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

相关文章
相关标签/搜索