Checklist for Setting up a CentOS 6 LAMP Server

I have to set up a new LAMP server for different clients here and there, but not with enough frequency to warrant using a particular scripted solution or 'stack' from a particular hosting company. Plus, I like to have a portable solution that is flexible to the needs (and constraints) of a client's website.

Note on hosting providers: For hosting, I've used a very wide variety of hosts. I typically use and recommend Hot Drupal VPSes or Linode VPSes [affiliate link] running CentOS for a good LAMP server. Shared servers are only good for nonessential or low-traffic sites, but they are a bit cheaper and easier to use for simpler needs!

So, here's a typical step-by-step process for how I set up a CentOS 6 (similar process for CentOS 5) server for LAMP (Linux, Apache, MySQL, and PHP), often for low-to-moderate Drupal sites (one or many):

  1. Set the server's hostname (guide).
  2. Set the server's timezone (guide).
  3. Install any existing updates using yum update (guide).
  4. Security: Add a non-root admin user, disable SSH password and root login (guide).
  5. Create a firewall for the server (guide).
  6. Enable the REMI/EPEL repos (guide) (for more recent versions of PHP, MySQL, Apache, etc.).
  7. Security: Install Fail2Ban (guide).
  8. Insall Apache, MySQL, and PHP (guide).
    1. Drupal also requires php-gd and php-xml
    2. Some configuration variables you might want to change:
      1. /etc/my.cnf: max_allowed_packet (for non-trival database imports, you want this to be bigger).
      2. /etc/httpd/conf/httpd.conf: Apache settings.
      3. /etc/php.ini: memory_limit, upload_max_filesize, at least
  9. Install and configure APC for PHP opcode caching (guide).
  10. Install and configure Munin for server monitoring (guide).
  11. Install git ($ sudo yum install git since you have the REMI/EPEL repos).
  12. Install drush (guide).

After you've completed all these steps, go ahead and configure Apache's VirtualHosts however you'd like (I typically create a special user for all the sites I run on that server, and include a 'vhosts.conf' file from the user's home directory in Apache's httpd.conf file). Then point a domain name to the server and see if everything's working for you!

Jeff Geerling is a Technical Architect at Acquia, owner of Midwestern Mac, LLC, and author of Ansible for DevOps. He is an active contributor in the Drupal community, and has primarily been a Mac user since the 1990s.

Comments

Add new comment