快捷搜索:
来自 67677新澳门手机版 2019-11-24 15:41 的文章
当前位置: 67677新澳门手机版 > 67677新澳门手机版 > 正文

67677新澳门手机版9编写翻译安装Nginx1

1:安装需求的库

Bash

yum install gc gcc gcc-c   pcre-devel zlib-devel openssl-devel

 

2:创造Nginx客户和组

Bash

groupadd www
#创建一个用户,不允许登陆和不创主目录 
useradd -s /sbin/nologin -g www -M www

 

3:下载并解压Nginx

Bash

wget http://nginx.org/download/nginx-1.12.0.tar.gz
tar -xzvf nginx-1.12.0
cd nginx-1.12.0

 

4:配置并编写翻译安装

Bash

./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module
make && make install

参数表达:

nginx大部分常用模块,编写翻译时./configure --help以--without领头的都暗中同意安装。

--prefix=PATH : 钦点nginx的安装目录。私下认可 /usr/local/nginx

--conf-path=PATH : 设置nginx.conf配置文件的不二诀窍。nginx允许使用分歧的布署文件运营,通过命令行中的-c选项。私下认可为prefix/conf/nginx.conf

--user=name: 设置nginx工作进度的客商。安装完毕后,能够任何时候在nginx.conf配置文件改过user指令。暗许的客商名是nobody。--group=name相符

--with-pcre :

设置PCRE库的源码路线,借使已通过yum方式安装,使用--with-pcre自动找到库文件。使用--with-pcre=PATH时,供给从PCRE网址下载pcre库的源码(版本4.4

8.30卡塔尔国并解压,剩下的就交付Nginx的./configure和make来产生。perl正则表达式使用在location指令和 ngx_http_rewrite_module模块中。

--with-zlib=PATH : 钦赐 zlib(版本1.1.3 - 1.2.5卡塔尔国的源码解压目录。在暗中认可就启用的互联网传输压缩模块ngx_http_gzip_module时供给动用zlib 。

--with-http_ssl_module : 使用https合同模块。暗许情状下,该模块未有被创设。前提是openssl与openssl-devel已设置

--with-http_stub_status_module : 用来监督 Nginx 的近些日子场所

--with-http_realip_67677新澳门手机版 ,module : 通过那几个模块允许大家改造顾客端需求头中型地铁户端IP地址值(举例X-Real-IP 或 X-Forwarded-For),意义在于能够使得后台服务器记录原始客户端的IP地址

--add-module=PATH : 增添第三方外界模块,如nginx-sticky-module-ng或缓存模块。每回加多新的模块都要重复编写翻译(Tengine能够在新步向module时无需重新编写翻译卡塔尔

 

5:配置Nginx命令和劳务并开机运转

Bash

vim /etc/init.d/nginx

复制一下代码到上边的文本

Bash

#!/bin/bash  
# nginx Startup script for the Nginx HTTP Server  
#  
# chkconfig: - 85 15  
# description: Nginx is a high-performance web and proxy server.  
# It has a lot of features, but it's not for everyone.  
# processname: nginx  
# pidfile: /var/run/nginx.pid  
# config: /usr/local/nginx/conf/nginx.conf  
nginxd=/usr/local/nginx/sbin/nginx  
nginx_config=/usr/local/nginx/conf/nginx.conf  
nginx_pid=/usr/local/nginx/nginx.pid  

RETVAL=0  
prog="nginx" 

# Source function library.  
. /etc/rc.d/init.d/functions  

# Source networking configuration.  
. /etc/sysconfig/network  

# Check that networking is up.  
[ ${NETWORKING} = "no" ] && exit 0  

[ -x $nginxd ] || exit 0  


# Start nginx daemons functions.  
start() {  

if [ -e $nginx_pid ];then 
   echo "nginx already running...." 
   exit 1  
fi  

   echo -n $"Starting $prog: " 
   daemon $nginxd -c ${nginx_config}  
   RETVAL=$?  
   echo  
   [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx  
   return $RETVAL  

}  


# Stop nginx daemons functions.  
stop() {  
        echo -n $"Stopping $prog: " 
        killproc $nginxd  
        RETVAL=$?  
        echo  
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid  
}  


# reload nginx service functions.  
reload() {  

    echo -n $"Reloading $prog: " 
 $nginxd -s reload  
    #if your nginx version is below 0.8, please use this command: "kill -HUP `cat ${nginx_pid}`" 
    RETVAL=$?  
    echo  

}  

# See how we were called.  
case "$1" in 
start)  
        start  
        ;;  

stop)  
        stop  
        ;;  

reload)  
        reload  
        ;;  

restart)  
        stop  
        start  
        ;;  

status)  
        status $prog  
        RETVAL=$?  
        ;;  
*)  
        echo $"Usage: $prog {start|stop|restart|reload|status|help}" 
        exit 1  
esac  

exit $RETVAL

Bash

cd /etc/rc.d/init.d
#附加执行权限
chmod 755 /etc/init.d/nginx
#开机自启
chkconfig --level 345 nginx on
service nginx start #可选  start | stop | restart | reload | status |  help

6.查看系统IP地址,张开nginx的地头网页

[root@bogon ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:0C:29:9C:2B:A5  
          inet addr:192.168.16.87  Bcast:192.168.16.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe9c:2ba5/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1648500 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2193 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1606718906 (1.4 GiB)  TX bytes:176876 (172.7 KiB)

67677新澳门手机版 1

本文由67677新澳门手机版发布于67677新澳门手机版,转载请注明出处:67677新澳门手机版9编写翻译安装Nginx1

关键词: