Ubuntu 16.04 LTS 安装配置 Nginx 1.10.0 Php7.0-FPM

家住魔仙堡 提交于 2020-02-15 04:33:39

1. 安装Nginx,Php-7.0

~$ sudo add-apt-repository ppa:nginx/stable

~$ sudo apt-get update

~$ sudo apt-get install nginx

~$ nginx -v

nginx version: nginx/1.10.0

~$ sudo apt-get install php

~$ php -v

PHP 7.0.4-7ubuntu2.1 (cli) ( NTS )

Copyright (c) 1997-2016 The PHP Group

Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

2. 配置Nginx的监听端口为8080(Apache2的服务已经安装在我的系统中了,默认的监听端口80被占用)。

~$ sudo vim /etc/nginx/sites-available/default

server {

listen 8080 default_server;

listen [::]:8080 default_server;

3. 配置Nginx和Php7.0-FPM 启用php7.0-FPM服务并在Nginx中生效

~$ sudo vim /etc/nginx/sites-available/default

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;

}

~$ sudo vim /etc/php/7.0/fpm/php-fpm.conf

; The address on which to accept FastCGI requests.

; Valid syntaxes are:

;  'ip.add.re.ss:port'    - to listen on a TCP socket to a specific IPv4 address on

;                            a specific port;

;  '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on

;                            a specific port;

;  'port'                - to listen on a TCP socket to all addresses

;                            (IPv6 and IPv4-mapped) on a specific port;

;  '/path/to/unix/socket' - to listen on a unix socket.

; Note: This value is mandatory.

listen = /run/php/php7.0-fpm.sock

4. 测试

~$ sudo service php7.0-fpm start

~$ sudo service ngnix start

 

访问 127.0.0.1:8080/phpinfo.php 出现phpinfo信息页面则为配置成功!

 

转http://www.jianshu.com/p/95ac61e6f0d0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!