1. 程式人生 > >nginx-0基礎安裝篇

nginx-0基礎安裝篇

 

 

Nginx安裝手冊

一:獲取nginx安裝包

1.1,下載nginx安裝包:

可以在nginx官網自行下載安裝nginx所需的安裝包

1.2,也可以通過我提供的分享連結進行下載,連結如下:

https://pan.baidu.com/s/1gDVZun7vDxI8Ep1oRu2SgA

二:安裝nginx

       2,1,將下載好的軟體包上傳到系統

              我們這邊是使用xshell工具進行遠端連線centos7的伺服器,使用其自帶的xsftp把檔案傳上去,開啟方式如 圖(1)所示,上傳步驟如 圖(2)所示。

                  圖(1)

 

                  圖(2)

2,2、安裝nginx所需要的依賴包

       進入系統,安裝nginx所需要的依賴包檔案命令如圖(3)所示,我們這裡使用yum安裝即可,

 

                圖(3)

 

      附上可複製的具體命令:

yum -y install openssl openssl-devel pcre pcre-devel gcc
-c++ autoconf automake zlib-devel libxml2 libxml2-dev libxslt-devel gd-devel perl-devel perl-ExtUtils-Embed GeoIP GeoIP-devel GeoIP-data

依賴安裝完成之後會出現Complete! 如圖(4) 所示:

                圖(4)

2.3、安裝nginx

       建立nginx所使用的使用者:

[[email protected] ~]# useradd nginx
[
[email protected]
~]# id nginx uid=1000(nginx) gid=1000(nginx) groups=1000(nginx)

  進入系統使用 ls 命令檢視檔案包是否存在,在使用tar 命令將nginx檔案包進行解壓,解壓完成之後進入 nginx-1.8.1 這個目錄,通過 ls 命令檢視一下存在一個configure (綠色檔案)的可執行檔案 圖(5),使用這個檔案進行初始化,configure後面需要指定一些初始化的引數,初始化完成之後會出現 圖(6)的樣子,在使用命令 make && make install 進行編譯安裝,編譯成功之後如 圖(7) 所示,以上具體操作請參考如下步驟詳細:

[[email protected] ~]# ls
anaconda-ks.cfg  nginx-1.8.1.tar.gz
[[email protected] ~]# tar -xf nginx-1.8.1.tar.gz 
[[email protected] ~]# ls
anaconda-ks.cfg  nginx-1.8.1  nginx-1.8.1.tar.gz
[[email protected] ~]# cd nginx-1.8.1
[[email protected] nginx-1.8.1]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  Makefile  man  objs  README  src
[[email protected] nginx-1.8.1]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx \
--error-log-path=/var/log/nginx_error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--sbin-path=/usr/sbin/nginx \
--with-rtsig_module \
--with-select_module \
--with-poll_module \
--with-file-aio \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_xslt_module \
--with-http_image_filter_module \
--with-http_geoip_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_stub_status_module \
--with-cpp_test_module [[email protected] nginx-1.8.1]# make && make install

                  圖(5)

                圖(6)

                  圖(7)

注意: nginx的安裝目錄在初始化中使用引數 --prefix=/usr/local/nginx 指定了,以後的配置將在/usr/local/nginx 目錄中

[[email protected] nginx-1.8.1]# cd /usr/local/nginx/
[[email protected] nginx]# ls
conf  html
[[email protected] nginx]# 

三:啟動

啟動nginx

/usr/local/nginx/sbin/nginx

停止nginx

/usr/local/nginx/sbin/nginx -s stop

重啟nginx

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