linux 编译安装nginx

nginx软件编译安装步骤:
#第一个里程:下载nginx程序软件包
mkdir /server/tools -p
cd /server/tools
wget http://nginx.org/download/nginx-1.14.0.tar.gz
tar xf nginx-1.14.0.tar.gz

#第二个里程:解决软件依赖问题
yum install openssl-devel pcre-devel -y
openssl-devel --- 为了让nginx服务可以实现https访问的功能
pcre-devel    --- 兼容perl语言的正则表达式(^ shell:以什么开头  perl:^/)
                  nginx使用时会应用一个参数rewrite 正则表达式信息(perl)

#第三个里程:创建worker进程的管理用户
useradd -s /sbin/nologin -M www
			
				  
#第四个里程:编译安装软件过程
#编译安装软件三部曲
#01.进行软件的配置

cd nginx-1.12
./configure --prefix=/application/nginx-1.14.2 --user=www --group=www --with-http_ssl_module --with-http_stub_status_module
#重要配置参数总结
#--prefix=PATH                      set installation prefix
#                                   设置软件程序安装到哪个目录,指定的目录不需要创建出来
#--user=USER                        set non-privileged user for worker processes
#--group=GROUP                      set non-privileged group for worker processes
#--with-http_ssl_module             enable ngx_http_ssl_module(可以实现https)
#--with-http_stub_status_module     enable ngx_http_stub_status_module(主要用于监控服务运行状态)

#02.进行软件的编译(将各个语言编写代码翻译成系统可以识别的二进制信息)
make

#03.进行编译安装(将软件最终安装到系统中)
make install


#第五个里程:创建程序软链接
ln -s /application/nginx-1.14.2/ /application/nginx
[root@web01 application]# ll /application/nginx-1.14.2/
total 16
drwxr-xr-x 2 root root 4096 May 16 10:49 conf
drwxr-xr-x 2 root root 4096 May 16 10:49 html
drwxr-xr-x 2 root root 4096 May 16 10:49 logs
drwxr-xr-x 2 root root 4096 May 16 10:49 sbin

一个程序目录部署好,会被其他开发程序或者脚本程序所调用
代码程序1:nginx_info1="/application/nginx/"
代码程序2:nginx_info2="/application/nginx/"
代码程序3: nginx_info3="/application/nginx/"

#第六个里程:启动nginx服务
/application/nginx/sbin/nginx

#查看80端口
netstat -lntup

#将sbin添加至环境变量
vim .bash_profile  (家目录下)
# 将路径添加到PATH
PATH=$PATH:$HOME/bin:/application/nginx-1.14.2/sbin
source .bash_profile

然后 输入 nginx 就可以运行了

原文地址:https://www.cnblogs.com/Afrafre/p/10815099.html