nginx编译安装

1 安装依赖

--root配置
yum install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel

2 makefile

--root配置
cd /home/ems/nginx/nginx-1.24.0
./configure --prefix=/etc/nginx --with-http_ssl_module --with-threads --with-http_v2_module --with-http_stub_status_module --with-stream --without-http_geo_module

3 编译安装

--root配置
#编译
make 
/*
objs/src/stream/ngx_stream_upstream_random_module.o \
objs/src/stream/ngx_stream_upstream_zone_module.o \
objs/ngx_modules.o \
-ldl -lpthread -lpthread -lcrypt -lpcre2-8 -lssl -lcrypto -ldl -lpthread -lz \
-Wl,-E
sed -e "s|%%PREFIX%%|/etc/nginx|" \
        -e "s|%%PID_PATH%%|/etc/nginx/logs/nginx.pid|" \
        -e "s|%%CONF_PATH%%|/etc/nginx/conf/nginx.conf|" \
        -e "s|%%ERROR_LOG_PATH%%|/etc/nginx/logs/error.log|" \
        < man/nginx.8 > objs/nginx.8
make[1]: 离开目录“/home/ems/nginx/nginx-1.24.0”
*/
#安装
make install 
/*
[root@user nginx-1.24.0]# make install
make -f objs/Makefile install
make[1]: 进入目录“/home/ems/nginx/nginx-1.24.0”
test -d '/etc/nginx' || mkdir -p '/etc/nginx'
test -d '/etc/nginx/sbin' \
        || mkdir -p '/etc/nginx/sbin'
test ! -f '/etc/nginx/sbin/nginx' \
        || mv '/etc/nginx/sbin/nginx' \
                '/etc/nginx/sbin/nginx.old'
cp objs/nginx '/etc/nginx/sbin/nginx'
test -d '/etc/nginx/conf' \
        || mkdir -p '/etc/nginx/conf'
cp conf/koi-win '/etc/nginx/conf'
cp conf/koi-utf '/etc/nginx/conf'
cp conf/win-utf '/etc/nginx/conf'
test -f '/etc/nginx/conf/mime.types' \
        || cp conf/mime.types '/etc/nginx/conf'
cp conf/mime.types '/etc/nginx/conf/mime.types.default'
test -f '/etc/nginx/conf/fastcgi_params' \
        || cp conf/fastcgi_params '/etc/nginx/conf'
cp conf/fastcgi_params \
        '/etc/nginx/conf/fastcgi_params.default'
test -f '/etc/nginx/conf/fastcgi.conf' \
        || cp conf/fastcgi.conf '/etc/nginx/conf'
cp conf/fastcgi.conf '/etc/nginx/conf/fastcgi.conf.default'
test -f '/etc/nginx/conf/uwsgi_params' \
        || cp conf/uwsgi_params '/etc/nginx/conf'
cp conf/uwsgi_params \
        '/etc/nginx/conf/uwsgi_params.default'
test -f '/etc/nginx/conf/scgi_params' \
        || cp conf/scgi_params '/etc/nginx/conf'
cp conf/scgi_params \
        '/etc/nginx/conf/scgi_params.default'
test -f '/etc/nginx/conf/nginx.conf' \
        || cp conf/nginx.conf '/etc/nginx/conf/nginx.conf'
cp conf/nginx.conf '/etc/nginx/conf/nginx.conf.default'
test -d '/etc/nginx/logs' \
        || mkdir -p '/etc/nginx/logs'
test -d '/etc/nginx/logs' \
        || mkdir -p '/etc/nginx/logs'
test -d '/etc/nginx/html' \
        || cp -R html '/etc/nginx'
test -d '/etc/nginx/logs' \
        || mkdir -p '/etc/nginx/logs'
make[1]: 离开目录“/home/ems/nginx/nginx-1.24.0”
*/

4 环境变量

#修改PATH变量
echo "PATH=$PATH:/etc/nginx/sbin" >>/root/.bashrc
#执行修改了环境变量的脚本
source /root/.bashrc

5 查看nginx版本

[root@user nginx]# nginx -V
nginx version: nginx/1.24.0
built by gcc 7.3.0 (GCC)
built with OpenSSL 1.1.1f  31 Mar 2020
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --with-http_ssl_module --with-threads --with-http_v2_module --with-http_stub_status_module --with-stream --without-http_geo_module

6 启动停止nginx

#启动 说明nginx.conf配置可以指定自定义命名的conf,如:web_nginx.conf
nginx -c /etc/nginx/conf/nginx.conf
#停止
nginx -s stop -c /etc/nginx/conf/nginx.conf

7 永久停止firewalld

#stop firewall和设置下次开机不启动firewalld
systemctl stop firewalld
systemctl disable firewalld

8 永久停止selinux

cat /etc/sysconfig/selinux 查看下是否关闭
/*
[root@user nginx]# cat /etc/sysconfig/selinux

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     ukmls - Multi Level Security protection.
#     ukmcs -ukmcs variants of the SELinux policy.
SELINUXTYPE=ukmcs

# SETLOCALDEFS= Check local definition changes
SETLOCALDEFS=0

*/
如果无执行以下命令
setenforce 0
sed -i '/^SELINUX=/s/enforcing/disabled/' /etc/sysconfig/selinux 
  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值