宝塔618特惠活动,企业版999元/年,宝塔SSL证书买1送1!限时抢购!查看活动
当前位置:论坛首页 > Linux面板 > 求助

之前环境是nginx+php,现在改用宝塔了,站点的nginx如何配置?

发表在 Linux面板2018-12-28 23:56 [复制链接] 2 3502


以下nginx.conf是之前服务器nginx1.10.2+php7.0.22的配置文件,现在改用宝塔了,请问添加站点后站点的配置文件要如何修改和配置呢?
之前服务器的环境是别人配置的,API打开地址是:http://api.xxxxxx.com/api   现在用宝塔添加站点后,server_name为api.xxxxxx.com,还有下面的红色部分我也添加到了配置文件,可是打开http://api.xxxxxx.com/api会出现404错误 “404,您请求的文件不存在!” ,是不是还需要设置什么地方呢?





# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        server_name  _;
        root         /usr/share/nginx/webapp;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
            index index.php;
            if (!-e $request_filename) {
                rewrite ^/(api)/(.*)$ /api.php?s=/$2 last;
                rewrite ^/(share)/(.*)$ /share.php?s=/$2 last;
                rewrite ^/(.*)$ /index.php?s=/$2 last;
                break;
            }
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        location ~ \.php$ {
            root           webapp;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
}

使用道具 举报 只看该作者 回复
发表于 2018-12-29 15:18:51 | 显示全部楼层
之前有环境的建议重装,因为会出现各种奇怪的问题...
使用道具 举报 回复 支持 反对
发表于 2020-6-10 18:47:48 | 显示全部楼层
没人遇到这个问题么?之前 nginx 配置 php 的网页,直接转给 php 的 9000 端口,就完事儿了,用包套以后,除了 index.php 可以打开,自定义请求路径的,全部都失效了
使用道具 举报 回复 支持 反对
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

普通问题处理

论坛响应时间:72小时

问题处理方式:排队(仅解答)

工作时间:白班:9:00 - 18:00

紧急运维服务

响应时间:3分钟

问题处理方式:宝塔专家1对1服务

工作时间:工作日:9:00 - 18:30

宝塔专业团队为您解决服务器疑难问题

点击联系技术免费分析

工作时间:09:00至18:30

快速回复 返回顶部 返回列表