VPS侦探论坛

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

求助军哥,一台服务器上如何设置一个IP+不同端口号来访问多个站点啊

[复制链接]
发表于 2015-9-24 12:13:26 | 显示全部楼层 |阅读模式

求助军哥,我的服务器在内网上,没用域名,只有一个IP,想在这个服务器上部署3个不同的站点,通过不同的端口号访问,如何设置啊。感谢!例如:10.21.96.113     10.21.96.113:8080     10.21.96.113:8000    三个ip和端口号来访问3个站点
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2015-9-24 12:18:59 | 显示全部楼层


监听 不同的端口 应该可以实现不同端口 不同站点
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2015-9-24 12:26:03 | 显示全部楼层

如何设置啊


我编辑nginx.conf配置文件在server下的linsten 80 ...改了监听端口啊,主机地址也改了,

server  {

listen  80

主机地址1


}
server  {

listen  8080

主机地址2

}
这样不行啊
访问不了
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2015-9-24 13:20:35 | 显示全部楼层



  1. server
  2.     {
  3.         listen 8080;
  4.         index index.html index.htm index.php;
  5.         root  /home/wwwroot/8080;

  6.         #error_page   404   /404.html;
  7.         include enable-php.conf;

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

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

  16.         location ~ /\.
  17.         {
  18.             deny all;
  19.         }

  20.         access_log  off;
  21.     }
复制代码

改端口和目录就行了
重启nginx生效
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2015-9-24 15:39:39 | 显示全部楼层

哦,谢谢军哥,是不是我把配置文件改成
  1. server
  2.     {
  3.         listen 80;
  4.         index index.html index.htm index.php;
  5.         root  /home/wwwroot/80;

  6.         #error_page   404   /404.html;
  7.         include enable-php.conf;

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

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

  16.         location ~ /\.
  17.         {
  18.             deny all;
  19.         }

  20.         access_log  off;
  21.     }
  22. server
  23.     {
  24.         listen 8080;
  25.         index index.html index.htm index.php;
  26.         root  /home/wwwroot/8080;

  27.         #error_page   404   /404.html;
  28.         include enable-php.conf;

  29.         location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  30.         {
  31.             expires      30d;
  32.         }

  33.         location ~ .*\.(js|css)?$
  34.         {
  35.             expires      12h;
  36.         }

  37.         location ~ /\.
  38.         {
  39.             deny all;
  40.         }

  41.         access_log  off;
  42.     }
复制代码



就OK了?访问就直接IP:80或IP:8080就好了?

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

发表于 2015-9-24 20:12:29 | 显示全部楼层

回复 5# 的帖子


嗯  就是这个意思
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-28 07:19 , Processed in 0.026902 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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