VPS侦探论坛

 找回密码
 注册
查看: 5973|回复: 5

lnmp1.3, nginx 多端口配置不成功

[复制链接]
发表于 2017-4-6 23:06:45 | 显示全部楼层 |阅读模式

VMware 安装 lnmp1.3,想配置多个端口,对应多个项目,总是进入nginx 欢迎页面。
nginx.conf 没有改变
vhost其中一个配置如下,如果是PHP文件就会报404,HTML文件就没问题。

server
    {
        listen 81;
        #listen [::]:80;
        server_name 192.168.1.107:81;
        index index.html index.htm index.php default.html default.htm default.php
        root /data/web/htdocs/php7.com/;

        location / {
            root /data/web/htdocs/php7.com/;
            index index.html index.htm index.php default.html default.htm default.php;
        }
        
        #include thinkphp.conf;
        #error_page   404   /404.html;
        include enable-php.conf;
               
        location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires 30d;
        }
        
        location ~ .*.(js|css)?$
        {
            expires   12h;
        }
        
        location ~ /.
        {
            deny all;
        }
        
        access_log /home/wwwlogs/access.log;
        error_log /home/wwwlogs/error.log;
        
    }
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2017-4-7 14:18:51 | 显示全部楼层


错误太多自己参考这个吧
  1. server
  2.     {
  3.         listen 81;
  4.         index index.html index.htm index.php;
  5.         root  /home/wwwroot/a;

  6.         #error_page   404   /404.html;

  7.         # Deny access to PHP files in specific directory
  8.         #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

  9.         include enable-php.conf;

  10.         location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  11.         {
  12.             expires      30d;
  13.         }

  14.         location ~ .*\.(js|css)?$
  15.         {
  16.             expires      12h;
  17.         }

  18.         location ~ /\.
  19.         {
  20.             deny all;
  21.         }

  22.         access_log  /home/wwwlogs/access.log;
  23.     }
复制代码

如果另外要用 http://域名:端口  这样的形势访问的话,在 listen 81; 下面添加一行 server_name abc.com; 保存,重启nginx生效
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2017-4-7 22:23:06 | 显示全部楼层

回复 2# 的帖子


按军哥的配置,成功了,谢谢军哥了
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2020-4-1 16:56:53 | 显示全部楼层



tangchang 发表于 2017-4-7 22:23
按军哥的配置,成功了,谢谢军哥了

你怎么配好的?为什么按照“域名:81/目录名”显示404?
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2020-4-1 19:19:56 | 显示全部楼层

mzlt 发表于 2020-4-1 16:56
你怎么配好的?为什么按照“域名:81/目录名”显示404?

不清楚你配置文件、目录结构,你也没按反馈必读要求提供信息无法确定什么原因

军哥运维代购:http://shop63846532.taobao.com/

发表于 2020-4-2 09:37:06 | 显示全部楼层

licess 发表于 2020-4-1 19:19
不清楚你配置文件、目录结构,你也没按反馈必读要求提供信息无法确定什么原因 ...

搞定了,路径配错了。管理员好敬业呀,谢谢!有问题再找你~
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-5-2 07:13 , Processed in 0.028077 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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