官网: www.nginx.org
版本: Stable version ==> nginx-1.14.0
命令: ./configure --prefix=/data/nginx
问题: the HTTP rewrite module requires the PCRE library ...
处理: nginx 默认是开启 rewrite 功可以,此处需要 PCRE 库,或者者用命令关闭 rewrite
下载PCRE库,有两个版本,还有一个是PCRE2,我下载的是【pcre-8.42】,
假如用的是 pcre2 则,需要升级 perl 到 perl 5
关于configure 的说明,请参考:http://nginx.org/en/docs/configure.html
命令: ./configure --prefix=/data/nginx --with-pcre=/root/pcre-8.42
成功用Nginx默认的配置编译完成,注意以下参数的默认值:
--user # 运行的使用户,此使用户已存在
--group # 选择的使用户组,此组已存在
--error-log # 默认的错误日志
--pid-path # PID 文件
--conf-path # 全局配置文件
--lock-path # lock 文件
命令: make && make install
执行完成之后,可在安装目录看到如下目录结构,在运行Nginx会生成其它的缓存目录:
/data/nginx
├── conf # 所有配置文件目录,后缀为 default 的都是默认的配置文件,使用于复原配置用
│ ├── fastcgi.conf # fastcgi 配置文件
│ ├── fastcgi.conf.default
│ ├── fastcgi_params # fastcgi 参数
│ ├── fastcgi_params.default
│ ├── koi-utf # 未知
│ ├── koi-win # 未知
│ ├── mime.types # Http mime 类型
│ ├── mime.types.default
│ ├── nginx.conf # 全局配置文件,可使用 include 包含,比方: include ./vhost/*.conf
│ ├── nginx.conf.default
│ ├── scgi_params # scgi 参数
│ ├── scgi_params.default
│ ├── uwsgi_params # uwsgi 参数
│ ├── uwsgi_params.default
│ └── win-utf # 未知
├── html # Nginx 默认的网页,在编译安装完成并启动之后,默认就显示此目录下的内容
│ ├── 50x.html
│ └── index.html
├── logs # 日志目录
└── sbin # 可执行文件目录
└── nginx # Nginx启动程序
编辑安装的Nginx是没有提供启动脚本的,“【修改】”表示需要修改,
此脚本放到 /etc/init.d/ 目录下,并命令为 nginx 并增加执行权限 chmo +x nginx
脚本内容参考如下:
#!/bin/bash
# 此脚本需要,在编辑Nginx的时候,需要增加有 --user 参数,或者者在此脚本中关闭 "make_dirs" 函数的调使用
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: NGINX is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/nginx.conf # 【修改】配置文件路径
# pidfile: /var/run/nginx.pid # 【修改】PID文件路径
# Source function library. # 资源库
. /etc/rc.d/init.d/functions
# Source networking configuration. # 网络配置
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0 # 网络检查
nginx="/usr/local/nginx/sbin/nginx" # 【修改】Nginx执行文件路径
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" # 【修改】主配置文件
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
# 从编译命令中获取相关参数,并创立必要的目录与运行使用户,同时分配权限
make_dirs() {
user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
if [ -z "`grep $user /etc/passwd`" ]; then
useradd -M -s /bin/nologin $user
fi
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
mkdir -p $value && chown -R $user $value
fi
fi
done
}
start() {
[ -x $nginx ] || exit 5 # 检查执行文件
[ -f $NGINX_CONF_FILE ] || exit 6 # 检查配置文件
make_dirs # 创立必要的运行环境,可看上面的方法,可注释
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE # daemon 为 functions 中定义的函数,调使用它来启动
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT # 向进程发送关闭信号
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
sleep 1
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP # 向进程发送重启信号
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog # 调使用 functions 中的函数,返回状态
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
脚本启动参数: 开启|中止|状态|重启|连续启动|尝试重启|重新加载|强制重新加载|测试配置文件
chkconfig --add nginx 增加到自启动服务器列表
chkconfig --level 2345 nginx on 系统在2345启动模式下自动启使用Nginx
chkconfig --list 查看
FIFA23 Origin/STEAM PC中文正版足球游戏 官网激活码CDK 自动发货
鹅鸭杀兑换码金币充值港湾鹅鸭杀扭蛋机代币激活码cdkey皮肤礼包goose goose duck狼人杀鹅鸭游戏
潘毅 闻道中医 推天道以明医事 35节高清视频课程 问道中医
uplay 全境封锁2 激活码 全境封锁2纽约军阀版DLC标准黄金终极版TOM CLANCY'S THE DIVISION 2正版育碧PC游戏
PC中文Steam 古剑奇谭三Gujian3 国区全球CDKey激活码 古剑奇谭3 古剑3 古剑奇谭2古剑1
Uplay育碧 刺客信条英灵殿 激活码CDKEY Assassin's Creed: Valhalla PC游戏正版标准版豪华版完整版曙光