ZH cheese: Ubuntu 14.04 installation lamp (linux,apache,mysql,php) has been introduced before lamp installation, this article mainly explain the lamp configuration.
1. Configure Apache
(1) Adjust the KeepAlive settings (refer to [1], [2]):
On a server with sufficient memory, the server performance will not change significantly, whether or not the KeepAlive function is turned off;
If the server memory is low, or the server has a very large number of file system access, or the main processing Dynamic Web services, the shutdown KeepAlive can save a lot of memory, and the saved memory for the file system cache, can improve the performance of file system access, and the system is more stable.
Files:/etc/apache2/apache2.conf
KeepAlive OFF
(2) Configuring Multi-Processing Module (MPM) (reference [3])
Apache default MPM is event module,php using Prefork module.
Files:/etc/apache2/mods-available/mpm_prefork.conf
The configuration below is more suitable for 1GB Linode VPS
<ifmodule mpm_prefork_module> startservers 2 minspareservers 6 maxspareservers maxclients </IfModule>
(3) Deactivate the event module and enable the Prefork module
sudo A2dismod mpm_event sudo a2enmod mpm_prefork
(4) Restart Apache
sudo service apache2 restart
2. Configuring virtual Hosts
There are many ways to configure a virtual host, and below is the recommended method. By default, Apache listens for all IP addresses that can access it.
(1) in the directory /etc/apache2/sites-available/ directory, create a new profile for your site example.com.conf , replace it with your own domain name example.com
Files:/etc/apache2/sites-available/example.com.conf
<virtualhost *:> ServerAdmin [email protected] ServerName example.com Serveralias www.example.com /var/www/html/example.com/public_html/ /var/www/html/example.com/logs/ Error.log /var/www/html/example.com/logs/access.log combined <Directory/path/to/public/website/> Require All granted </Directory></VirtualHost>
Note: It is recommended that the errorlog and customlog entrances be as fine-grained as possible (detailed partitioning)
Attention! : If Errorlog and Customlog (for example, above) are configured, you must ensure that the path logs exists before restarting Apache.
(2) Create a directory:
sudo mkdir -p/var/www/html/example.com/public_htmlsudomkdir /var/www/html/example.com/logs
(3) Link your web hosting file from the Sites-available directory to the sites-enable directory:
sudo a2ensite example.com.conf
Note: If you later need to remove this site, run:
sudo a2dissite example.com.conf
(4) Reload Apache
sudo service apache2 Reload
3. Create a MySQL Database
(1) Login
(2) Create a database and an authorized user (for example, create a WebData database with the user name: webuser, Password: password):
CREATE database WebData; grant all on WebData. ' WebUser ' ' Password '
(3) Exit MySQL:
Quit
4. Configure PHP
(1) configuration file: /etc/php5/apache2/php.ini
Configure more error descriptions, logs, and performance.
error_reporting = e_compile_error| e_recoverable_error| e_error| =/var/log/php/
Note: Make sure that the top lines are not commented out. Comment lines begin with a semicolon (;)
(2) Build a log directory for PHP and give Apache ownership:
sudo mkdir /var/log/phpsudochown www-data/var/log/php
(3) Reload Apache:
sudo service apache2 Reload
Summary: Now know the Apache and PHP configuration file location and methods, more understanding of configuration parameters, you can configure a more suitable site for their site.
Reference link: How to Install a LAMP Stack on Ubuntu 14.04
ZH cheese: Ubuntu 14.04 configuration lamp (Linux, Apache, MySQL, PHP)