Linux下安装、配置、启动并访问Nginx(在线安装)
一、安装编译工具(Nginx安装之前需要编译)
[root@lzp local]# yum -y install gcc gcc-c++
二、安装PCRE
1、下载
[root@lzp local]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
2、解压
[root@lzp local]# tar -zxvf pcre-8.35.tar.gz
3、进入pcre目录
[root@lzp local]# cd pcre-8.35
4、配置
[root@lzp pcre-8.35]# ./configure
5、编译安装
[root@lzp pcre-8.35]# make && make install
三、安装SSL库
[root@lzp pcre-8.35]# cd /usr/local [root@lzp local]# wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz --no-check-certificate [root@lzp local]# tar -zxvf openssl-1.0.1j.tar.gz
[root@lzp local]# cd openssl-1.0.1j
[root@lzp openssl-1.0.1j]# ./config
[root@lzp openssl-1.0.1j]# make && make install
四、安装zlib库
[root@lzp openssl-1.0.1j]# cd /usr/local [root@lzp local]# wget http://zlib.net/zlib-1.2.11.tar.gz [root@lzp local]# tar -zxvf zlib-1.2.11.tar.gz [root@lzp local]# cd zlib-1.2.11 [root@lzp zlib-1.2.11]# ./configure [root@lzp zlib-1.2.11]# make && make install
五、安装Nginx
[root@lzp zlib-1.2.11]# cd /usr/local/ [root@lzp local]# wget http://nginx.org/download/nginx-1.16.1.tar.gz [root@lzp local]# tar -zxvf nginx-1.16.1.tar.gz [root@lzp local]# cd nginx-1.16.1 [root@lzp nginx-1.16.1]# mkdir -p /usr/local/server/nginx [root@lzp nginx-1.16.1]# ./configure --prefix=/usr/local/server/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/pcre-8.35
[root@lzp nginx-1.16.1]# make && make install
六、安装成功效果图
七、启动Nginx
[root@lzp local]# cd server/nginx/
[root@lzp nginx]# ll
总用量 4
drwxr-xr-x. 2 root root 4096 11月 14 13:13 conf
drwxr-xr-x. 2 root root 40 11月 14 13:13 html
drwxr-xr-x. 2 root root 6 11月 14 13:13 logs
drwxr-xr-x. 2 root root 19 11月 14 13:13 sbin
[root@lzp nginx]# cd sbin/
[root@lzp sbin]# ./nginx
[root@lzp sbin]# lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 24709 root 6u IPv4 70737 0t0 TCP *:http (LISTEN)
nginx 24710 nobody 6u IPv4 70737 0t0 TCP *:http (LISTEN)
八、访问Nginx(默认端口为80)
http://本地IP
访问成功