ubuntu安装nginx配置反向代理服务器

4 篇文章 0 订阅

安装nginx:

sudo apt-get install nginx

启动nginx;

sudo service nginx start

如果报了这样的错误:

[alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)2015/01/16 15:55:46
[warn] 1973#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1nginx: the configuration file /etc/nginx/nginx.conf syntax is ok2015/01/16 15:55:46
 [emerg] 1973#0: open() "/var/run/nginx.pid" failed (13: Permission denied)nginx: configuration file /etc/nginx/nginx.conf test failed

出现上面的情况要么就是文件没创建,要么就是没权限。所以:

先用touch和mkdir创建文件和文件夹。然后在用sudo chmod a+rwx -R 文件路径赋予所有用户所有权限(777)。

最后在nginx.conf文件中的http下加入

upstream myproject(内网映射的地址别名){
server     192.168.0.27:80(ip:port);
}
server{
listen 8088;
server_name localhost;
location / {
root html;
index index.html index.htm;
proxy_pass http://myproject(内网映射地址别名);
}
}
好了,现在使用service nginx start命令启动服务器。然后输入http://localhost:8088看看是不是成功了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值