奥飞火千万电 发表于 2017-12-23 13:44:07

nginx 虚拟主机基于端口的搭建

  首先配置nginx.conf
# cat nginx.conf
  worker_processes1;
  user nginx nginx;
  error_log /app/log/nginx.error.log;
  events {
  use epoll;
  worker_connections1024;
  }
  http {
  include       mime.types;
  default_typeapplication/octet-stream;
  sendfile      on;
  keepalive_timeout65;
  include extra/nginx.vhosts.conf; #包含文件
  log_formatmain'$remote_addr - $remote_user [$time_local] "$request" ';
  error_page   500 502 503 504/50x.html;
  }
  vim /workspace/nginx/conf/extra/nginx.host.conf
  #只写server
  server {
  listen       80;
  server_name localhost;
  location / {
  index index.jsp index.htm index.html;
  root /data0/www/www;
  access_log /app/log/www.access.log;
  }
  error_page   500 502 503 504/50x.html;
  location = /50x.html {
  root   html;
  }
  }
  ###
  server {
  listen       100;
  server_namelocalhost;
  location / {
  index index.jsp index.htm index.html;
  root /data0/www/bbs;
  access_log /app/log/www.access.log;
  }
  }
  ###
  server {
  listen       200;
  server_namelocalhost;
  location / {
  index index.jsp index.htm index.html;
  root /data0/www/blog;
  access_log /app/log/www.access.log;
  }
  }
页: [1]
查看完整版本: nginx 虚拟主机基于端口的搭建