ubuntu安裝Nginx

  什麼都不說了 直接幹html

1、安裝Nginx

首先從Nginx的官網下載最新的穩定版本1.14.0:nginxnginx

1.解壓安裝包ubuntu

1.root@ubuntu:tar -zxf nginx-1.14.0.tar.gz 
2.
root@ubuntu:cd nginx-1.14.0/
3.
root@ubuntu:./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.

若是出現以上錯誤 提示HTTP的rewrite模塊須要PCRE庫,若是須要使用HTTP的rewrite功能,須要首先安裝PCRE庫瀏覽器

PCRE庫的下載地址:https://sourceforge.net/projects/pcre/files/pcre/8.42/pcre-8.42.tar.gz/downloadui

root@ubuntu:~$ tar -xzf pcre-8.42.tar.gz 
root@ubuntu:~$ cd pcre-8.42/
root@ubuntu:~/pcre-8.42$ sudo ./configure
root@ubuntu:~/pcre-8.42$ sudo make
root@ubuntu:~/pcre-8.42$ sudo make install

PCRE安裝完成以後繼續Nginx的安裝spa

root@ubuntu:~/pcre-8.42$ cd ../nginx-1.14.0/
root@ubuntu:~/nginx-1.14.0$ sudo ./configure
    ......
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.

HTTP的gzip模塊須要zlib庫的支持,下載zlib庫的最新版本:http://www.zlib.net/.net

root@ubuntu:~$ tar -xzf zlib-1.2.11.tar.gz 
root@ubuntu:~$ cd zlib-1.2.11/
root@ubuntu:~/zlib-1.2.11$ sudo ./configure
root@ubuntu:~/zlib-1.2.11$ sudo make
root@ubuntu:~/zlib-1.2.11$ sudo make install

安裝完zlib庫以後再次安裝Nginx3d

root@ubuntu:~/zlib-1.2.11$ cd ../nginx-1.14.0/
root@ubuntu:~/nginx-1.14.0$ sudo ./configure
root@ubuntu:~/nginx-1.14.0$ sudo make
root@ubuntu:~/nginx-1.14.0$ sudo make instal

進入/usr/local/nginx/sbin 目錄下 啓動nginxcode

root@ubuntu:/usr/local/nginx/sbin$ ./nginx 

查看nginx進程  ps -ef|grep nginxhtm

root@ubuntu:/home/ubuntu/Nginx# ps -ef |grep nginx
root     28746     1  0 14:03 ?        00:00:00 nginx: master process ./nginx
nobody   28747 28746  0 14:03 ?        00:00:00 nginx: worker process
root     28785 20480  0 14:25 pts/2    00:00:00 grep --color=auto nginx
root@ubuntu:/home/ubuntu/Nginx# 

而後瀏覽器輸入IP地址  默認80端口

 

 

到這裏就完成了Nginx的安裝

 

若是出現此報錯

./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

在/usr/local/nginx/sbin 目錄下執行如下命令 建立目錄

root@ubuntu:/usr/local/nginx/sbin$ sudo ln -s /usr/local/lib/libpcre.so.1 /lib

 

 

 

技術QQ羣:216868740

相關文章
相關標籤/搜索