nginx

nginx下配置域名

php网站在nginx.conf文件中添加配置

server {
        listen 80;
        server_name xxx.xx.com;//设置的域名
        root /www/.../;//根目录

        location / {
                try_files $uri  /index.php?$query_string;
                index index.php index.html index.htm;
        }

        location ~ \.php$ {
                fastcgi_pass 127.0.0.1:3000;//3000 php监听的端口号(nginx把接收到的请求,转发到3000端口,让php去解析文件,然后把解析的结果返回给nginx)
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_param PATH_INFO $fastcgi_path_info;    #增加这一句
                include fastcgi_params;
        }

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

静态网站有时候设置上面的配置找不到默认的html文件时,按照下面设置

server {
        listen 80;
        server_name xxx.xx.com;//设置的域名
        root /www/.../;//根目录

        location / {               
                try_files $uri  /index.html;
                index index.php index.html index.htm;
        }       

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

在linux里面上传文件命令(使用SecureCRTPortable)

sudo rz //然后选择文件

如果文件存在 ,则使用下面命令强制覆盖

sudo rz -y

做完之后要reload nginx

sudo nginx -s reload

nginx环境

环境调试确认
1、系统网络
ping www.baidu.com
2、yum可用
3、确认关闭iptables规则
4、确认停用selinux

yum -y intall gcc gcc

初始化目录
cd /opt;mkdir app download logs work backup

主机和虚拟机可以互通,但是浏览器访问不了,nginx重启报错” /var/run/nginx.pid failed”

nginx -s reload 
报错:

nginx: [error] open() "/var/run/nginx.pid" failed (2: No such file or directory)

解决办法:
[root@TEST nginx]# sudo nginx -c /etc/nginx/nginx.conf
[root@TEST nginx]# nginx -s reload

摘自:https://www.cnblogs.com/afei-happy/p/6524074.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

嵌入式小镇做题家

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值