下載nginx 並創建用戶和組 安裝所需要的組件
[root@localhost ~]# wget http://nginx.org/download/nginx-1.6.2.tar.gz 穩定版
[root@localhost ~]# yum install pcre-devel -y 依賴perl擴展的正則表達式
[root@localhost ~]# groupadd -r -g 110 nginx 添加以個nginx組爲系統組
[root@localhost ~]# useradd -r -u 110 -g 110 nginx 添加以個用戶爲系統用戶 專門管理nginx
[root@localhost ~]# yum -y install cmake gcc gcc-c++ autoconf automake zlib* libxml* \
ncurses ncurses-devel libtool-ltdl-devel* make bison bison-devel libaio
[root@localhost ~]# tar xf nginx-1.6.2.tar.gz
[root@localhost ~]# cd nginx-1.6.2
[root@localhost nginx-1.6.2]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
[root@localhost nginx-1.6.2]#yum install openssl-devel gd-devel gd --庫是圖片過濾處理模塊
開始編譯:
第一種 : ./configure --prefix=/usr/local/nginx
第二種 :
.
/configure
\
--prefix=
/usr
\
--sbin-path=
/usr/sbin/nginx
\
--conf-path=
/etc/nginx/nginx
.conf \
--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 \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=
/var/tmp/nginx/client/
\
--http-proxy-temp-path=
/var/tmp/nginx/proxy/
\
--http-fastcgi-temp-path=
/var/tmp/nginx/fcgi/
\
--http-uwsgi-temp-path=
/var/tmp/nginx/uwsgi
\
--http-scgi-temp-path=
/var/tmp/nginx/scgi
\
--with-pcre \
--with-
file
-aio \
--with-http_image_filter_module
make
&&
make
install
[root@localhost nginx-1.6.2]#nginx
檢查是否啓動成功
[root@localhost ~]# ps -ef |grep nginx
root 1086 1 0 18:12 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 1088 1086 0 18:12 ? 00:00:00 nginx: worker process
root 1142 1124 0 18:21 pts/0 00:00:00 grep nginx
[root@localhost ~]# service iptables stop #關閉防火牆
[root@localhost ~]# service iptables status #查看防火牆狀態
iptables: Firewall is not running.
[root@localhost ~]#
最後測試是否成功 IE輸入http://ip
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
網站的目錄
.
/configure
\
--prefix=
/usr
\----------------網站的目錄
--sbin-path=
/usr/sbin/nginx
\
--conf-path=
/etc/nginx/nginx
.conf \
--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 \
--user=nginx \
根據安裝顯示 我們的安裝目錄在/usr
下面我看看。
[root@localhost ~]# ls /usr
bin etc games html include lib lib64 libexec local sbin share src tmp
其中
html 默認站點的主目錄
sbin 存放nginx的程序