博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nginx在linux环境下安装
阅读量:6975 次
发布时间:2019-06-27

本文共 2552 字,大约阅读时间需要 8 分钟。

hot3.png

1、安装依赖包

yum install autoconf automake zlib zlib-devel openssl openssl-devel pcre pcre-devel

2、下载nginx

cd /usr/local/nginxwget http://nginx.org/download/nginx-1.12.2.tar.gz

3、解压安装

tar -zxvf xxx.tar.gzmkdir /usr/local/nginx./configure --prefix=/usr/local/nginx --with-stream (--with-stream 加入tcp模块)makemake install

 

4、防火墙允许80端口通过

vi /etc/sysconfig/iptables在 -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT      -------------redhat -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT      -------------centos下添加: -A INPUT  -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

5、重启防火墙

/etc/init.d/iptables restart 或者 service iptables restart

6、启动

./usr/local/nginx/sbin/nginx

7、停止

./usr/local/nginx/sbin/nginx -s stop

8、设置开机自启动

vi /etc/rc.d/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

9、设置文件权限,加入到系统启动项中

chmod +x /etc/rc.d/init.d/nginxchkconfig --add nginxchkconfig --level 2345 nginx onchkconfig --list nginx

 

转载于:https://my.oschina.net/TonyTaotao/blog/3000673

你可能感兴趣的文章
ORACLE存储过程 练习系列三 失效或者生效指定表的外键
查看>>
用户表空间查询
查看>>
求整数数组中最大子数组的和
查看>>
hdu2546-饭卡???
查看>>
Silverlight 获取控件间的相对位置
查看>>
vscode icon in elementary os
查看>>
Android环境搭建(Windows)
查看>>
MSHFLEXGRID控件常用属性
查看>>
去除iframe滚动条
查看>>
在WORD表格按列添加时间的一种方法
查看>>
poj 2455 Secret Milking Machine
查看>>
Linux 中,如何显示 (gcc)make时实际执行命令
查看>>
每个程序员都应该了解的内存知识(2)-CPU caches
查看>>
solr error logs org.apache.solr.common.SolrException: ERROR: [doc=17] unknown field alias
查看>>
django 项目创建使用
查看>>
简单的Verilog测试模板结构
查看>>
接口数据加密
查看>>
vue-router-transiton
查看>>
Micresoft Dynamices CRM 中的Webresouce
查看>>
DevExpress之TreeList节点绑定图片
查看>>