Nginx的yum安装以及源码安装
2019-07-30 11:46
120 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_44685773/article/details/97488084
1.yum安装
yum安装法法简单,但是缺少灵活性;无法自定义模块及安装路径
配置yum源的配置文件:
在/etc/yum.repos.d 下编写一个nginx.repo
vi /etc/yum.repos.d/nginx.repo [nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key [nginx-mainline] name=nginx mainline repo baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/ gpgcheck=1 enabled=0 gpgkey=https://nginx.org/keys/nginx_signing.key
cat nginx.repo [nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key [nginx-mainline] name=nginx mainline repo baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/ gpgcheck=1 enabled=0 gpgkey=https://nginx.org/keys/nginx_signing.key
然后安装:
make install nginx
2.源码安装
源码包获取:http://nginx.org/download/
源码安装法法过程繁琐,但是可定制化安装
源码安装的环境说明:
系统:CentOS 7.4
软件:nginx-1.17.0tar.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
(1)安装环境准备,安装依赖包,创建安装目录
[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.17.0.tar.gz -C /usr/local/src/
(2).编译安装
[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
(3)配置环境变量:
[root@localhost sbin]# ./nginx -t [root@localhost sbin]# vim /etc/profile export PATH=$PATH/opt/data/nginx/sbin #添加环境 [root@localhost sbin]# source /etc/profile
(4)Nignx配置:
[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; server{} } [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
(5)Nginx启动:
[root@localhost conf]#vim /lib/systemd/system/nginx.service #Centos7的启动。Centos6 的写在/etc/init.d 下面 [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 -t是检查语法的意思 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
相关文章推荐
- nginx服务器详细安装过程(使用yum 和 源码包两种安装方式,并说明其区别)
- nginx 安装(源码及yum)
- CentOS6.5 yum安装配置nginx 以及相关配置
- 阿里云ECS安装MySQL通过yum安装,rpm源码安装,navicat for mysql 无法远程连接解决办法 包括Tomcat,Nginx无法远程访问等
- nginx服务器详细安装过程(使用yum 和 源码包两种安装方式,并说明其区别)
- yum安装的nginx以及解决selinux导…
- nginx服务器详细安装过程(使用yum 和 源码包两种安装方式,并说明其区别)
- yum安装的nginx以及解决selinux导致无法访问的问题
- centos6.5源码安装和centos7.2使用yum安装httpd后,如何添加模块;以及怎么设置Cache-Control:max-age=?浏览器缓存时间
- nginx服务器详细安装过程(使用yum 和 源码包两种安装方式,并说明其区别)
- nginx服务器详细安装过程(使用yum 和 源码包两种安装方式,并说明其区别)
- centos6.5源码安装和centos7.2使用yum安装httpd后,如何添加模块;以及怎么设置Cache-Control:max-age=?浏览器缓存时间
- Linux下源码安装nginx服务器以及部分配置
- nginx服务器详细安装过程(使用yum 和 源码包两种安装方式,并说明其区别)
- Nginx (一)Windows下编译Nginx源码以及安装 nginx for windows方法步骤
- nginx服务器详细安装过程(使用yum 和 源码包两种安装方式,并说明其区别)
- rpm软件包管理,YUM以及源码编译安装
- 源码安装nginx以及平滑升级
- yum工具详解以及源码包安装讲解
- nginx服务器详细安装过程(使用yum 和 源码包两种安装方式,并说明其区别)