欢迎来到梦飞科技

服务器租用

当前优惠活动:

Linux系统下安装nginx处事教程

nginx依赖一些软件库,在安装之前请确保系统安装了gcc、ssl、pcre和gzip等软件,可以用rpm -q 呼吁查察软件是否安装。

[[email protected] ~]# rpm -q gcc
gcc-4.1.2-44.el5

依赖库信息如下:

(1). gzip 模块需要 zlib 库 ( 下载: http://www.zlib.net/ )
(2). rewrite 模块需要 pcre 库 ( 下载: http://www.pcre.org/)
(3). ssl 成果需要 openssl 库 ( 下载: http://www.openssl.org/)

如安装pcre,下载pcre至目标目次下,这里选择的版本是pcre-8.38,下载完后执行以下操纵

tar -zxvf pcre-8.38.tar.gz
cd pcre-8.38
./configure
make
make install

安装nginx,执行如下呼吁

        在默认环境下,颠末编译安装的Nginx已经包括了大部门可用模块,可以通过“./configure  --help”选项配置各个模块的利用环境,譬喻对不需要的http_ssi模块,可通过“--without-http_ssi_module”参数封锁此模块;假如需要“http_perl”模块,则可以通过“--with-http_perl_module”参数安装此模块。执行以下操纵举办安装。

tar -zxvf nginx-1.11.1.tar.gz
cd nginx-1.11.1
./configure --with-pcre=../pcre-8.38 --prefix=/usr/local/nginx
make
make install

检测是否安装乐成,执行呼吁如下

[[email protected] sbin]# cd /usr/local/nginx/sbin
[[email protected] sbin]# ./nginx -t
呈现如下信息证明安装乐成
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
启动nginx
[[email protected] sbin]# ./nginx
查察端口
[[email protected] sbin]# netstat -ntlp
功效如下:
Proto Recv-Q Send-Q Local Address     Foreign Address   State    PID/Program name
tcp        0      0 127.0.0.1:2208    0.0.0.0:*         LISTEN   2993/hpiod
tcp        0      0 0.0.0.0:834       0.0.0.0:*         LISTEN   2772/rpc.statd
tcp        0      0 0.0.0.0:11111     0.0.0.0:*         LISTEN   3391/ricci
tcp        0      0 0.0.0.0:111       0.0.0.0:*         LISTEN   2733/portmap
tcp        0      0 0.0.0.0:80        0.0.0.0:*         LISTEN   3852/nginx
tcp        0      0 0.0.0.0:16851     0.0.0.0:*         LISTEN   3290/modclusterd
tcp        0      0 127.0.0.1:631     0.0.0.0:*         LISTEN   3024/cupsd
tcp        0      0 127.0.0.1:25      0.0.0.0:*         LISTEN   3057/sendmail: acce
tcp        0      0 127.0.0.1:2207    0.0.0.0:*         LISTEN   2998/python
tcp        0      0 :::22             :::*              LISTEN   3013/sshd
也可以在欣赏器中输入:http://localhost来验证是否启动乐成。

遏制nginx

遏制操纵是通过向nginx历程发送信号来举办的

步调1:查询nginx主历程号:

ps -ef | grep nginx
在历程列内外 面找master历程,它的编号就是主历程号了。

步调2:发送信号

从容遏制Nginx:kill -QUIT 主历程号

快速遏制Nginx:kill -TERM 主历程号

强制遏制Nginx:pkill -9 nginx

重启nginx:滑腻重启

        假如变动了设置就要重启Nginx,要先封锁Nginx再打开?不是的,可以向Nginx 发送信号,滑腻重启。

滑腻重启呼吁:
kill -HUP 住进称谓或历程号文件路径   可能   /usr/local/nginx/sbin/nginx -s reload

梦飞科技 - 全球数据中心基础服务领先供应商

Copyright © 2003-2019 MFISP.COM. 国外服务器租用 IDC公司 版权所有 粤ICP备11019662号