Nginx程序安装

  1. 源码安装
    (1)源码包的获取
    http://nginx.org/download/
    源码安装的环境说明:
    系统:CentOS 7.4
    软件:nginx-1.14.0.tar.gz
    其他所需软件:openssl-1.0.2d.tar.gz、pcre-8.37.tar.gz、zlib-1.2.8.tar.gz
    安装方式:源码编译安装
    安装位置:/opt/data/nginx
    下载地址:http://nginx.org/download
    (2)安装环境准备,安装依赖包,创建安装目录
[root@localhost ~]# mkdir -p /opt/data/nginx/
[root@localhost ~]# groupadd nginx
[root@localhost ~]# useradd -g nginx nginx
[root@localhost ~]# yum install gcc gcc-c++ make recp pcre-devel openssl openssl-devel -y
[root@localhost ~]# tar -xf nginx-1.14.0.tar.gz -C /usr/local/src/

(3)编译安装

[root@localhost nginx-1.14.0]# ./configure \
> --prefix=/opt/data/nginx \
> --with-http_stub_status_module \
> --with-http_ssl_module \
> --with-stream
[root@localhost nginx-1.14.0]# make &make install

(4)配置环境变量

[root@localhost sbin]# ./nginx -t
[root@localhost sbin]# vim /etc/profile.d/nginx.sh
export PATH=/opt/data/nginx/sbin:$PATH
[root@localhost sbin]# source /etc/profile.d/nginx.sh

(5)Nginx配置

[root@localhost nginx]# ln -s /opt/data/nginx/conf /etc/nginx
[root@localhost nginx]# vim nginx.conf
user nginx;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
access_log off;
client_max_body_size 128M;
include /etc/nginx/conf.d/*.conf;
}
[root@localhost nginx]# mkdir /etc/nginx/conf.d
[root@localhost nginx]# mkdir /var/log/nginx
[root@localhost nginx]# chown -R nginx:nginx /var/log/nginx

(6)Nginx启动

vim /lib/systemd/system/nginx.service
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/opt/data/nginx/sbin/nginx -t -c /opt/data/nginx/conf/nginx.conf
ExecStart=/opt/data/nginx/sbin/nginx -c /opt/data/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[root@localhost conf]# systemctl enable nginx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值