安装编译依赖的包
yum -y install gcc gcc-c++ autoconf automake make yum -y install zlib zlib-devel openssl yum -y install openssl-devel pcre pcre-devel
安装 Nginx
# 下载源码 wget http://Nginx.org/download/Nginx-1.8.0.tar.gz # 解压 tar zxvf Nginx-1.8.0.tar.gz cd Nginx-1.8.0 # 编译安装 ./configure make && make install
运行 configure
后可以看到一大串配置信息:
Nginx path prefix: "/usr/local/Nginx" Nginx binary file: "/usr/local/Nginx/sbin/Nginx" 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
注意上面的配置信息,Nginx 的配置文件在 /usr/local/Nginx/conf/
目录下,此时可以编辑 /usr/local/Nginx/conf/Nginx.conf
文件,修改配置,这个就不多说了。
配置完可以用 Nginx -t
检查配置是否正确。
Nginx -c /usr/local/Nginx/conf/Nginx.conf # 查看 Nginx 进程 ps aux | grep Nginx原文链接:https://www.f2er.com/centos/381070.html