I started with LAMP server, but this was not an ideal choice and especially managing many requests, that happen from time to timeā¦ So I moved onto LEMP that is faster and takes less memory.
LEMP server
Installing main components: php-fpm, mysql, nginx:
- sudo apt update
- sudo apt install php-fpm
- sudo apt install mysql-server
- sudo apt install nginx
Setting up:
Configure main components. MySQL security run (just go through few questions, this will make mysql installation a little more secure)
sudo mysql_secure_installation
Nginx config is here:
/etc/nginx/sites-available/default
include php-fpm to nginx settings:
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
After altering NGINX config, you can test yourself by typing:
sudo nginx -t
This should output something like this (if all is ok):
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Once happy, reload nginx process for changes to take place:
systemctl reload nginx
Open your local IP address in the browser, it should output the NGINX welcome page.
The address should look like this: 192.168.xx.xxx
Let’s test PHP, go to web server root directory. (by default is /var/www)
Create info.php file with content:
echo "<?php phpinfo(); ?>"
When you open this file in the browser (should look like this: 192.168.xx.xxx/info.php)
This outputs php current settings. All done, you got LEMP.
The general benefits of LEMP over LAMP are:
- Handling more clients using less memory (comparing to Apache server)
- Faster (comparing to Apache server)