一 安裝配置nginx
1、下載安裝包nginx1.10.3
1.2---解壓到/usr/local
1.3---進入目錄 執行./configure
# ./configure,
報錯:
出現這個錯誤,是因為gcc包沒有安裝
# yum -y install gcc
# whereis gcc
安裝gcc之后,運行./configure,
報錯:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
安裝pcre-devle 解決問題
# yum -y install pcre-devel
(這里我順便安裝了openssl # yum -y install pcre-devel openssl openssl-devel )
執行 ./configure
如果報錯:
...Require the zlib library
...
則執行安裝
# yum install zlib-devel -y
1.4 -- openssl和sha1
如果你想使用openssl功能 sha1功能 那么需要安裝openssl和sha1
# yum install openssl openssl-devel
開啟ssl模塊 :
# ./configure --with-http_ssl_module
啟用”server_status”頁
# ./configure --with-http_stub_status_module
上述兩條命令同時啟用 可以使用如下命令:
# ./configure --with-http_stub_status_module --with-http_ssl_modile
1.5--##編譯 安裝
上面configure就通過了
執行make 和make install 命令 ##編譯 安裝
# make
# make install
至此,nginx執行成功了。
1.6--配置環境變量
# whereis nginx
nginx:/usr/local/nginx
在/etc/profile 中加入配置
# vim /etc/profile
在配置文件中加入:
#nginx configure
export NGINX_HOME=/usr/local/nginx
export PATH=$PATH:$NGINX_HOME/sbin
編譯完保存退出
# source /etc/profile
使配置生效
整個過程,就安裝成功了
二 修改nginx,conf
2.1 啟動nginx
# cd /usr/local/nginx
# nginx -c conf/nginx.conf
啟動成功后,將在瀏覽器打開 ip加端口號 默認端口號是80
用瀏覽器打開看到帶有welcome to nginx 的頁面