1、下載nginx1.2.4
#注:下載地址:http://nginx.org/download/nginx-1.2.4.tar.gz
wget -c http://nginx.org/download/nginx-1.2.4.tar.gz
2、安裝
#注:默認安裝到/usr/local/nginx
tar -zxvf nginx-1.2.4.tar.gz
cd nginx-1.2.4
./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= option.
#注:安裝pcre-devel解決問題
yum -y install pcre-devel
# ./configure
make? #注:會出來一堆東西
make install
3、運行
/usr/local/nginx/sbin/nginx
#注:nginx默認使用80端口,若是80端口被占用,修改/usr/local/nginx/conf/nginx.conf里的
server {
listen 80;?? #我這邊改為8081
#查看nginx是否正常
[[email?protected] nginx-1.2.4]# /usr/local/nginx/sbin/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
4、測試
echo "test123" > /usr/local/nginx/html/index.html
然后在瀏覽器中輸入ip:8081 可以看到內容test123