linux下安裝nginx

1.可以使用wget 命令下載或者使用工具上傳

這裏我是使用wget下載

wget http://nginx.org/download/nginx-1.9.9.tar.gz

2.把這個壓縮包使用tar 命令解壓

tar -zxvf nginx-1.9.9.tar.gz 

3.這是我們進入解壓文件夾

cd nginx

4.nginx下面有個文件configure,使用

./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.

這是如果報錯,不要慌張,仔細看錯誤,是讓我們

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.

這裏我們忽略這個功能

./configure --without-http_rewrite_module

如果在報錯就如此操作

我的報了二個 所以我使用

/configure --without-http_rewrite_module --without-http_gzip_module
注意我們可能看到如下錯誤
[root@localhost nginx]# make install

make -f objs/Makefile install

make[1]: Entering directory`/usr/local/nginx'

test -d '/usr/local/nginx' || mkdir -p'/usr/local/nginx'

test -d '/usr/local/nginx/sbin' \

       ||mkdir -p '/usr/local/nginx/sbin'

test ! -f '/usr/local/nginx/sbin/nginx' \

       ||mv '/usr/local/nginx/sbin/nginx' \

              '/usr/local/nginx/sbin/nginx.old'

cp objs/nginx '/usr/local/nginx/sbin/nginx'

test -d '/usr/local/nginx/conf' \

       ||mkdir -p '/usr/local/nginx/conf'

cp conf/koi-win '/usr/local/nginx/conf'

cp: ‘conf/koi-win’ and‘/usr/local/nginx/conf/koi-win’ are the same file

make[1]: *** [install] Error 1

make[1]: Leaving directory`/usr/local/nginx'

make: *** [install] Error 2

[root@localhost nginx]# mv /usr/local/nginx

mv: missing destination file operand after‘/usr/local/nginx’

Try 'mv --help' for more information.

這是我們的安裝目錄和源碼目錄衝突,我們應該把解壓的文件放在其他位置,不要放在、usr/local下面

5.使用make命令編譯

make

然後再使用make install

make install
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/usr/local/nginx/logs' 		|| mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' || 		mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html' 		|| cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' || 		mkdir -p '/usr/local/nginx/logs'
make[1]: Leaving directory `/root/nginx'

結尾爲這個命令就說明你安裝成功了。

6.開啓nginx

當我們安裝成功後,、usr/local下會多一個nginx文件夾

 cd /usr/local/
[root@admin local]# ls
aegis  bin  games    lib    libexec  native  redis-4.0.8  share  tomcat
apr    etc  include  lib64  mysql    nginx   sbin         src

進入nginx下面sbin

cd nginx/
[root@admin nginx]# ls
conf  html  logs  sbin
[root@admin nginx]# cd sbin/
[root@admin sbin]# ls
nginx

這是使用如下命令啓動

./nginx
查看進程,這時我們的進程就啓動成功了。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章