Linux Nginx 1.6.2配置php5

我的设备是树莓派B3,系统版本:Raspbian GNU/Linux 8

为了方便,Nginx直接用现成的

sudo apt-get install nginx
sudo apt-get install php5-fpm php5-sqlite

然后编辑 /etc/nginx/sites-available/default,有一行:

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

根据注释说的,加一个index.php变成:

index index.html index.htm index.nginx-debian.html index.php;

然后继续设置PHP:

     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #   include snippets/fastcgi-php.conf;
    #
    #   # With php5-cgi alone:
    #   fastcgi_pass 127.0.0.1:9000;
    #   # With php5-fpm:
    #   fastcgi_pass unix:/var/run/php5-fpm.sock;
    #}

改为:

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
    #include snippets/fastcgi-php.conf;

    # With php5-cgi alone:
    #fastcgi_pass 127.0.0.1:9000;
    # With php5-fpm:
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

nginx的PHP连接就完成了。

/etc/init.d/php5-fpm restart
/etc/init.d/nginx restart

然后就可以写PHP代码了。

网页路径在/etc/nginx/sites-enabled/default有定义
参考:
ubuntu 12.10 默认安装php5-fpm无监听9000端口,nginx无法链接php5-fpm修正
树莓派开发系列教程7——树莓派做web服务器(nginx、Apache)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值