使用nginx虚拟主机配置

在linux虚拟机启动一个web服务器, 开发部署想都通过普通用户. 普通用户没有权限监听80端口.

这里可以使用nginx配置虚拟主机, 把 vm.amosk.info的80端口映射到普通端口8000.

1. 安装nginx服务, 并设置开机启动
2. 添加nginx虚拟主机配置文件 /etc/nginx/conf.d/amos.conf

upstream vm.amosk.info {
  server 127.0.0.1:8000;
}

server {
  listen          80;
  server_name     vm.amosk.info;

  location /media/  {
    alias /home/amos/public/media/;
  }

  location / {
    proxy_pass    http://vm.amosk.info;
  }
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.