Security, Server Administration, Technology, Uncategorized

Hardening LAMP / Plesk VPS / DDoS Mitigation.

If you want to harden the security of your Plesk VPS, there are a couple of things you can do from disabling non-essential apache modules to reduce attack vectors and from adding/activating some apache modules that can help in the department of security. In this article i will share with you what i have found after a couple of days of research and give you some practical tips, apache modules to install/enable/disable and some 3rd party services i have found to be of use.

What we will cover:
1) Disclaimer.
2) DNS / Proxy services (like CloudFlare).
3) Installing mod_evasive.
4) Installing mod_security.
5) Adding a rule set to mod_security courtesy of OWASP.
6) Enabling/Disabling useful Apache Modules.
7) Plesk Firewall Changes.
8) Configuring ‘httpd.conf’.
9) Disabling Directory Browsing.
10) Prevent PHP exposing itself in HTTP Headers.
11) Further Reading.


I am not a security expert by any measure, and make no guarantees that any of this will work for you! Please test your setup on a test bed before deploying and backing up your server (scripts/assets/database/configs etc) should be standard practice as i cannot be held responsible for any damages caused.

Further more, i use yum on CentOS and will not translate these instructions for use on other platforms or other package managers. If you are using apt-get, rpm, dpkg or anything else you will need to go to the original sites; the links for which i have provided and find alternative install instructions there.

CloudFlare and CDN’s.

Where DDoS attacks are concerned, there are some things you can do to help mitigate the attack but overall your options will be severely limited on any VPS. VPS’s generally mean you are already sharing your hardware with several other virtual servers, which could scale in any quantity depending on your provider and their policies.

The more virtual machines running side by side with your own VPS on the same hardware the lesser chance of successfully mitigating a DDoS attack. This is due to the limitations of bandwidth from the switch to that hardware combined with how much traffic your site and the other VPS’s on the same hardware are using.

Further more, the switch itself could have already peaked its limit, meaning nothing you do on your server will help to mitigate the attack.

If that is the case, then you have 2 options:
1) Migrate your DNS to CloudFlare or any other DNS/proxy/CDN services out there (there are lots to choose from, though CloudFlare is one of the most up and coming out there).
2) Contact your VPS provider and enquire as to any DDoS protection they are using at the switch/router level and wether they have any additional more dedicated filters that can be used. If they do provide such a service though it will likely come at a premium. Some ISPs/hosting companies will allow you to use your own hardware if you own it to filter out such attacks though will still likely charge you to use it (for the electricity and rack-space being used). Even then, such filtering boxes can be fallible.

From my own experience so far, i highly recommend trying out CloudFlare

Also, once setup on CloudFlare, considering installing their apache module from the downloads section mod_cloudflare.

Note that using CloudFlare comes with some added advantages, being a CDN, scripts/css/images and so fourth are cached, and further more, additional features can be enabled for blocking scrapers and spambots. Lastly as a really nice addition are the statistics that CloudFlare provide for you on bandwidth, and hits/visitors etc.

Now moving on to some more important tricks we can use to help mitigate weaker attacks on our system such as single DoS scripts and content scrapers etc.

Apache Modules.

Before we go ahead and do anything here, i highly recommend you back up your entire system setup, including your site contents and database and keep a copy of the backup on your local machine. I cannot be held responsible for data loss because something went wrong, so please, just backup your stuff, ok?

For this we will want 2 apache modules, mod_evasive and mod_security.

Mod_evasive will attempt to monitor connections looking for excessive repeat requests to the same resources from the same source and block out what it deems to be either DoS, DDoS, content scrapers or some other brute force attack. You can read more about that here.

Mod_security will employ a number of tactics to cover a large range of security implications from brute force attacks, xss attacks and also work to patch exploits in the OS once discovered by the community prior to the release of updates from the software providers. This is a much more sophisticated module and the original site for the project can do its description much greater justice than i can, so you can read more about it here. Though i will provide you with an extract from the site:

Real-Time Monitoring and Attack Detection

In addition to providing logging facilities, ModSecurity can monitor the HTTP traffic in real time in order to detect attacks. In this case ModSecurity operates as a web intrusion detection tool, allowing you to react to suspicious events that take place at your web systems.

Attack Prevention and Just-in-time Patching

ModSecurity can also act immediately to prevent attacks from reaching your web applications. There are three commonly used approaches:

Negative security model. Negative security model monitors requests for anomalies, unusual behaviour, and common web application attacks. It keeps anomaly scores for each request, IP addresses, application sessions, and user accounts. Requests with high anomaly scores are either logged or rejected altogether.
Known weaknesses and vulnerabilities. Its rule language makes ModSecurity an ideal external patching tool. External patching is all about reducing the window of opportunity. Time needed to patch application vulnerabilities often runs to weeks in many organisations. With ModSecurity, applications can be patched from the outside, without touching the application source code (and even without any access to it), making your systems secure until a proper patch is produced.
Positive security model. When positive security model is deployed, only requests that are known to be valid are accepted, with everything else rejected. This approach works best with applications that are heavily used but rarely updated.

Just as a note here, i am using Plesk 11, HTTPD 2.2 on a CentOS setup. You may wish to tweak the install steps according to your own setup. If you do not have/use yum, you may want to use apt-get instead which is fine.

Apache Module mod_evasive.

$ cd /usr/src/
$ wget
$ mkdir mod_evasive/
$ tar xvzf mod_evasive_1.10.1.tar.gz mod_evasive/
$ cd mod_evasive/
$ ls -al
$ /usr/sbin/apxs -i -a -c /usr/src/mod_evasive/mod_evasive20.c

Some of the older install instructions use the wrong download link which is no longer active, i have provided the more up to date link in the instructions for you. You will also need wget, which if you do not have on your Plesk install i suggest you install.

That should be mod_evasive installed. It is best to ensure you have not broken anything so do a restart of the HTTP Daemon.

$ service httpd restart

Apache Module mod_security.

Next up, in order to install Mod_Security we need to ensure we have the following dependencies:

$ yum install libxml2
$ yum install libxml2-devel
$ yum install libcurl
$ yum install libcurl-devel

I am using mod_security_2.6.7 (there was a 2.7.0 prelease candidate but i don’t recommend using pre-release candidates as they may have bugs etc and 2.6.7 is considered stable).

$ cd /usr/src/
$ mkdir mod_security/
$ wget
$ tar xvzf modsecurity-apache_2.6.7.tar.gz
$ cd /modsecurity-apache_2.6.7
$ ./configure
$ ./configure --with-apxs=/usr/sbin/apxs
$ make
$ make mlogc
$ make install

I am also using apxs, which if you do not have/use, you may want to consult the original install instructions.

Before we can use this however, we have to edit the httpd.conf file to ensure that it is including the libxml and lua libs, use your preferred text editor to add the following at the top of the list of LoadModule section labelled (Dynamic Shared Object (DSO) Support).

#LoadFile /usr/lib/
LoadFile /usr/lib64/
#LoadFile /usr/lib/
LoadFile /usr/lib64/

LoadModule security2_module modules/

If the server fails to load the httpd server, then swap the commented out LoadFile lines with the uncommented ones.

As before, it is best to ensure you have not broken anything so do a restart of the HTTP Daemon.

$ service httpd restart

Adding the OWASP Rule Set.

The Open Web Application Security Project (OWASP) is a set of predefined rules to harden your mod_security setup. According to OWASP, mod_security does not do a great deal on its own, while it will by default add some protection, it will need a decent rule set to really put this thing to task. Many of the rule sets are commercial and will cost you money, however OWASP provide a nice set of rules for free to harden any server.

You can check out the project on their homepage.

Installation was a little tricky as their docs seems slightly inconsistent and poorly explained a few things. However assuming you are running Plesk 11, i will run you through the necessary steps to get this setup easily.

One of the things in the official docs was that the install directories were all wrong, or at least wrong for Apache 2.2 on a Plesk 11 setup. If this does not work for you then go ahead and follow the original docs, otherwise give this a go.

$ cd /etc/httpd/conf/
$ wget
$ mv master owasp.tar.gz
$ tar xvzf owasp.tar.gz
$ mv SpiderLabs-owasp-modsecurity-crs-618ff50/ crs/

The filename extracted from the tarball may be different depending on the build/revision from the git repository.

Also, in this next section, i tried the newer 2.2.6 configuration but it seemed incompatible with the current stable build of mod_security, i could not find very good documentation explaining all the necessary steps or the difference, but my guess is that 2.2.6 is meant for the new mod_security 2.7.0 pre-release. So i went with 2.2.5 which worked. Version 2.2.6 will give you issues! (namely the httpd won’t start due to misconfigurations).

$ cd 2.2.5/
$ cp modsecurity_crs_10_setup.conf.example modsecurity_crs_10_config.conf

In that last step not only do we need to rename the copy to remove the “.example”, but also to change “_setup” to “_config”, this is an issue as the docs only say to remove example, and cite a wrongly named file. Just an error in their docs which i am sure will be addressed at some point but don’t let that trip you up.

Next up we need to make some changes to the file, we need to change the deny option on secDefaultAction to pass, according to the doc, (which actually will cause an error).

What they meant to say was set it the following:

SecDefaultAction "phase:2,deny,log"

To look like:

SecDefaultAction "phase:2,pass"

Use whatever text editor you prefer. I used vi, but feel free to use nano or pico etc.

Next up, we want to set up all the symlinks, linking the rules we wish to use into the ‘activated_rules’ directory.

I have corrected the following again from the docs to match the directories that are being used for httpd configurations in Plesk 11, which were invalid in the original docs but thats fixed in the steps i have given you below:

$ sudo ln -s /etc/httpd/conf/crs/2.2.5/modsecurity_crs_10_config.conf activated_rules/modsecurity_crs_10_config.conf
$ for f in `ls base_rules/` ; do sudo ln -s /etc/httpd/conf/crs/2.2.5/base_rules/$f activated_rules/$f ; done
$ for f in `ls optional_rules/ | grep comment_spam` ; do sudo ln -s /etc/httpd/conf/crs/2.2.5/optional_rules/$f activated_rules/$f ; done

Now, if we peak inside the activated_rules, what we should have is a list of symlinks:

$ ls -al activated_rules/
total 112K
drwxr-xr-x 2 root root 4.0K Sep 19 13:27 .
drwxr-xr-x 9 root root 4.0K Sep 19 13:25 ..
lrwxrwxrwx 1 root root   67 Sep 19 13:26 -> /etc/httpd/conf/crs/2.2.5/base_rules/
lrwxrwxrwx 1 root root   65 Sep 19 13:26 -> /etc/httpd/conf/crs/2.2.5/base_rules/
lrwxrwxrwx 1 root root   72 Sep 19 13:26 -> /etc/httpd/conf/crs/2.2.5/base_rules/
lrwxrwxrwx 1 root root   78 Sep 19 13:26 -> /etc/httpd/conf/crs/2.2.5/base_rules/
lrwxrwxrwx 1 root root   73 Sep 19 13:27 -> /etc/httpd/conf/crs/2.2.5/optional_rules/
lrwxrwxrwx 1 root root   65 Sep 19 13:26 -> /etc/httpd/conf/crs/2.2.5/base_rules/
lrwxrwxrwx 1 root root   73 Sep 19 13:26 -> /etc/httpd/conf/crs/2.2.5/base_rules/
lrwxrwxrwx 1 root root   56 Sep 19 13:26 modsecurity_crs_10_config.conf -> /etc/httpd/conf/crs/2.2.5/modsecurity_crs_10_config.conf
lrwxrwxrwx 1 root root   80 Sep 19 13:26 modsecurity_crs_20_protocol_violations.conf -> /etc/httpd/conf/crs/2.2.5/base_rules/modsecurity_crs_20_protocol_violations.conf
lrwxrwxrwx 1 root root   79 Sep 19 13:26 modsecurity_crs_21_protocol_anomalies.conf -> /etc/httpd/conf/crs/2.2.5/base_rules/modsecurity_crs_21_protocol_anomalies.conf
lrwxrwxrwx 1 root root   75 Sep 19 13:26 modsecurity_crs_23_request_limits.conf -> /etc/httpd/conf/crs/2.2.5/base_rules/modsecurity_crs_23_request_limits.conf
lrwxrwxrwx 1 root root   72 Sep 19 13:26 modsecurity_crs_30_http_policy.conf -> /etc/httpd/conf/crs/2.2.5/base_rules/modsecurity_crs_30_http_policy.conf
lrwxrwxrwx 1 root root   71 Sep 19 13:26 modsecurity_crs_35_bad_robots.conf -> /etc/httpd/conf/crs/2.2.5/base_rules/modsecurity_crs_35_bad_robots.conf
lrwxrwxrwx 1 root root   76 Sep 19 13:26 modsecurity_crs_40_generic_attacks.conf -> /etc/httpd/conf/crs/2.2.5/base_rules/modsecurity_crs_40_generic_attacks.conf
lrwxrwxrwx 1 root root   82 Sep 19 13:26 modsecurity_crs_41_sql_injection_attacks.conf -> /etc/httpd/conf/crs/2.2.5/base_rules/modsecurity_crs_41_sql_injection_attacks.conf
lrwxrwxrwx 1 root root   72 Sep 19 13:26 modsecurity_crs_41_xss_attacks.conf -> /etc/httpd/conf/crs/2.2.5/base_rules/modsecurity_crs_41_xss_attacks.conf
lrwxrwxrwx 1 root root   77 Sep 19 13:27 modsecurity_crs_42_comment_spam.conf -> /etc/httpd/conf/crs/2.2.5/optional_rules/modsecurity_crs_42_comment_spam.conf
lrwxrwxrwx 1 root root   75 Sep 19 13:26 modsecurity_crs_42_tight_security.conf -> /etc/httpd/conf/crs/2.2.5/base_rules/modsecurity_crs_42_tight_security.conf
lrwxrwxrwx 1 root root   68 Sep 19 13:26 modsecurity_crs_45_trojans.conf -> /etc/httpd/conf/crs/2.2.5/base_rules/modsecurity_crs_45_trojans.conf
lrwxrwxrwx 1 root root   78 Sep 19 13:26 modsecurity_crs_47_common_exceptions.conf -> /etc/httpd/conf/crs/2.2.5/base_rules/modsecurity_crs_47_common_exceptions.conf
lrwxrwxrwx 1 root root   85 Sep 19 13:26 modsecurity_crs_48_local_exceptions.conf.example -> /etc/httpd/conf/crs/2.2.5/base_rules/modsecurity_crs_48_local_exceptions.conf.example
lrwxrwxrwx 1 root root   77 Sep 19 13:26 modsecurity_crs_49_inbound_blocking.conf -> /etc/httpd/conf/crs/2.2.5/base_rules/modsecurity_crs_49_inbound_blocking.conf
lrwxrwxrwx 1 root root   69 Sep 19 13:26 modsecurity_crs_50_outbound.conf -> /etc/httpd/conf/crs/2.2.5/base_rules/modsecurity_crs_50_outbound.conf
lrwxrwxrwx 1 root root   78 Sep 19 13:26 modsecurity_crs_59_outbound_blocking.conf -> /etc/httpd/conf/crs/2.2.5/base_rules/modsecurity_crs_59_outbound_blocking.conf
lrwxrwxrwx 1 root root   72 Sep 19 13:26 modsecurity_crs_60_correlation.conf -> /etc/httpd/conf/crs/2.2.5/base_rules/modsecurity_crs_60_correlation.conf

If you have something similar to that, then you are good so far.

Next up we need to edit our httpd.conf file to include the rules. This is what i added, and i added mine below the ‘extendedStatus on’ section which is only a bit below the LoadModule section. I would recommend doing the same so that it follows after the loading of mod_security.

# mod_security setup

    Include conf/crs/2.2.5/modsecurity_crs_10_config.conf
    Include conf/crs/2.2.5/activated_rules/*.conf

That should load all the symlinked rule files into mod_security, and thus you should be done. 🙂

Now to restart the httpd server once again and check that everything is ok.

$ service httpd restart

Enabling/Disabling Apache Modules.

With a complex server that is exposing itself in so many ways to the outside world, the least number of modules you can have running will help in reducing possible attack vectors that can be exploited by malicious hackers. Plesk makes enabling and disabling apache_modules super easy so we should not need to fire up the CLI/SSH any further at this point. Log into your Plesk panel and go to the “Tools & Settings” tab. There click on ‘Apache Modules’ which should be under ‘General Settings’ group.

Please check carefully the function of each apache module before turning it off, although i do not need them myself, you may depending on what your doing with your server. I have gone and made it easy by grouping them into some useful groups to explain what they are roughly about, and also provided a link for each module so you can get the official story on what its about before you go ahead and turn it off.

Here are a list of modules you should turn ON:

So, the evasive20 and the security2 modules correspond to the modules we installed earlier, if they are not on already turn them on now!

If you are running Plesk and not something else like CPanel, you will still need to be running mod_perl and mod_python even if you do not use perl or python scripts yourself on your server Plesk depends on these scripting engines (sucks i know, would love to disable them both, i just don’t use them).

Here are some modules you should turn OFF:

Filtering and substitution modules you likely will never use. (each one refiltering the same content and with potentially multiple rules being applied to each. Madness!)

Modules for remote management of database, mostly using really peculiar and obscure methods not suitable for average Plesk VPS users.

Chances are you won’t be using LDAP.

Mostly things you won’t need or care about.

With regards to deflate, please bear in mind that firstly, most browsers will cache images, css and scripts, so deflating them is pointless. Secondly as for html output, use a decent framework with template optimisation and caching for your code. For example, in php there is the Symfony framework which automatically optimises your html (strips whitespace from your html [to some limited extent, but can be optimised further with some understanding of the template engine]). Also, minify your assets manually prior to upload or during the process of building a local cache for your sites assets, this will have the same affect as using deflate except it only need be done once, where as deflate does it every single request (not good for performance!). You get extra points for using CloudFlare which acts as a CDN and will cache all your assets for you.

Next up, if you are not using SHTML SSI, CGI scripts, Tomcat/Server side Java Applets, then disable all of the following:

These are mostly tracking and logging, from a security stand point that can be a good thing, however chances are most of these logs won’t ever be checked, and all bloat your servers load time. If you need them, just pick a few but don’t enable them all. Remember that CloudFlare will block some of the damage and also log a lot of the activity for you, further more mod_evasive and mod_security will also block quite a lot of varying attacks now. I would only be activating them if i have an issue that needs a closer look, otherwise its just more crud running in the background.

You likely won’t need rpaf, if you don’t know what it is, you likely do not need it, same for mod_aclr for nginx.

Chances are you can also disable most of the authn_ and authz_ modules, unless you have specific use cases for them. The same also applies to all the proxy modules.

By disabling most/all of the above not only do we reduce the number of attack vectors but actually save a lot of memory and your website will generally load much faster. Since making these changes i have noticed nearly more than half the load time on my site. Thats nearly twice as fast. (site being CodeConsortium).

Sometimes performance is a benefit when mitigating DDoS (depending on the level of the attack), where if your site is being reduced to a crawl, at least if the content is served a bit quicker and the assets are cached on some CDN, the site may still be usable (potentially).

There may be more modules you can disable, however it is your responsibility to work that out for yourself, see what you need and don’t need. Also try them out few at a time rather than doing all of them and then finding you broke something, much easier to eliminate the potential causes from the list if you only do a few or 1 at a time.

If you want to know what modules are loaded, try ‘$ httpd -M’ to list them.

Plesk Firewall Changes.

By default, plesk leaves quite a few services exposed that you probably won’t need access to from the outside, particularly when access is already being provided through an html interface via the Plesk Panel.

Change the following to “deny incoming from all” for the following at your own discretion:

  • MySQL Server (this can be administrated through PHPMyAdmin, no need to allow direct access to this).
  • PostGreSQL Server (same as above).
  • Tomcat Administrative Interface (if your not using java on the server that is, otherwise you *might* need it).
  • Samba (Just not likely to need it, FTP will do fine).
  • Ping Service

With regard to the ping service, i choose to deny all traffic for the simple reason that, if your using CloudFlare, then your servers original IP address should be hidden behind CloudFlare. However if some malicious hacker does find your IP address, they should not be able to view the website as the traffic did not originate from cloudflare (thanks to the mod_cloudflare) so there browser should not receive any html or valid responses. So the last thing we want to do is validate their suspicions that the IP they have uncovered is legit by returning a ping request. In-fact what we want is to tell any potential hackers the least amount of useful information we can get away with; without crippling our own network.

The other thing to remember is, some of the older attacks still use ping for DDoS, denying inbound ping requests will lighten the load on the server if an attacker should choose to use this method. That said, the switch, router and even servers NIC can still be overloaded if the packet size and quantity is very large, and while we cannot really stop inbound ping based DoS attacks, at least we are not wasting outbound traffic by responding to it.

Configuring ‘httpd.conf’.

We can add some more fine grain refinements to our httpd.conf file for a little bit extra security.

1) Set, ServerSignature to Off. This will reveal less info in the http headers about your server setup.
2) Set ServerTokens to Prod. Also works to reveal less info in the http headers.
3) Add Header unset X-Powered-By.
4) Limit request body.
5) Limit XML request body.
6) Lower the timeout to 45 seconds.

I recommend only setting 1 or 2 of these at a time and then testing them before changing more. You can do this incrementally by testing each config by running ‘httpd -t’ on the CLI.

# Disable features with known stability issues.
EnableMMAP Off
EnableSendfile Off

# Reduce exposure.
ServerSignature to Off
ServerTokens to Prod
Header unset X-Powered-By

# Impose limits on Request/Responses.
LimitInternalRecursion 5
LimitRequestBody 5242880
LimitXMLRequestBody 5242880
LimitRequestFields 50

Timeout 45

KeepAlive On
KeepAliveTimeout 15
MaxKeepAliveRequests 45

If you have already setup your CloudFlare, or any other CDN for that matter, and are using some tool to monitor your HTTP Headers. Then you may notice that most of the resources still say X-Powered-By etc while the main page html does not. This is because you need to log into your CloudFlare/CDN and purge your cache after you have saved the above settings and restarted your HTTPD server. After restarting your server and purging your CDN cache, you will notice the X-Powered-By header strings disappear.

Disabling NMAP and SendFile, is more for the instability issues that can occur. Both are designed to allegedly improve performance of serving static content, however i did not notice any decrease in performance by disabling them. This is likely because my site is entirely dynamic with the exception of assets that are already being cached on the CDN. Therefor if you use a CDN and most of your site is dynamically generated via PHP, Ruby or likewise then just turn these both off as they won’t do much for improving performance but could reduce stability issues for your OS (which is good).

Setup a sensible default for public directories that apache has access to.

# Limit access to default directories, block altogether if possible.
# If you do not use them, just deny from all!

    Options -Indexes +FollowSymLinks -ExecCGI -Includes
    AllowOverride None

    #Options -Indexes +FollowSymLinks -ExecCGI -Includes
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all

    AllowOverride FileInfo AuthConfig Limit
    #Options -MultiViews -Indexes -FollowSymlinks -SymLinksIfOwnerMatch -IncludesNoExec -Includes -ExecCGI
    Options None
        Order allow,deny
        #Allow from all
        Deny from all
        Order deny,allow
        Deny from all

Any other instances for the setup of vhosts/alias and directories etc, use -Indexes to prevent browsing of directories everywhere.

Some default apache/Plesk installs will setup an alias to /icons/, make sure that you disable this by commenting out the alias line. You can also keep the remaining setup for this by once again negating the Indexes and lastly, change the last bit to ‘Deny from all’.

#Alias /icons/ "/var/www/icons/"

    #Options -Indexes -MultiViews -FollowSymLinks -ExecCGI -Includes
    Options None
    AllowOverride None
    Order allow,deny
    Deny from all

Do the same again for the CGI scripts directory.

#ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.

    AllowOverride None
    Options None
    Order allow,deny
    Deny from all

Though i added the header unset directive for the X-Powered-By, the same does not work for MS-Authored-By header string, in order to remove this, comment out the LoadModule lines for:

  • #LoadModule dav_fs_module modules/
  • #LoadModule dav_module modules/

Some of the above tricks were found here.

Disabling Directory Browsing.

Also, you can edit your vhost.conf so that the line for Options disables indexes and allows symlinks. By doing this symlinks being active means the OS treats symlinks like regularly directories and takes less time to by passing checks on wether the folder is a symlink or not and checking if the directory it points to exists or not. This way we don’t check if it exists before trying to follow it, so it speeds things up a little. Disabling indexes will turn off directory browsing, which just adds a little extra onto our security.

Options -Indexes +FollowSymLinks

Prevent PHP exposing itself in HTTP Headers.

In your php.ini turn expose_php to Off.

Remember, you will likely have quite a few versions of php.ini all over your file system, you have the default one, then sometimes another default for the CLI (which can differ), also you may have one for the Plesk system, and again another for each individual vhost.

Here is a nice script to tell you which php.ini files are exposing your server.

$ for f in `locate php.ini` ; do echo $f; cat $f | grep expose_ ; done

Output should be something like:

expose_php = Off
expose_php = On
expose_php = Off
expose_php = Off
expose_php = On
expose_php = Off

If you have a very short list, or none at all, then you may need to update your locate database.

$ updatedb


These are the steps i have taken so far, though i am continuing the search to harden the Plesk / LAMP stack. As i find new techniques that are particularly profound i will follow up with more articles. If you have any suggestions, please leave a comment below or head over to the forum. Some of the links below in the further reading section cover topics i am yet to fully investigate, and i will write more articles about other new techniques soon.

Further Reading.

Some of the resources i found which you may find useful and may include more tricks you can use not covered here.

Official / Links for Best Practices (ordered by least paranoid security approach / simplest first):
Official Apache Security Documentation
Symantec – Securing Apache: Step-by-Step.
WPSecure Server Guide.
SANS Institute – Security Consensus Operational Readiness Evaluation.
NSA Guide on Securing your OS (features documentation for most OS’s).

An auditing checklist from DISA (supposedly they do audits for the US DoD [Department Of Defence]) here (its in a zip file).

Some other links you may find interesting:
20 ways to Secure your Apache Configuration.
Mad Irish: Hardening PHP from php.ini.
How To: Harden and Secure Your Linux Server – ASL and Plesk.
DDOS Protection | Sysctl protection | DDoS Deflate.
Developer.Mozilla The X-Frame-Options response header MDN.

Good luck.