nginx 入门实战

nginx入门实战

nginx 安装与卸载

下载安装

进入 http://nginx.org/en/download.html
下载自己想要的版本,我选择的stable版本

tar -zxvf nginx.tar.gz
cd nginx
./configure
make
make install # 如果报错 使用 sudo make install

使用

upstream hello.com {
	server 127.0.0.1:8084 weight=1;
	server 127.0.0.1:8084 weight=1;
}
server {
	location / {
		proxy_pass      http://hello.com;
		proxy_redirect  default;
	}
}

接下来访问 http://localhost:8080/hello来测试

遇到的问题

  • nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
    • 解决方案
      • 需要刚开始执行nginx 加载nginx.conf文件
      • sudo ./nginx -c /usr/local/nginx/conf/nginx.conf

参考文章

posted @ 2019-11-20 22:25  Draymonder  阅读(176)  评论(0编辑  收藏  举报