安裝make
yum -y install gcc automake autoconf libtool make
安裝g++
yum install gcc gcc-c++
在 /usr/local/src 目錄下安裝PCRE庫、zlib庫和openssl
#安裝PCRE庫
cd /usr/local/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
tar -zxvf pcre-8.37.tar.gz
cd pcre-8.34
./configure
make
make install
#安裝zlib庫
cd /usr/local/src
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
make install
#安裝openssl
cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz
tar -zxvf openssl-1.0.1t.tar.gz
======================================
安裝nginx
#安裝nginx
cd /usr/local
wget http://nginx.org/download/nginx-1.14.1.tar.gz
tar -zxvf nginx-1.14.1.tar.gz
cd nginx-1.14.1
./configure
make
make install
配置環境變量
#配置環境變量
vim /etc/profile
添加環境變量,我是添加在設置jdk環境變量的上面
#set nginx environment
export NGINX_HOME=/usr/local/nginx
export PATH=$PATH:$NGINX_HOME/sbin
重新編譯 /etc/profile 文件
#重新編譯
source /etc/profile
已經將nginx配置到了環境變量中,在任何目錄都可以操作nginx。
#測試配置文件是否正確
[root@izbp188p52tbilo2rsi9vnz nginx]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
#啓動nginx
nginx
#重啓nginx
nginx -s reload
#關閉ngixn
nginx -s stop
再填一坑:
由於使用的阿里雲服務器,nginx默認使用了80端口,但是阿里雲服務器並沒有開80端口的安全組規則,所以使禁止訪問80端口,這裏需要進入阿里雲網站管理控制檯添加80端口的安全組規則。