CentOS下的Nginx安装配置
来源:互联网 发布:疯狂淘宝李涛微博 编辑:程序博客网 时间:2024/06/05 09:23
CentOS下的Nginx安装配置
这里演示在CentOS使用yum快速安装Nginx,在Ubuntu,Debian下对应apt-get工具,步骤类似:
1)检查系统是否已经有CentOS的rpm安装包
1
rpm -qa nginx
2)如果没有,或者没有需要的版本,通过yum查询仓库
1
yum search nginx
3)选择需要的版本进行下载,如果yum库没有需要的版本,可以添加remi源,或者wget官网的tar包重新编译;
首选要确保系统中有www用户组和www用户,nginx默认归属该用户,当然也可以自己重新指定其他用户组,但是在nginx安装后需要更改nginx.conf中的"use www www"为指定的用户组和用户‘
1
yum -y install nginx
安装结束后,可以通过 chkconfig nginx on 查看nginx的安装信息,和安装路径等;
为了方便演示,假设安装路径在 /usr/local/nginx
4)将nginx的sbin包添加到PATH环境变量方便nginx工具的快速调用;
vim 编辑 /etc/pofile 文件,添加以下文本后,再通过 "source /etc/profile" 更新配置;
1
export PATH=$PATH:/usr/local/nginx/sbin
更新配置后重启 nginx 指令
1
nginx -s reload
当然也可以通过把nginx注册为service来快速开启关闭nginx,在/etc/init.d/ 下创建文件 nginx,添加以下内容:
#!/bin/bash# nginx Startup script for the Nginx HTTP Server# it is v.0.0.2 version.# chkconfig: - 85 15# description: Nginx is a high-performance web and proxy server.# It has a lot of features, but it's not for everyone.# processname: nginx# pidfile: /var/run/nginx.pid# config: /usr/local/nginx/conf/nginx.confnginxd=/usr/local/nginx/sbin/nginxnginx_config=/usr/local/nginx/conf/nginx.confnginx_pid=/var/run/nginx.pidRETVAL=0prog="nginx"# Source function library.. /etc/rc.d/init.d/functions# Source networking configuration.. /etc/sysconfig/network# Check that networking is up.[ ${NETWORKING} = "no" ] && exit 0[ -x $nginxd ] || exit 0# Start nginx daemons functions.start() {if [ -e $nginx_pid ];then echo "nginx already running...." exit 1fi echo -n $"Starting $prog: " daemon $nginxd -c ${nginx_config} RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx return $RETVAL}# Stop nginx daemons functions.stop() { echo -n $"Stopping $prog: " killproc $nginxd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid}# reload nginx service functions.reload() { echo -n $"Reloading $prog: " #kill -HUP `cat ${nginx_pid}` killproc $nginxd -HUP RETVAL=$? echo}# See how we were called.case "$1" instart) start ;;stop) stop ;;reload) reload ;;restart) stop start ;;status) status $prog RETVAL=$? ;;*) echo $"Usage: $prog {start|stop|restart|reload|status|help}" exit 1esacexit $RETVAL
1
2
之后执行:
1
chmod a+x nginx
2
chkconfig --add nginx
便可以通过以下快速启动,关闭,重启nginx
1
service nginx start
2
service nginx stop
3
service nginx restart
阅读全文
0 0
- CentOS下nginx的安装与配置
- Centos下nginx的安装与配置
- CentOS下NGINX的安装与配置
- CentOS下的Nginx安装配置
- CentOS下Nginx的安装配置
- CentOS下Nginx的安装和配置
- centos下nginx的配置
- centos下 nginx的安装
- Centos下nginx的安装
- centos下nginx的安装
- centos下的nginx安装
- centos下Nginx+tomcat整合安装配置
- centos下nginx + php 安装及配置
- centos 7下安装配置nginx
- CentOS 下配置yum安装Nginx
- Centos下 Nginx安装与配置
- Centos下 Nginx安装与配置
- 在centOS下安装nginx并配置
- 醒醒吧,这世界上根本没有稳定的工作
- 事物—事物四大特性
- 设计模式之禅笔记-门面模式
- CSU-ACM2017暑期训练5-三分 E
- c语言模拟实现c++的继承和多态
- CentOS下的Nginx安装配置
- 车牌识别资料整理
- Linux crontab 用法分析
- LeetCode 617. Merge Two Binary Trees
- dav-loading 专辑
- 【HDU1222】 Wolf and Rabbit(GCD)
- 机器学习笔记(六) 决策树
- Spring框架整合测试时出现错误
- Dapper的基本使用