zoukankan      html  css  js  c++  java
  • Ubuntu 安装配置 nginx

    作者:任明旭
    链接:https://www.zhihu.com/question/46241604/answer/100788789
    来源:知乎
    著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

    第一句当然是先安装:
    sudo apt-get install nginx php7.0-fpm mysql-server-5.6 php7.0-mysql
    然后改配置文件,php的配置文件不用改就能用,nginx的配置文件不行,默认情况下是不支持php CGI的,所以得改一下:
    vim /etc/nginx/sites-available/default
    找到
    #
    #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;
    #}
    改成
    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/php/php7.0-fpm.sock;
    }
    大概意思就是所有以 .php 积极结尾的文件都传给php7.0-fpm去处理,处理完了把结果发给nginx,然后再由nginx发给客户机
    然后重启一下服务:
    systemctl restart nginx
    systemctl restart php7.0-fpm
    systemctl restart mysql
    就好啦默认的网站根目录在/var/www/html/(可以通过nginx的配置文件里root 的那行改)
    题主要是想搭wordpress之类的话,要把index.php当做主页的
    就是把nginx配置文件中的
    index index.html index.htm index.nginx-debian.html;
    改成 index.php

  • 相关阅读:
    shell练习题4
    shell练习题3
    shell练习题2
    shell练习题1
    Docker入门
    自动化运维之ansible
    自动化运维之Saltstack
    代码管理平台
    非关系统型数据库-mangodb
    2018-08-22 第三十五课
  • 原文地址:https://www.cnblogs.com/mouseleo/p/8763598.html
Copyright © 2011-2022 走看看