Language Selection

English French German Italian Portuguese Spanish

Quick Guide to Securing a Lamp Server

Filed under

In the last few years on the Internet the price of dedicated servers have went down and more people are beginning to use them for their sites, game servers, or small hosting companies. With this comes as I was talking about in my last article inexperienced admins. Lots of people I spoke too are too intimated by the linux shell and try to administer their server completely from the control panel.
This short guide will show you a few copy and paste walkthroughs you can use to help secure your server, these should work with any control panel, the mod security update script however is only for apache2. Using these tools and using basic security procedures will help you keep your server secure and free of hackers, spammers, and other annoyances.

Using linux as a personal desktop helps a lot as well as it gets you used to using the command line. The other extremely valuable tool is google. I would probably be nowhere without google. You can look stuff up as you go and find about any answer to any question you may have, Plus there is lots of walkthroughs just like this one I am just putting all the basic ones together.

OK this is not a complete guide but those who are less experienced should be able to follow these walkthroughs and make their server more secure then it was before.
First thing, install apf, bfd, and dos deflate. Complete walkthrough HERE
Note: Dos deflate will not work with debian unless you disable ipv6.

Next install modsecurity using the simple guide from, guide can be found HERE

After you install mod security make a directory in /etc called modsecurity. Use my update script found HERE (apache2 only)
This will get all the latest rules from when you have them at the bottom of the mod security configuration in httpd.conf put
Include /etc/modsecurity/apache2/rulename.conf
I suggest using them all besides rules.conf as it gives lots of false positives.

Now if you have shell users or are running redhat, fedora, or debian you most likely need to update your kernel. Now this isn't as hard as you would think, with this copy and paste guide I made that is all you have to do is copy and paste, same as these other tutorials.
The guide can be found HERE. I will be making one for debian soon but you just use any basic debian kernel how to and patch the kernel the same way as you do in this one.

Once you have modsecurity installed keep an eye on the audit log to make sure it is not giving any false positives or blocking legitimate web apps. With the ruleset and rules you have included it should not unless someone is using some oddball web app.
None of these will make your server totally secure, it takes basic security practices such as using strong passwords, not using the same password for everything, and keeping up with all the latest exploitrs and hacking methods.

If you ever get hacked don't go ranting about how you are gonna prosecute so and so, go find out how they done it, how they got in, and what you can do to prevent it again. You will most likely never track down the hackers and the FBI most likely will not care so secure your system and make sure it does not happen again. As I have explained before defacers can actually be helpful to admins. That's about it, good luck and stay on your toes.

More in Tux Machines

Leftovers: OSS

  • Video: PBS Pro Workload Manager Goes Open Source
  • Turris Omnia: high-security, high-performance, open-source router
    An Indigogo campaign was recently launched for the Turis Omnia, promising backers a high-security, high-performance, open-source router. “With powerful hardware, Turris Omnia can handle gigabit traffic and still be able to do much more,” the company said. “You can use it as a home server, NAS, printserver, and it even has a virtual server built-in.”
  • IBM SystemML Machine Learning Technology Goes Open-Source
  • PuppetLabs Introduces Application Orchestration
    Everybody loves Puppet! Or at the very least, an awful lot of people USE Puppet and in the IT world, “love” is often best expressed by the opening of one’s wallet. I know, in the FOSS world wallets are unnecessary, and Puppet does indeed have an Open Source version. However, once one gets to enterprise-level computing, a tool designed for enterprise scale is preferable and usually there is a cost associated. Puppet was originally started as an open source project by Luke Kanies in 2005, essentially out of frustration with the other configuration management products available at the time. Their first commercial product was released in 2011, and today it is the most widely used configuration management tool in the world with about 30,000 companies running it. According to our own surveys, better than 60% of Linux Journal readers use some form of Puppet already and you must like it too as it regularly finishes at or near the top in Readers’ Choice awards.

today's howtos

Ubuntu 16.04 LTS Continues To Focus On The Linux 4.4 Kernel

Ubuntu's kernel team continues to be focused on having Linux 4.4 for Ubuntu 16.04. Linux 4.4 is their target for the "Xenial Xerus" since Ubuntu 16.04 is to be a Long-Term Support release and the upstream 4.4 kernel is also being maintained as a long-term release too. Additionally, Linux 4.5 would come too close to the April debut of Ubuntu 16.04 that the developers wouldn't feel comfortable, particularly for an LTS release. Read more

Will Steam Machine Solve Linux’s Gaming Woes?

The Steam machine is now publicly on sale as of last week, but it’s not off to the best start. A couple of weeks ago, Ars Technica compared the performance of games when running on Valve’s Linux based SteamOS and Windows 10. Six Valve games were tested on a single machine and results showed a 21 to 58 percent frame rate drop when running on Linux. While only six games were tested out of an entire collection of around 1,800 available titles, the games used Valve’s own Source engine, which is designed for Linux and SteamOS. Valve had previously stated that Steam games run faster on Linux, so it was expected that any of Valve’s own Source engine games would run smoothly. Read more