1. 程式人生 > >Linux CentOS6.5安裝Nginx1.8.0

Linux CentOS6.5安裝Nginx1.8.0

命令 ref 存在 stc grep 目錄 linu 註意 依賴

一. 安裝nginx

1. 準備1.8.0安裝包

nginx-1.8.0.tar.gz

2. 安裝第三方依賴

yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel

3. 解壓安裝包並進入nginx目錄

tar zxf nginx-1.8.0.tar.gz 
cd nginx-1.8.0

4. 使用configure命令在nginx目錄中創建makeFile文件

./configure --prefix=/usr/local/nginx 
--pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --http-client-body-temp-path=/var/temp/nginx/client --http-proxy-temp-path=/var/temp/nginx/proxy --http-fastcgi-temp-path=/var/temp/nginx/fastcgi
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi --http-scgi-temp-path=/var/temp/nginx/scgi

5. 在/var下創建temp及nginx目錄

註意:第4步將臨時文件目錄指定為/var/temp/nginx,所以在啟動nginx之前,需要在/var下創建temp及nginx目錄

mkdir /var/temp/nginx/client -p

6. 編譯nginx源文件, 在nginx目錄下執行make命令

make

7. 運行編譯後的文件

make install

8. 查看已安裝的nginx

註意: 安裝好的nginx在/usr/local/下

cd /usr/local/
ll

二. 啟動nginx

1. 進入nginx的sbin目錄後啟動

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

2. 查看是否啟動

註意: 存在master和worker進程說明啟動成功

ps wux|grep nginx

3. 通過瀏覽器訪問nginx

註意: 默認端口80, 這裏的ip地址是虛擬機上linux的ip地址

http://192.168.18.107/

三. 關閉nginx

cd /usr/local/nginx/sbin
./nginx -s quit

四. 重啟nginx

註意: 可以用於刷新配置文件, 先關閉後啟動

cd /usr/local/nginx/sbin
./nginx -s reload

Linux CentOS6.5安裝Nginx1.8.0