nginx配置
来源:互联网 发布:海尔燃气热水器 知乎 编辑:程序博客网 时间:2024/06/06 05:14
1.从nginx官网(http://nginx.org/) 下载,我在此选择1.12.0版本。
2.安装之前需要安装依赖包,我这里直接用yum安装。
yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
3.装完依赖包后进入nginx目录用./configure --help查看安装选项,我在这里用
./configure --with-http_stub_status_module --prefix=/usr/local/nginx --with-debug --with-http_sub_module
出现这样代表nginx安装成功,然后执行make,make install。
执行 #whereis nginx 出现内容代表成功。
4.设置启动服务
在/etc/init.d下编辑nginx文件,往里面添加
exit 0#!/bin/sh
# chkconfig: 2345 85 15
# Startup script for the nginx Web Server
# description: nginx is a World Wide Web server.
# It is used to serve HTML files and CGI.
# processname: nginx
# pidfile: /usr/local/nginx/logs/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx deamon"
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
SCRIPTNAME=/etc/init.d/$NAME
test -x $DAEMON || exit 0
d_start(){
$DAEMON || echo -n "already running"
}
d_stop(){
$DAEMON -s quit || echo -n "not running"
}
d_reload(){
$DAEMON -s reload || echo -n "can not reload"
}
case "$1" in
start)
echo -n "Starting DESC:DESC:NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping DESC:DESC:NAME"
d_stop
echo "."
;;
reload)
echo -n "Reloading $DESC conf..."
d_reload
echo "reload ."
;;
restart)
echo -n "Restarting DESC:DESC:NAME"
d_stop
sleep 2
d_start
echo "."
;;
*)
echo "Usage: $ScRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac
保存退出
设置文件的访问权限
# chmod +x /etc/init.d/nginx
添加nginx到启动服务里
# chkconfig --add nginx
设置nginx开机启动
# chkconfig nginx on
查看nginx是否开机启动
chkconfig --list nginx
5.添加nginx全局变量
编辑 /etc/profile文件,在文档最后添加
PATH=$PATH:/usr/local/nginx/sbinexport PATH
:wq!保存退出, 执行 source /etc/profile
6.运行nginx
service nginx start,打开网站出现
运行成功
- Varnish+Nginx 配置----Nginx
- Nginx-配置-nginx.conf
- 【Nginx】Nginx配置优化
- 105 nginx nginx 配置
- nginx nginx.conf 配置
- nginx 配置
- nginx 配置
- Nginx配置
- nginx配置
- NGINX配置
- nginx配置
- Nginx配置
- nginx配置
- nginx配置
- nginx 配置
- nginx 配置
- nginx配置
- Nginx配置
- rosrun,roslaunch: cannot launch node or is either a launch file in package
- android 写log到文件
- 线程安全并且无阻塞的Atomic类
- mysql中的毫秒问题
- 你还在用notifyDataSetChanged?
- nginx配置
- Linux基础学习——unit12
- FairSync与NonfairSync
- 【转载】Android异步处理
- MeasureSpec介绍及使用详解
- Android如何在初始化的时候获取加载的布局的宽高
- Thread例子
- [KERNEL] SpeedMod N7000 Jelly Bean [K5-5 CWM CIFS ROOT / NO-ROOT]
- android购买装备