System Environment:
Ubuntu 16.04.2 LTS
nginx version:nginx/1.10.3 (Ubuntu)
PHP 7.0.22-0ubuntu0.16.04.1
MySQL Ver 14.14 Distrib 5.7.20
first, the environment preparation:
Detecting network environments
PING-C2 baidu.com
Update apt Source
sudo apt update
Second, install Nginx
1. Installing Nginx
sudo apt-get install nginx-y
2. Edit the configuration nginx file
sudo vim/etc/nginx/sites-available/default
#index行添加index. php
Index index.php index.html index.htm index.nginx-debian.html;
Location ~ \.php$ {
Include snippets/fastcgi-php.conf;
# with php7.0-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# with PHP7.0-FPM:
Fastcgi_pass Unix:/run/php/php7.0-fpm.sock;
}
third, installation php7.0
1. Install PHP php-fpm
$sudo apt-get Install php7.0 php7.0-fpm-y
2. Edit the configuration file php.ini, locate cgi.fix_pathinfo=0, and change the value to 1
$sudo Vim/etc/php/7.0/fpm/php.ini
760 cgi.fix_pathinfo=0
3. Restart the service
$sudo systemctl Restart Nginx php7.0-fpm
iv. installation of MySQL
$sudo apt Install mysql-server mysql-client libmysqld-dev-y
Follow the prompts to enter the root user password
$sudo Apt install-y php7.0-mysql
v. Verification
$echo "<?php phpinfo ();? > ">/var/www/html/index.php
Browser Access http://localhost
ubuntu16.04 Installing LNMP (ubuntu+nginx+mysql+php7.0)