ubuntu安装Nginx
什么都不说了 直接干
一、安装Nginx
首先从Nginx的官网下载最新的稳定版本1.14.0:nginx
1.解压安装包
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/download
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的安装
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/
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库之后再次安装Nginx
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 目录下 启动nginx
root@ubuntu:/usr/local/nginx/sbin$ ./nginx
查看nginx进程 ps -ef|grep nginx
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