nginx源码安装

nginx源码安装

1、前提准备

准备主机

主机名称 IP 作用
client 192.168.7.11 nginx主机

下载nginx软件包:http://nginx.org/download/nginx-1.14.0.tar.gz

关闭防火墙和selinux

# systemctl stop firewalld
# systemctl disable firewalld
# setent

下载插件并且创建nginx用户

#  yum -y install pcre-devel openssl openssl-devel gd-devel
#  yum -y groups mark install 'Development Tools' 
#  useradd -r -M -s /sbin/nologin nginx
//创建日志目录
# mkdir -p /var/log/nginx
# chown -R nginx.nginx /var/log/nginx

2、安装

下载并且解压nginx

# wget http://nginx.org/download/nginx-1.14.0.tar.gz
# tar -xf nginx-1.14.0.tar.gz
nginx-1.14.0.tar.gz nginx-1.14.0

进入安装目录进行编译安装

# pwd
/root/nginx-1.14.0
# ./configure --prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \ 
--with-debug \ 
--with-http_ssl_module \
--with-http_realip_module \ 
--with-http_image_filter_module \ 
--with-http_gunzip_module \ 
--with-http_gzip_static_module \ 
--with-http_stub_status_module \ 
--http-log-path=/var/log/nginx/access.log \ 
--error-log-path=/var/log/nginx/error.log

#  make -j $(grep 'processor' /proc/cpuinfo | wc -l) && make install 

查看并且启动

# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
# cd /usr/local/nginx/sbin/
# ls
nginx 

3、nginx后续配置

添加环境变量

# echo "export PATH=/usr/local/nginx/sbin/:$PATH" > /etc/profile.d/nginx.sh
#  /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
# nginx -s start
# ss -antl
State       Recv-Q Send-Q               Local Address:Port                              Peer Address:Port              
LISTEN      0      128                              *:80                                           *:*                  
LISTEN      0      128                              *:22                                           *:*                  
LISTEN      0      100                      127.0.0.1:25                                           *:*                  
LISTEN      0      128                             :::22                                          :::*                  
LISTEN      0      100                            ::1:25                                          :::*       

posted @ 2020-06-14 10:49  -东皇太一-  阅读(130)  评论(0编辑  收藏  举报