LNMP installation under Ubuntu

LNMP installation under Ubuntu#

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

Update Ubuntu source##

sudo apt update
sudo apt upgrade

Install Nginx

sudo apt-get install nginx

Install MySQL5.7

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

Install PHP7.2

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

Configure PHP settings

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

LNMP installation under Ubuntu
Installation of deb package under Ubuntu
Redis installation under ubuntu and windows
Ubuntu 16.04 installation graphic tutorial under VMware 12
Installation of Docker CE under Ubuntu
UBUNTU 16.04 installation diary
ubuntu 1804 installation details
Ubuntu system installation
Ubuntu installation record
ubuntu 18.04 installation (UEFI+GBT)
ubuntu installation error
Ubuntu16.04 mirror complete installation tutorial under VMware
Installation and uninstallation of CUDA under Ubuntu 16.04
DLNA/UPnP Server installation and configuration under Ubuntu 12.04
Manual for Ubuntu Installation
Install apache+PHP under Ubuntu
Install node.js under Ubuntu
Install python3.6 under Ubuntu 16.04
Ubuntu16.04 installation partition settings
ubuntu redis php installation
Install mysql under Ubuntu 16.04
Install Thrift under ubuntu 14.10
Install OpenJDK10 under Ubuntu
Install Caffe under Ubuntu 14.04
Python MySQLd under Ubuntu
Installation of pulseaudio and API usage under Ubuntu 12.04
Start working under ubuntu
Ubuntu introduction and installation
[python] python2 and python3 under ubuntu
Use iptables under ubuntu
ubuntu nice font installation
Network configuration under Ubuntu
Problems encountered in pip tool installation under Ubuntu
Redis3 installation under Centos7
Install ROS under ROS Ubuntu 18.04[2]
Ubuntu CEPH quick installation
Kaldi installation and configuration graphic tutorials under Ubuntu
foreman ubuntu16 quick installation
Install MySQL under Ubuntu
Install Yarm-PM2 under Ubuntu
Ubuntu 17.10 installation toss record
Ubuntu dual system installation
Ubuntu16.04 mirror complete installation and configuration tutorial under VMware
Install nvidia graphics driver under Ubuntu (easy installation method)
Installation and use of GDAL in Python under Ubuntu
Installation and usage instructions of rz/sz command under ubuntu
Github Project-OpenPose installation on Ubuntu
Django&MySQL environment deployment under Ubuntu 14.04
Deploy FTP server under ubuntu
Redis cluster installation under CentOS
Solve Unment dependencies under ubuntu
ubuntu view python installation path
Open SSH service under Ubuntu
Ubuntu16.04 installation and simple configuration
Detailed ubuntu 20.04 LTS installation record
Modify shortcut keys under Ubuntu 18.04
Redis cluster installation under CentOS
Use of mediawiki under ubuntu
Install server-side Shadowsocks under Ubuntu 16.04
Open SSH service under Ubuntu
CSI Tools installation Intel 5300 + Ubuntu 14.04