微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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 就可以运行了

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐