别管那么多 先装一堆基础依赖(本次用的着的,用不着的以装别的也可能用的着的)
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc gcc-c++ openssl-devel
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum install gcc perl-ExtUtils-MakeMaker
- 官网下载nginx(找当前的稳定版)
- 下载后上传到服务器(scp 就不用写了吧)
- 解压并进入目录:
tar -xzf nginx-1.16.0.tar.gz
cd nginx-1.16.0
- 编译安装:
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --with-pcre --with-file-aio --with-http_realip_module --without-http_scgi_module --without-http_uwsgi_module --without-http_fastcgi_module`
make && make install
- nginx 安装到 /usr/local/nginx
- 安装好以后修改 nginx.conf 文件进行配置。配置修改后使用测试命令
nginx -t
出现以下显示为配置文件修改没有错误,可以重新加载配置
nginx: the configuration file /usr/local/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/nginx.conf test is successful
重新加载配置
nginx -s reload