标签 系统部署 下的文章

系统部署之nginx安装

系统部署之nginx安装

安装文件

  • nginx-1.12.0.tar.gz
  • gd-devel-2.0.35-26.el7.x86_64.rpm

安装依赖

yum install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libxslt libxslt-devel gd-devel geoip geoip-devel -y

yum install gd fontconfig-devel freetype-devel libX11-devel libXpm-devel libjpeg-devel libpng-devel -y

创建用户

useradd -M -s /sbin/nologin nginx

编译安装

./configure \
 --prefix=/usr/local/nginx \
 --user=nginx \
 --group=nginx \
 --with-pcre \
 --with-http_ssl_module \
 --with-http_v2_module \
 --with-http_realip_module \
 --with-http_addition_module \
 --with-http_sub_module \
 --with-http_dav_module \
 --with-http_flv_module \
 --with-http_mp4_module \
 --with-http_gunzip_module \
 --with-http_gzip_static_module \
 --with-http_random_index_module \
 --with-http_secure_link_module \
 --with-http_stub_status_module \
 --with-http_auth_request_module \
 --with-http_image_filter_module \
 --with-mail \
 --with-mail_ssl_module \
 --with-stream_ssl_module

 make && make install

系统服务

vi /usr/lib/systemd/system/nginx.service

[Unit]
 Description=The nginx HTTP and reverse proxy server
 After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
 Type=forking
 PIDFile=/usr/local/nginx/logs/nginx.pid
 ExecStartPre=/usr/local/nginx/sbin/nginx -t
 ExecStart=/usr/local/nginx/sbin/nginx
 ExecReload=/bin/kill -s HUP /usr/local/nginx/logs/nginx.pid
 ExecStop=/bin/kill -s QUIT /usr/local/nginx/logs/nginx.pid
 PrivateTmp=true

[Install]
 WantedBy=multi-user.target

配置自启动

配置开机自动启动
systemctl enable nginx

启动服务
systemctl start nginx

停止服务
systemctl stop nginx