1. Install MySQL
sudo
apt
install
mysql-server
The installation process will prompt for the password
2. Installing Nginx and PHP
#添加nginx和php的ppa源
sudo
apt-add-repository ppa:nginx
/stable
sudo
apt-add-repository ppa:ondrej
/php
sudo
apt update
sudo
apt
install
nginx
Install Nginx, open Browser input http://localhost see Welcome to nginx! Indicates that the installation was successful.
The same is true for installing PHP 7.0 and installing other versions.
3. Installing the PHPFASTCGI Manager
sudo
apt
install
php7.0-fpm
4. Modify the configuration file
sudo
vim
/etc/php/7
.0
/fpm/pool
.d
/www
.conf
#nginx 和fastcgi通信有2种方式,一种是TCP方式,还有种是UNIX Socket方式
#默认是socket方式
listen =
/run/php/php7
.0-fpm.sock
#TCP方式 #listen = 127.0.0.1:9000
#可以用如下方式检查下配置文件是否有错误
sudo
php-fpm7.0 -t
#修改重启下 php-fpm7.0
sudo
service php-fpm7.0 restart (
/ETC/INIT.D/PHP7.0-FPM restart)
#修改nginx配置文件
sudo
vim(或vi)
/etc/nginx/sites-enabled/default
#如果你的vi修改时, the keyboard does not operate properly $sudo Apt-get remove Vim-common ($sudo apt-get install vim)
root
/var/www
;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
#找到 location ~ \.php$ { 修改里面
#socket 方式 必须和上面socket的listen路径一样
fastcgi_pass unix:
/run/php/php7
.0-fpm.sock;
Because according to the original blogger's configuration, my restart will be an error, this is the final look I modified:
#TCP方式 #fastcgi_pass 127.0.0.1:9000;
#不管用那种方式,通信方式一定要对应。
#修改重启下 nginx
sudo
service nginx restart
#nginx 检查配置文件命令是
sudo
nginx -t
To this configuration file basic OK, we in the/var/www directory, new index.php test under a look
See this figure illustrates that the configuration has been nearly successful, the following also need to install some common extension libraries
sudo
apt
install
php-mysql php-curl php-mcrypt php-gd php-memcached php-redis
#此方式安装会同时在多个版本下面分别安装
#还有一些库
sudo
apt
install
php7.0
#按tab 可以显示如下一些库
php7.0 php7.0-fpm php7.0-mysql php7.0-sqlite3
php7.0-bcmath php7.0-gd php7.0-odbc php7.0-sybase
php7.0-bz2 php7.0-gmp php7.0-opcache php7.0-tidy
php7.0-cgi php7.0-imap php7.0-pgsql php7.0-xml
php7.0-cli php7.0-interbase php7.0-phpdbg php7.0-xmlrpc
php7.0-common php7.0-intl php7.0-pspell php7.0-xsl
php7.0-curl php7.0-json php7.0-readline php7.0-zip
php7.0-dba php7.0-ldap php7.0-recode
php7.0-dev php7.0-mbstring php7.0-snmp
php7.0-enchant php7.0-mcrypt php7.0-soap
#这个php ppa的源提供了几个版本的php 5.5 5.6 7.0 7.1 也就是说我们可以安装多个版本共存,这个有兴趣的同学可以折腾折腾,反正是开发环境。。。。
According to the problem of the installation process, there are some things in the original text,
Original: http://www.cnblogs.com/ddling/p/5906109.html
Ubuntu 16.04LTS LNMP Environment Configuration--turn (with modification)