ubuntu下安装nginxphp各种问题

一 。

创新互联建站专业为企业提供浮梁网站建设、浮梁做网站、浮梁网站设计、浮梁网站制作等企业网站建设、网页设计与制作、浮梁企业网站模板建站服务,十年浮梁做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

sudo apt-get install nginx

安装之后的文件结构大致为:

所有的配置文件都在/etc/nginx下,并且每个虚拟主机已经安排在了/etc/nginx/sites-available下 日志放在了/var/log/nginx下 并已经在/etc/init.d/下创建了启动脚本nginx 默认的虚拟主机的目录设置在了/var/www/nginx-default

启动nginx sudo service nginx start 或 sudo /etc/init.d/nginx start 访问即可看到nginx欢迎界面

2.安装php sudo apt-get install php5 php5-cgi

3.安装fastcgi sudo apt-get install spawn-fcgi

4.配置nginx 修改nginx的配置文件:/etc/nginx/sites-available/default

修改主机名: server_name localhost;

修改index的一行为: index index.php index.html index.htm;

去掉下面部分的注释用于支持php脚本: location ~ /.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/nginx-default$fastcgi_script_name; #fastcgi_param设置参数 include /etc/nginx/fastcgi_params; }

重启nginx sudo service nginx restart

5.用spawn-fcgi启动php5-cgi spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php5-cgi

6.测试 在/var/www/nginx-default下新建一个index.php文件

<?php echo phpinfo(); ?>

访问 http://localhost 即可测试成功

二 。 一,安装Nginx

apt-get install nginx

1,配置nginx

nginx所有的配置在 /etc/nginx/nginx.conf中

nginx.conf配置里面包括了

include /etc/nginx/conf.d/*.conf;

 include /etc/nginx/sites-enabled/*; 这两个配置,所以这里面的配置也是有效的。 错误日志 error_log /var/log/nginx/error.log;

这里我们把配置写在 /etc/nginx/sites-available/default中   修改 root /usr/share/nginx/html; 这是网页的根目录,默认里面有一个index.html页面 index index.html index.htm修改成index index.php index.html index.htm; 增加

location ~ .php$ {    try_files $uri =404;    fastcgi_pass 127.0.0.1:9000;    fastcgi_index index.php;    include fastcgi_params;    }

2,保存文件,使配置生效 /etc/init.d/nginx reload

3,启动nginx     /etc/init.d/nginx start

4,在 /usr/share/nginx/html下新建index.php     <? php     phpinfo();     ?> 二 安装php sudo apt-get install php5-fpm sudo apt-get install php5-gd # Popular image manipulation library; used extensively by Wordpress and it\'s plugins. sudo apt-get install php5-cli # Makes the php5 command available to the terminal for php5 scripting sudo apt-get install php5-curl # Allows curl (file downloading tool) to be called from PHP5 sudo apt-get install php5-mcrypt # Provides encryption algorithms to PHP scripts sudo apt-get install php5-mysql # Allows PHP5 scripts to talk to a MySQL Database sudo apt-get install php5-readline # Allows PHP5 scripts to use the readline function

查看php5运行进程 ps -waux | grep php5

打开关闭php5进程

sudo service php5-fpm stop sudo service php5-fpm start sudo service php5-fpm restart sudo service php5-fpm status

配置php5监听端口 /etc/php5/fpm/pool.d/www.conf

把 listen = /var/run/php5-fpm.sock 改为 listen = 127.0.0.1:9000

重新运行php进程

在浏览器中输入 localhost就可以看到了

三 。 牛人配置

location ~ .php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+.php)(/.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; }

本文题目:ubuntu下安装nginxphp各种问题
文章起源:https://www.cdcxhl.com/article10/cppjdo.html

成都网站建设公司_创新互联,为您提供手机网站建设用户体验网站设计营销型网站建设App开发品牌网站建设

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

绵阳服务器托管