系统运维
1.nginx简介
常见WebServer(排行https://www.56dr.com/host/ https://www.56dr.com/host/ )
老牌:Httpd(早期叫Apache) ,开源,市场份额最高
微软:IIS
轻量:Lighttpd,性能高,低耗能,功能欠缺
Nginx诞生
2004年10月发布,俄国人Igor Sysoev开发,rambler.ru
Nginx官网、版本
nginx.org 1.14.0稳定版
国内分支Tengine(https://www.56dr.com/host/
Nginx功能介绍
Http服务、反向代理、负载均衡、邮件代理、缓存加速、SSL、flv/mp4流媒体
2.nginx安装-yum安装
vi /etc/yum.repos.d/nginx.repo
#https://www.56dr.com/host/
name=nginx repo
baseurl=https://www.56dr.com/host/
gpgcheck=0
enabled=1
yum install -y nginx
systemctl start/stop/restart/reload nginx
测试:浏览器访问或者curl访问
检查服务进程:ps aux |grep nginx
检查端口监听:netstat -lnp |grep ‘:80’
有防火墙,需加规则iptables -I INPUT -p tcp –dport 80 -j ACCEPT
nginx -V查看版本以及各个目录、参数
下面是我的脚本自动安装的一个小模块
OS_VERSION=rpm -q --queryformat \'%{VERSION}\' centos-release
echo "………………………………………..nginx…………………………………………."
cp /root/tools/nginx.repo /etc/yum.repos.d/
sed -i "s/6/$OS_VERSION/g" /etc/yum.repos.d/nginx.repo
yum install -y nginx
yum install -y libselinux-python
yum install -y telnet nc
cp /root/tools/nginx.conf /etc/nginx/nginx.conf".bakdate %F
"
cat /root/tools/nginx.conf > /etc/nginx/nginx.conf
if [[ "$OS_VERSION" = 6 ]]; then
setenforce 0 && chkconfig nginx on
elif [[ "$OS_VERSION" = 7 ]];then
setenforce 0 && systemctl enable nginx.service
fi
echo "…………………………………………nginx………………………………"
3.nginx安装-源码安装
wget https://www.56dr.com/host/ //下载包
tar zxf nginx-1.14.0.tar.gz //解压包
cd nginx-1.14.0
./configure –prefix=/usr/local/nginx //开始编译安装
make && make install
/usr/local/nginx/sbin/nginx //启动
pkill nginx //杀死nginx进程,停止nginx服务
/usr/local/nginx/sbin/nginx -t //检测配置文件语法错误
/usr/local/nginx/sbin/nginx -s reload//重载配置
服务管理脚本
https://www.56dr.com/host/
chkconfig: – 30 21
description: http service.
Source Function Library
. /etc/init.d/functions
Nginx Settings
NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=0
prog="Nginx"
start()
{
echo -n $"Starting $prog: "
mkdir -p /dev/shm/nginx_temp
daemon $NGINX_SBIN -c $NGINX_CONF
RETVAL=$?
echo
return $RETVAL
}
stop()
{
echo -n $"Stopping $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -TERM
rm -rf /dev/shm/nginx_temp
RETVAL=$?
echo
return $RETVAL
}
reload()
{
echo -n $"Reloading $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -HUP
RETVAL=$?
echo
return $RETVAL
}
restart()
{
stop
start
}
configtest()
{
$NGINX_SBIN -c $NGINX_CONF -t
return 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
configtest)
configtest
;;
*)
echo $"Usage: $0 {start|stop|reload|restart|configtest}"
RETVAL=1
esac
exit $RETVAL
更多关于云服务器,域名注册,虚拟主机的问题,请访问特网科技官网:www.56dr.com
免责声明:本站发布的内容(图片、视频和文字)以原创、来自本网站内容采集于网络互联网转载等其它媒体和分享为主,内容观点不代表本网站立场,如侵犯了原作者的版权,请告知一经查实,将立刻删除涉嫌侵权内容,联系我们QQ:712375056,同时欢迎投稿传递力量。
Copyright © 2009-2022 56dr.com. All Rights Reserved. 特网科技 特网云 版权所有 特网科技 粤ICP备16109289号
域名注册服务机构:阿里云计算有限公司(万网) 域名服务机构:烟台帝思普网络科技有限公司(DNSPod) CDN服务:阿里云计算有限公司 百度云 中国互联网举报中心 增值电信业务经营许可证B2
建议您使用Chrome、Firefox、Edge、IE10及以上版本和360等主流浏览器浏览本网站