1、安装Nginx的历来库
1.1 为了编译Nginx源代码,需要用到gcc的编译器。又因为,由于Nginx的一些模块需要依赖其他的第三方库,通常有pcre库(支持rewrite模块),zlib库(支持gzip模块),和openssl库(支持ssl模块)。初此之外,还需要Automake工具,已完成自动创建Makefile的工作。
1.2 使用 yum安装第三方库
[root@localhost Desktop]# yum -y install gcc gcc-c++ automake pcre pcre-devel zlib zlib-devel open openssl-devel
2、解压Nginx
tar -zxvf nginx-1.7.3.tar.gz
2、安装Nginx(默认的安装位置在 /usr/local/nginx)
#命令1
./configure --prefix=/usr/local/nginx --with-http_ssl_module
#命令的解释
./configure
--prefix=/nginx #指定安装的目录
--add-module=path #指定第三方模块的路径,用于编译到Nginx中
--with-http_ssl_module #声明启用HTTP的ssl模块,这样Nginx服务器就可以支持HTTPS请求了。这个模块的正常运行,需要安装openssl库。
#命令二
make && make install
3、查看安装的Nginx目录,启动并访问
[root@localhost sbin]# cd /usr/local/nginx/
[root@localhost nginx]# cd sbin/
[root@localhost sbin]# ./nginx
4、查看Nginx的启动进程信息,获取Nginx的Pid
1.Nginx安装成功后,默认在Nginx服务器的安装目录下安装的logs目中会产生文件名为nginx.pid的文件,这个文件保存的就是Nginx服务主进程的PID。这个文件的存放目录和文件名可以在Nginx服务器的配置文件中进行配置。
[root@localhost logs]# cat nginx.pid
7103
2.利用linux下的进程查看工具ps
[root@localhost sbin]# ps -ef | grep nginx
root 7103 1 0 01:18 ? 00:00:00 nginx: master process ./nginx
nobody 7104 7103 0 01:18 ? 00:00:00 nginx: worker process
root 7173 2455 0 01:35 pts/0 00:00:00 grep nginx
5、访问的截图