How to add LAMP support to Ubuntu 14.0.4 64-bit on New OpenVZ
A LAMP (Linux, Apache, MySQL, PHP) stack is a common web stack used for hosting web content. This guide shows you hot to install a LAMP stack on an Ubuntu 14.04 (LTS) server.
Before You Begin
Ensure that you have followed the Securing Your Server guides, and the RentVPS' hostname is set.
Update your system:
Apache
Install and Configure
Install Apache 2.4:
Edit the main Apache configuration file,
apache2.conf, to adjust the KeepAlive setting:
- /etc/apache2/apache2.conf
The default multi-processing module (MPM) for Apache is the event module, but by default PHP uses the prefork module. Open the
mpm_prefork.conffile located in/etc/apache2/mods-availableand edit the configuration. Below is the suggested values for a 1GB RentVPS:
- /etc/apache2/mods-available/mpm_prefork.conf
Disable the event module and enable prefork:
Restart Apache:
Configure Virtual Hosts
There are several different ways to set up virtual hosts; however, below is the recommended method. By default, Apache listens on all IP addresses available to it.
Within the
/etc/apache2/sites-available/directory, create a configuration file for your website,example.com.conf, replacingexample.comwith your own domain information:
- /etc/apache2/sites-available/example.com.conf
<VirtualHost *:80> ServerAdmin webmaster@example.com ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/html/example.com/public_html/ ErrorLog /var/www/html/example.com/logs/error.log CustomLog /var/www/html/example.com/logs/access.log combined <Directory /path/to/public/website/> Require all granted </Directory> </VirtualHost>The
ErrorLogandCustomLogentries are suggested for more fine-grained logging, but are not required. If they are defined (as shown above), thelogsdirectories must be created before you restart Apache.
Create the above-referenced directories:
Link your virtual host file from the
sites-availabledirectory to thesites-enableddirectory:
If you later need to disable your website, run:
Reload Apache:
Assuming that you have configured the DNS for your domain to point to your RentVPS' IP address, virtual hosting for your domain should now work.
If there are additional websites you wish to add to your RentVPS repeat the above steps to add them.
MySQL
Install and Configure (Requirement: min. 128MB ram or 512MB swap)
Install the
mysql-serverpackage:
Choose a secure password when prompted.
Run
mysql_secure_installation, a program that helps secure MySQL. You will be presented with the opportunity to change the MySQL root password, remove anonymous user accounts, disable root logins outside of localhost, and remove test databases:
Create a MySQL Database
Log into MySQL:
Enter MySQL’s root password, and you’ll be presented with a MySQL prompt.
Create a database and a user with permissions for it. In this example the databse is called
webdata, the userwebuserand passwordpassword:
Exit MySQL:
PHP
Install PHP, and the PHP Extension and Application Repository:
If you need MySQL support also install
php5-mysql
Once PHP5 is installed, tune the configuration file located in
/etc/php5/apache2/php.inito enable more descriptive errors, logging, and better performance. The following modifications provide a good starting point:
- /etc/php5/apache2/php.ini
Ensure the lines above are uncommented. Commented lines begin with a semicolon (;).
Create the log directory for PHP and give the Apache user ownership:
Reload Apache:
Congratulations! You have now set up and configured a LAMP stack.
 877-SENTRIS
 877-SENTRIS
     
 
