First, install dependencies
yum install gcc gcc-c++ pcre-devel patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel openssl-devel –y
Second, download and install nginx
1 download nginx source package
wget -c https://nginx.org/download/nginx-1.10.3.tar.gz
2 Create a user nginx
useradd nginx -s /sbin/nologin -M
3 decompression
tar -zxvf nginx-1.10.3.tar.gz
4 into the directory
cd nginx-1.10.3
5 generates compiled files
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx-1.10.3/ --with-http_stub_status_module --with-http_ssl_module --with-stream
6 Compile
make
7 Installation
make install
After the successful implementation we can look at whether there is nginx under / usr / local directory
ll /usr/local/
8 make soft links
ln -s /usr/local/nginx-1.10.3 /usr/local/nginx
9 into the program directory nginx
cd /usr/local/nginx-1.10.3
Check the directory structure: ll
10 to simplify the configuration file nginx
cd /usr/local/nginx/conf
grep -Ev "#|^$" /usr/local/nginx/conf/nginx.conf.default > /usr/local/nginx/conf/nginx.conf
监测语法
/usr/local/nginx/sbin/nginx -t
11 启动nginx
cd /usr/local/nginx/sbin
./nginx
监测端口
netstat -lntup|grep 80
监测进程
ps -ef|grep nginx
12 访问nginx
注:若想使用外部主机连接上虚拟机访问10.0.0.200,需要关闭虚拟机的防火墙:
systemctl stop firewalld.service
13 nginx关闭与重启
./nginx -s stop 关闭
./nginx -s reload 重启