Today, let’s talk about how to install LNMP under Ubuntu16
PHP7.2
, MySQL5.7
, Nginx1.13
, it seems that these three are the latest ones at present, haha, don’t talk nonsense, start the original link : CODECASTS
sudo apt update
sudo apt upgrade
sudo apt-get install nginx
sudo apt-get install mysql-server mysql-client
There will be a pop-up input during the process, and it should be fine after the password is confirmed
sudo apt-get update
sudo apt-get install -y language-pack-en-base
locale-gen en_US.UTF-8
sudo apt-get install software-properties-common
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get-y install php7.2
sudo apt-get-y install php7.2-mysql
sudo apt-get install php7.2-fpm
apt-get install php7.2-curl php7.2-xml php7.2-json php7.2-gd php7.2-mbstring
sudo vim /etc/php/7.2/fpm/php.ini
Find cgi.fix_pathinfo,change into:
cgi.fix_pathinfo=0 Uncomment
Configure php-fpm
sudo vim /etc/php/7.2/fpm/pool.d/www.conf
Modify listen
listen =/var/run/php/7.2-fpm.sock
Restart PHP
sudo service php7.2-fpm restart
Next, configure Nginx to support PHP Open the nginx configuration file
sudo vim /etc/nginx/sites-available/default
Modify file
sudo vim /etc/nginx/sites-available/default
location /{
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri//index.php?$query_string;}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/7.2-fpm.sock;~~#Note that this is a pit plus php~~
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;}
Mainly the above two modules, as for the root servername, configure yourself according to the situation
To save, you can use nginx -t to check for errors. If you see ok and success, it means it is correct
Then restart nginx in two ways
1. sudo service nginx restart
2. sudo systemctl reload nginx
So far, LNMP has been installed successfully, but the Nginx version is 1.10. This is uncomfortable, since PHP is 7.2, MySQL 5.7 is the latest version, how can Nginx be out? In that case, update nginx
There are two ways to update nginx
1. Source installation, but it's too much trouble, so I don't need it here 2. Upgrade method: Add a nginx.list file under /etc/apt/sources.list.d/, The content is as follows:
deb http://nginx.org/packages/mainline/ubuntu/ xenial nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ xenial nginx
Add nginx key and update apt
curl http://nginx.org/keys/nginx_signing.key | sudo apt-key add
sudo apt update
It should be noted that the nginx series modules that come with Ubuntu will interfere with the installation of nginx, so first back up the configuration file, delete the default module of ubuntu, and then reinstall nginx
sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
sudo apt remove nginx nginx-common nginx-full nginx-core
sudo apt install nginx
sudo rm /etc/nginx/nginx.conf
sudo cp /etc/nginx/nginx.conf.bak /etc/nginx/nginx.conf
Another point is that nginx is masked at this time...remove and restart it:
sudo systemctl unmask nginx
sudo systemctl start nginx
After the test is correct, plus restart and start
sudo systemctl enable nginx
The method to update nginx is of course I got it on Baidu, the address is given below Kouga's blog.
ok,At this point, the installation is complete, and you are welcome to correct any deficiencies.
Recommended Posts