centos7 安装nginx 做反向代理记录

1、完整干净的vps centos7
新开的centos7 vps,先update一下

yum update

2、安装最新版的nginx 1.18.0
先安装wget

yum install wget
wget http://nginx.org/download/nginx-1.18.0.tar.gz

解压缩下载下来的nginx

tar -zvxf nginx-1.18.0.tar.gz

进入nginx目录

cd nginx-1.18.0

nginx有很多编译配置项,我使用了默认的配置:

./configure --with-http_ssl_module --with-http_gzip_static_module

在这里插入图片描述
。。。
在这里插入图片描述
nginx path prefix: “/usr/local/nginx”
nginx binary file: “/usr/local/nginx/sbin/nginx”
nginx modules path: “/usr/local/nginx/modules”
nginx configuration prefix: “/usr/local/nginx/conf”
nginx configuration file: “/usr/local/nginx/conf/nginx.conf”
nginx pid file: “/usr/local/nginx/logs/nginx.pid”
nginx error log file: “/usr/local/nginx/logs/error.log”
nginx http access log file: “/usr/local/nginx/logs/access.log”
nginx http client request body temporary files: “client_body_temp”
nginx http proxy temporary files: “proxy_temp”
nginx http fastcgi temporary files: “fastcgi_temp”
nginx http uwsgi temporary files: “uwsgi_temp”
nginx http scgi temporary files: “scgi_temp”
上面是nginx各类文件的名称及路径。
上图可以看见,有好多文件在编译过程中出现(…not found),是因为缺少依赖的问题,最常用的依赖
gcc zlib ssl等

yum install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
make
make install

3、启动nginx:
启动nginx:

cd /usr/local/nginx/sbin/
./nginx

如果运行的时候不带-c参数,那就采用默认的配置文件,即/etc/nginx/nginx.conf

查看运行进程状态:

ps aux | grep nginx

打开浏览器,访问http://localhost/看看nginx的默认页面:

停止nginx:

./nginx -s stop

重启nginx(配置文件变动后需要重启才能生效):

./nginx -s reload

检查配置文件是否正确:

./nginx -t

查看nginx的pid:

cat /usr/local/nginx/logs/nginx.pid

查看nginx版本

 ./nginx -v

回头看编译配置

./nginx -V
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值