CentOS 7 Linux 中Yum方式安装Nginx的配置(咋个办呢 zgbn)
来源:互联网 发布:大数据运维工作内容 编辑:程序博客网 时间:2024/05/29 06:28
CentOS 7 Linux 中Yum方式安装Nginx的配置
使用yum方式安装nginx软件之后,需要进行简单的配置,这时候首先需要对nginx的安装信息做简单的了解。
查看yum安装nginx信息命令。
rpm -ql nginx
创建nginx启动脚本
nginx.sh
#!/bin/bash# nginx Startup script for the Nginx HTTP Server# this script create it by jackbillow at 2007.10.15.# it is v.0.0.2 version.# if you find any errors on this scripts,please contact jackbillow.# and send mail to jackbillow at gmail dot com.## 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: /etc/nginx/nginx.confnginxd=/usr/sbin/nginxnginx_config=/etc/nginx/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
配置文件
nginx.conf
这个配置文件中将nginx的进程数调整为8个,追加了gzip配置,其他并没有改动。
user nginx;worker_processes 8;error_log /var/log/nginx/error.log warn;pid /var/run/nginx.pid;events { worker_connections 1024;}http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '[$remote_addr][$http_x_forwarded_for]' '[$remote_user][$time_local]' '[$request][$status][$body_bytes_sent][$request_time]' '[$http_referer][$http_user_agent]'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; gzip on; gzip_min_length 1k; gzip_buffers 32 4k; gzip_comp_level 6; gzip_types text/plain text/css text/javascript application/x-javascript application/xml; #gzip_disable "MSIE [1-6]\."; include /etc/nginx/conf.d/*.conf;}
将nginx.sh服务脚本放到/ext/init.d目录下
命令
cp /ext/nginx/nginx.sh /ext/init.d/nginxchmod 755 /ext/init.d/nginx
测试一下。
service nginx start
启动服务成功则添加成功。
阅读全文
0 0
- CentOS 7 Linux 中Yum方式安装Nginx的配置(咋个办呢 zgbn)
- CentOS 7 Linux 中Yum方式安装MySQL(咋个办呢 zgbn)
- CentOS 7 Linux 安装Tomcat 8(咋个办呢 zgbn)
- Linux 使用yum安装软件实用方法(咋个办呢 zgbn)
- CentOS 7下 yum方式安装Nginx
- CentOS 7 YUM 安装 Nginx
- CentOS 7 yum 安装 Nginx
- centos 7 yum 安装 NGINX
- centos 7 yum安装 nginx
- CentOS 7 yum 安装 Nginx
- CentOS 7 yum 安装 Nginx
- CentOS 7 yum 安装 Nginx
- CentOS 7 yum 安装 Nginx
- CentOS 7 YUM 安装 Nginx
- CentOS 7 yum 安装 Nginx
- CentOS 7 yum 安装 Nginx
- CentOS 7 YUM 安装 Nginx
- CENTOS 6.5 配置YUM安装NGINX
- 怎样才能赚到钱系列(九):交流的价值
- 290. Word Pattern
- TX2更改内核
- MVP+Retrofit封装网络请求
- C#之out与ref
- CentOS 7 Linux 中Yum方式安装Nginx的配置(咋个办呢 zgbn)
- 设计模式之解释器模式
- 玩转 ESP8266 Arduino 笔记01 开发环境搭建
- 全国大学API接口
- HTML基础(4.input其他)
- Python3之1003.我要通过(20分)
- 1.Sping简介
- IFE_js_task02
- 20170620