Skip to Content

Setting up a Linux webserver

Setting up a Linux webserver has never been easier as it is today. I have setup a bunch of them over the years and I wanted to share the list of applications I install for my webserver. This list is not specific to any one Linux distro. I also stick to using the Linux package managers to do the install as they will get the most recent version of the application and it makes setting this all up even easier.

  • Installation: Pick the Linux distro you like. I recommended Red Hat 6, Cent OS 5, Ubuntu (Any version really).
  • SSH: First thing you need is OpenSSH installed and running. Most distros should have this already installed but you might need to install it. Once you have openssh installed you no longer need to be at the computer itself and in most cases you do not have access other than ssh.
  • Firewall: Firewall is important to have on as soon as you install the machine. You can use iptables which is common firewall tool or you can use ufw orfirestarter. Once you have the firewall started I recommend setting up in way that blocks everything by default and you decide what ports should be open by providing a rule for each port.
  • Date and Time: Check to make sure the date and time matches where the machine is. Even if it is correct the clock skews after some time. I would recommend installing a ntp server to make sure it does not skew.
  • Web Server: To turn your server into a web server you need to install a web server. There are many out there to use such as Apache, Tomcat, Light Http, etc etc. I use Apache as my default server as it has a lot of documentation and tutorials on how to install and configure.
  • Web Programming Language: Once you have the web server running you can serve html pages right away. For other program written in different programming languages you will have to install them and install their web server plugin. Examples are Ruby on rails, PHP, Python and so on.
  • Database: For most of your websites or CMS’s you need a database and I recommend MySQL because it is easy to setup and use.
  • Statistics: It is useful to have access statistics for your server. You can read the locally stored logs file on your own. For a better way to look to see statistics you can use statistic tools like Google analystics or webalizer. I recommend webalizer as it is easy to use and it parses the apache log files to generate statistics.

Problems you might face:

  • Some application might not to be available through the package manager, so you might need to find an rpm or install the application from source.
  • Make sure you open the ssh port to your server otherwise you cannot access it.
  • Sometimes you might have the wrong timezone for your server, you will have to make sure to change the timezone in the correct configuration file to get it adjusted. If you use PHP as your web programming language in the current version you have to set the timezone in the php.ini file otherwise you get warning everytime you use the date function.

Extra Security:

  • User should have strong passwords specially users who have admin privileges.
  • No files/folders in the web root should be set to 777.
  • Restrict login forms, admin areas with htaccess files to restrict ips or use password protection.

Author: Daniel Mundra, CASIT Programmer