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):
- Set the server's hostname (guide).
- Set the server's timezone (guide).
- Install any existing updates using yum update (guide).
- Security: Add a non-root admin user, disable SSH password and root login (guide).
- Create a firewall for the server (guide).
- Enable the REMI/EPEL repos (guide) (for more recent versions of PHP, MySQL, Apache, etc.).
- Security: Install Fail2Ban (guide).
- Insall Apache, MySQL, and PHP (guide).
- Drupal also requires php-gd and php-xml
- Some configuration variables you might want to change:
/etc/my.cnf
:max_allowed_packet
(for non-trival database imports, you want this to be bigger)./etc/httpd/conf/httpd.conf
: Apache settings./etc/php.ini
:memory_limit
,upload_max_filesize
, at least- Install and configure APC for PHP opcode caching (guide).
- Install and configure Munin for server monitoring (guide).
- Install git (
$ sudo yum install git
since you have the REMI/EPEL repos). - 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!
Comments
May I suggest also the following link for setting up LAMP stack
http://howtolamp.com/lamp/