当你的nginx服务器和php服务器不在一起的时候,这个nginx 的root目录问题

简介: 两个服务器的网站代码目录需要对齐,docker容器里面也是一样

server {
listen 80 default_server;
listen [::]:80 default_server;

    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;
    #尽管说不影响后面的php目录但是还是要设置,否则nginx工作不正常
    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.php index.html index.htm index.nginx-debian.html;

    server_name 10.8.125.86;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ =404;
    }

    # pass PHP scripts to FastCGI server

    location ~ \.php$ {
            #include snippets/fastcgi-php.conf;
    #
    #       # With php-fpm (or other unix sockets):
    #       fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    #       # With php-cgi (or other tcp sockets):
            fastcgi_pass 172.17.0.2:9000;
            fastcgi_index index.php;
            #php服务器会根据这个地址来查找网站代码
            fastcgi_param SCRIPT_FILENAME /var/www/html/$fastcgi_script_name;
            include fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #       deny all;
    #}

}

相关文章
|
2月前
|
缓存 负载均衡 JavaScript
Nginx:高性能Web服务器与反向代理利器
Nginx:高性能Web服务器与反向代理利器
223 110
|
2月前
|
缓存 负载均衡 前端开发
Nginx:高性能的Web服务器与反向代理利器
Nginx:高性能的Web服务器与反向代理利器
191 99
|
2月前
|
缓存 负载均衡 前端开发
Nginx:高性能Web服务器的核心引擎
Nginx:高性能Web服务器的核心引擎
100 47
|
10天前
|
Ubuntu 安全 应用服务中间件
详细指南:配置Nginx服务器在Ubuntu平台上
以上步骤涵盖了基本流程:从软件包管理器获取 Ngnix, 设置系统服务, 调整UFW规则, 创建并激活服务器块(也称作虚拟主机), 并进行了初步优化与加固措施。这些操作都是建立在命令行界面上,并假设用户具有必要权限(通常是root用户)来执行这些命令。每个操作都有其特定原因:例如,设置开机启动确保了即使重启后也能自动运行 Ngnix;而编辑server block则定义了如何处理进入特定域名请求等等。
125 18
|
12天前
|
Ubuntu 安全 应用服务中间件
详细指南:配置Nginx服务器在Ubuntu平台上
以上步骤涵盖了基本流程:从软件包管理器获取 Ngnix, 设置系统服务, 调整UFW规则, 创建并激活服务器块(也称作虚拟主机), 并进行了初步优化与加固措施。这些操作都是建立在命令行界面上,并假设用户具有必要权限(通常是root用户)来执行这些命令。每个操作都有其特定原因:例如,设置开机启动确保了即使重启后也能自动运行 Ngnix;而编辑server block则定义了如何处理进入特定域名请求等等。
114 17
|
11月前
|
应用服务中间件 nginx
Nginx里的root和alias的区别是什么?
Nginx里的root和alias的区别是什么?
817 2
|
前端开发 应用服务中间件 nginx
Nginx中root与alias区别
Nginx中root与alias区别
142 0
|
应用服务中间件 nginx
Nginx 配置中root和alias的区别分析
Nginx 配置中root和alias的区别分析
292 0
|
应用服务中间件 nginx
nginx中root和alias的区别
nginx中root和alias的区别
nginx中root和alias的区别
|
应用服务中间件 nginx
Nginx:root与alias的区别
Nginx:root与alias的区别
182 0

热门文章

最新文章