nginx二进制安装
作者:互联网
nginx-1.14.2
yum -y install gcc automake autoconf libtool make pcre pcre-devel zlib zlib-devel openssl openssl-devel
wget http:
//10.5.15.22/centos/nginx-1.14.2.tar.gz
tar xf nginx-
1.14
.
2
.tar.gz -C /opt/
cd /opt/nginx-
1.14
.
2
/
useradd -u
601
nginx -s /sbin/nologin -M
sed -i
's@1.14.2@1.0.0@g'
./src/core/nginx.h
sed -i
's@"nginx/"@"apache/"@g'
./src/core/nginx.h
sed -i
'22s@"NGINX"@"APACHE"@g'
./src/core/nginx.h
sed -i
'49s#nginx#apache#g'
./src/http/ngx_http_header_filter_module.c
sed -i
'36s#nginx#apache#gp'
./src/http/ngx_http_special_response.c
./configure --prefix=/hm/app/nginx --sbin-path=/hm/app/nginx/sbin/nginx --conf-path=/hm/app/nginx/conf/nginx.conf --error-log-path=/hm/log/nginx/error.log --http-log-path=/hm/log/nginx/access.log --pid-path=/run/nginx.pid --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre --with-http_v2_module --with-stream --with-http_gzip_static_module
make && make install
cp -a /hm/app/nginx/sbin/nginx /usr/local/bin/
firewall-cmd --zone=
public
--add-port=
80
/tcp --permanent
firewall-cmd --zone=
public
--add-port=
443
/tcp --permanent
firewall-cmd --reload
#使用systemctl管理nginx
cat <<efo> /usr/lib/systemd/system/nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
# Nginx will fail to start
if
/run/nginx.pid already exists but has the wrong
# SELinux context. This might happen when running `nginx -t` from the cmdline.
# https:
//bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /run/nginx.pid
ExecStartPre=/hm/app/nginx/sbin/nginx -t
ExecStart=/hm/app/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=
5
KillMode=process
PrivateTmp=
true
LimitCORE=infinity
LimitNOFILE=
10240
LimitNPROC=
10240
[Install]
WantedBy=multi-user.target
efo
nginx-1.20.1
yum -y install gcc automake autoconf libtool make pcre pcre-devel zlib zlib-devel openssl openssl-devel
wget http:
//10.5.15.22/centos/nginx-1.20.1.tar.gz
tar xf nginx-
1.20
.
1
.tar.gz -C /opt/
cd /opt/nginx-
1.20
.
1
/
useradd -u
601
nginx -s /sbin/nologin -M
sed -i
's@1.20.1@1.0.0@g'
./src/core/nginx.h
sed -i
's@"nginx/"@"apache/"@g'
./src/core/nginx.h
sed -i
'22s@"NGINX"@"APACHE"@g'
./src/core/nginx.h
sed -i
'49s#nginx#apache#g'
./src/http/ngx_http_header_filter_module.c
./configure --prefix=/hm/app/nginx --sbin-path=/hm/app/nginx/sbin/nginx --conf-path=/hm/app/nginx/conf/nginx.conf --error-log-path=/hm/log/nginx/error.log --http-log-path=/hm/log/nginx/access.log --pid-path=/run/nginx.pid --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre --with-http_v2_module --with-stream --with-http_gzip_static_module
make && make install
cp -a /hm/app/nginx/sbin/nginx /usr/local/bin/
firewall-cmd --zone=
public
--add-port=
80
/tcp --permanent
firewall-cmd --zone=
public
--add-port=
443
/tcp --permanent
firewall-cmd --reload
#使用systemctl管理nginx
cat <<efo> /usr/lib/systemd/system/nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
# Nginx will fail to start
if
/run/nginx.pid already exists but has the wrong
# SELinux context. This might happen when running `nginx -t` from the cmdline.
# https:
//bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /run/nginx.pid
ExecStartPre=/hm/app/nginx/sbin/nginx -t
ExecStart=/hm/app/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=
5
KillMode=process
PrivateTmp=
true
LimitCORE=infinity
LimitNOFILE=
10240
LimitNPROC=
10240
[Install]
WantedBy=multi-user.target
efo
标签:sbin,http,log,二进制,nginx,hm,--,安装 来源: https://www.cnblogs.com/hm1825/p/15825270.html