yum安装lnmp-nginx

yum install nginx

配置文件默认在/etc/nginx/conf.d/default.conf,配置文件中网页根目录在/etc/share/nginx/html

下面是yii文档中推荐的nginx配置:

为了使用 Nginx,你应该已经将 PHP 安装为 FPM SAPI 了。 你可以使用如下 Nginx 配置,将 path/to/basic/web 替换为实际的 basic/web 目录, mysite.local 替换为实际的主机名以提供服务。

server {
    charset utf-8;
    client_max_body_size 128M;

    listen 80; ## listen for ipv4
    #listen [::]:80 default_server ipv6only=on; ## listen for ipv6

    server_name mysite.local;
    root        /path/to/basic/web;
    index       index.php;

    access_log  /path/to/basic/log/access.log;
    error_log   /path/to/basic/log/error.log;

    location / {
        # Redirect everything that isn't a real file to index.php
        try_files $uri $uri/ /index.php$is_args$args;
    }

    # uncomment to avoid processing of calls to non-existing static files by Yii
    #location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
    #    try_files $uri =404;
    #}
    #error_page 404 /404.html;

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass 127.0.0.1:9000;
        #fastcgi_pass unix:/var/run/php5-fpm.sock;
        try_files $uri =404;
    }

    location ~* /\. {
        deny all;
    }
}

修改完成后使用以下命令重启nginx完成修改

 

Centos6 : service nginx restart

Centos7:systemctl restart nginx 

通用:

/etc/init.d/nginx start

/etc/init.d/nginx stop  

/etc/init.d/nginx restart

启动报错:

nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)

解决办法:

vim /etc/nginx/conf.d/default.conf

listen       80 default_server;

listen       [::]:80 default_server;

改为:

listen       80;

#listen       [::]:80 default_server;

重新启动nginx即可


另外 如果出现内部可以访问nginx,在外部无法访问的情况,可能是防火墙的问题,如果防火墙没做限制,那可能就是阿里云的安全组规则里面没有对80端口进行配置



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值