nginx下配置域名

来源:互联网 发布:淘宝转化率如何计算 编辑:程序博客网 时间:2024/05/02 05:03

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
0 0
原创粉丝点击