Ubuntu16.04LTS安装配置Nginx1.10.0Php7.0FPM

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信息页面则为配置成功!

 

Ubuntu16.04LTS安装配置Nginx1.10.0Php7.0FPM

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

原文链接:https://www.cnblogs.com/likwo/p/5975774.html
本文来源 爱码网,其版权均为 原网址 所有 与本站无关,文章内容系作者个人观点,不代表 本站 对观点赞同或支持。如需转载,请注明文章来源。

© 版权声明

相关文章