1. Acquire root privilages:
sudo -i2. Update system:
apt update && apt upgrade3. Install Apache 2
apt install apache24. The KeepAlive setting allows Apache to utilize server-side memory, reducing latency for users on the hosted site. KeepAlive will make a website faster if the host has enough memory to support it. This is done by allowing Apache to reuse connections, instead of opening a new connection for every request.
vi /etc/apache2/apache2.confMake the changes as below (or you can edit it as per your needs):
KeepAlive On MaxKeepAliveRequests 50 KeepAliveTimeout 55.The default multi-processing module (MPM) is the prefork module. Mpm_prefork is the module that is compatible with most systems. Since the LAMP stack requires PHP, it may be best to stick with the default.
vi /etc/apache2/mods-available/mpm_prefork.conf
<ifmodule mpm_prefork_module=""> StartServers 4 MinSpareServers 3 MaxSpareServers 40 MaxRequestWorkers 200 MaxConnectionsPerChild 10000 </ifmodule>6. Disable the event module and enable prefork:
a2dismod mpm_event
a2enmod mpm_prefork7. Restart Apache
systemctl restart apache28. Create a copy of the default Apache configuration file for the site:
cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf9. Edit the new example.com.conf configuration file by uncommenting ServerName and replacing example.com with your site’s IP or Fully Qualified Domain Name (FQDN). Enter the document root path and log directories.
vi /etc/apache2/sites-available/example.com.conf
<virtualhost> ServerName example.com ServerAlias www.example.com ServerAdmin webmaster@localhost DocumentRoot /var/www/html/example.com/public_html <directory /var/www/html/example.com/public_html> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </directory> ErrorLog /var/www/html/example.com/logs/error.log CustomLog /var/www/html/example.com/logs/access.log combined </virtualhost>10. Create the directories:
mkdir -p /var/www/html/example.com/{public_html,logs}
11. Link virtual host file from the sites-available directory to the sites-enabled directory:
a2ensite example.com.conf12. Disable the default virtual host to minimize security risks:
a2dissite 000-default.conf13. Reload Apache:
systemctl reload apache214. Install the mysql-server
apt install mysql-server14. Log into MySQL:
mysql -u root –p15. Create a database and a user with permissions for it.
CREATE DATABASE dbname; GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';16. Exit MySQL
quit17. Install PHP, the PHP Extension and Application Repository, Apache support, and MySQL support:
apt install php7.0 libapache2-mod-php7.0 php7.0-mysqlOptionally, install additional cURL, JSON, and CGI support:
apt install php7.0-curl php7.0-json php7.0-cgi18. Edit the php configuration file
vi /etc/php/7.0/apache2/php.ini
max_input_time = 30 error_reporting = E_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_ERROR | E_CORE_ERROR error_log = /var/log/php/error.log19. Create the log directory for PHP and give ownership to the Apache system user:
mkdir /var/log/php chown www-data /var/log/php20. Restart Apache:
systemctl restart apache2Now Let's check if the installed LAMP server working properly
21. Paste the following code into a new file in the documentroot,(/var/www/html/example.com/public_html)
vi /var/www/html/example.com/public_html/info.php
<?php phpinfo(); ?>22. Restart apache2
systemctl restart apache223. Edit the /etc/hosts file on local machine and enter the server's IP address and domain name.
vi /etc/hosts
ip address example.comNavigate to example.com/info.php from local machine.
October 28, 2018
Tags :
lamp
,
lamp on ubuntu
,
ubuntu16.04
Subscribe by Email
Follow Updates Articles from This Blog via Email

No Comments