首页 > 其他 > 详细

Nginx安装

时间:2021-06-10 15:20:05      阅读:29      评论:0      收藏:0      [点我收藏+]

下载地址:http://nginx.org/en/download.html

1.YUM安装
vim  /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
module_hotfixes=true
安装
yum install nginx -y
2.源码安装
安装依赖环境
[root@server ~]# yum -y install pcre-devel openssl openssl-devel gd-devel

[root@server ~]# yum -y groups install ‘Development Tools‘
创建日志存放目录
[root@server ~]# mkdir -p /var/log/nginx
[root@server ~]# chown -R nginx.nginx /var/log/nginx/
下载nginx
[root@server ~]# cd /usr/src/
[root@server src]# wget http://nginx.org/download/nginx-1.12.0.tar.gz
编译安装
[root@server ~]# cd /usr/src/
[root@server src]# tar xf nginx-1.12.0.tar.gz
[root@server src]# cd nginx-1.12.0
[root@server nginx-1.12.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

[root@server nginx-1.12.0]# make -j 2 && make install
3.nginx安装后配置配置环境变量
[root@server nginx-1.12.0]# echo ‘export PATH=/usr/local/nginx/sbin:$PATH‘ > /etc/profile.d/nginx.sh
[root@server nginx-1.12.0]#  . /etc/profile.d/nginx.sh

//注:

[root@nginx-server nginx-1.12.0]# echo $PATH
/usr/local/nginx/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
4.启动nginx
[root@server ~]# nginx
[root@server ~]# ss -antl

Nginx安装

原文:https://www.cnblogs.com/yanghaizhen/p/14870788.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!