码迷,mamicode.com
首页 > 其他好文 > 详细

nginx服务器搭建

时间:2019-09-11 09:16:57      阅读:86      评论:0      收藏:0      [点我收藏+]

标签:kconfig   域名   编写   efi   本地   gzip   logs   pid   nginx的安装   

nginx服务搭建
防火墙,安全机制的关闭
iptables -F
systemctl stop firewalld
setenforce 0
本地yum的构建
安装依赖包
yum -y install pcre-devel zlib-devel openssl-devel
nginx服务的搭建需要pcre、zlib等软件包的技术支持
从网上下载nginx软件包
weget+复制的下载路径,或者下载到桌面rz上传
tar -xf nginx-1.14.2.tar.gz -C /usr/src/ #把安装包解压到/usr/src/下
cd /usr/src/nginx-1.14.2
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module &&make &&make install
--prefix 设定Nginx的安装目录
--user和--group 指定Nginx运行用户和组
--with-http_stub_status_module 启用http_stub_status_module模块以支持状态统计
--with-http_ssl_module 启用SSL模块
--with-http_flv_module 启用FLV模块,提供寻求内存使用基于时间的偏移量文件
echo $PATH
ln -s /usr/local/nginx/sbin/nginx /usr/local/bin
ll /usr/local/bin/nginx
nginx -t #检查你的语法是否正确 successful ok代表正确
nginx #启动nginx
netstat -anpt | grep :80 #80端口nginx使用
在浏览器中输入你的ip地址测试nginx是否运行
Welcome to nginx!
HUP 重载进程 等同于-1 killall -s HUP nginx
QUIT 退出进程 等同于 -3 killall -s QUIT nginx
kill杀死进程根据PID号 kill + pid号
PID号的存放位置
cat /usr/local/nginx/logs/nginx.pid
netstat -anpt | greo :80 查看80端口是谁使用着
netstat -a 显示所有 -t tcp传输协议连接状态 -u udp协议连接状态 -p显示程序名称 -n直接使用IP地址,不通过域名服务器
为了让服务开机可以自启动,可以通过编写脚本来实现
vim /etc/init.d/nginx
#!/bin/bash
# chkconfig: 2345 99 20
# description: Nginx Server Control Script
PROG="/usr/local/nginx/sbin/nginx"
PIDF="/usr/local/nginx/logs/nginx.pid"

case "$1" in
start)
$PROG
;;
stop)
kill -s QUIT $(cat $PIDF)
;;
restart)
$0 stop
$0 start
;;
reload)
kill -s HUP $(cat $PIDF)
;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
exit 0
chomd +x /etc/init.d/nginx #加上可执行权限
chkconfig --add nginx
chkconfig nginx on
chkconfig --list nginx # 查看开启状态信息
#服务基本搭建完成

 

 

nginx服务器搭建

标签:kconfig   域名   编写   efi   本地   gzip   logs   pid   nginx的安装   

原文地址:https://www.cnblogs.com/zcdhhh/p/11504304.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!