设为首页 收藏本站
查看: 960|回复: 0

[经验分享] lnmp环境下编译安装zabbix----nginx安装和配置

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-9-8 09:29:06 | 显示全部楼层 |阅读模式
    lnmp环境下编译安装zabbix可以在各大逛网上下载和安装。接下来一个个安装,linux,nginx,mysql,php由于linux实现安装好,接下来安装nginx,mysql,php来一步步的演示。


                        <一>nginx的安装和相关的配置

1,首先从官网上下载需要安装nginx版本(http://nginx.org/en/download.html)我以nginx1.8.0
为准。
2,安装前需要 prce和openssl包的支持,首先要yum安装。
[iyunv@localhost install]# yum install prce*
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirrors.pubyun.com
* extras: mirrors.pubyun.com
* updates: mirrors.pubyun.com
base                                                     | 3.7 kB     00:00     
base/primary_db                                          | 4.6 MB     00:00     
extras                                                   | 3.4 kB     00:00     
extras/primary_db                                        |  27 kB     00:00     
updates                                                  | 3.4 kB     00:00     
updates/primary_db                                       | 1.3 MB     00:00     
Setting up Install Process
No package prce* available.
[iyunv@localhost install]# yum -y install pcre-devel openssl openssl-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.pubyun.com
* extras: mirrors.pubyun.com
* updates: mirrors.pubyun.com
Setting up Install Process
No package prce* available.
Error: Nothing to do
[iyunv@localhost install]# yum -y install openssl*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.pubyun.com
* extras: mirrors.pubyun.com
* updates: mirrors.pubyun.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package openssl.x86_64 0:1.0.1e-15.el6 will be updated
---> Package openssl.x86_64 0:1.0.1e-42.el6 will be an update
---> Package openssl-devel.x86_64 0:1.0.1e-42.el6 will be installed
--> Processing Dependency: zlib-devel for package: openssl-devel-1.0.1e-42.el6.x86_64
--> Processing Dependency: krb5-devel for package: openssl-devel-1.0.1e-42.el6.x86_64
---> Package openssl-perl.x86_64 0:1.0.1e-42.el6 will be installed
--> Processing Dependency: perl(vars) for package: openssl-perl-1.0.1e-42.el6.x86_64
--> Processing Dependency: perl(strict) for package: openssl-perl-1.0.1e-42.el6.x86_64
--> Processing Dependency: perl(WWW::Curl::Easy) for package: openssl-perl-1.0.1e-42.el6.x86_64
--> Processing Dependency: perl(IO::Handle) for package: openssl-perl-1.0.1e-42.el6.x86_64
--> Processing Dependency: perl(Getopt::Std) for package: openssl-perl-1.0.1e-42.el6.x86_64
Dependency Updated:
  e2fsprogs.x86_64 0:1.41.12-22.el6                                             
  e2fsprogs-libs.x86_64 0:1.41.12-22.el6                                       
  keyutils-libs.x86_64 0:1.4-5.el6                                             
  krb5-libs.x86_64 0:1.10.3-42.el6                                             
  libcom_err.x86_64 0:1.41.12-22.el6                                            
  libselinux.x86_64 0:2.0.94-5.8.el6                                            
  libselinux-utils.x86_64 0:2.0.94-5.8.el6                                      
  libss.x86_64 0:1.41.12-22.el6                                                

Complete!



3,对nginx进行解压
[iyunv@localhost install]# tar zxvf nginx-1.8.0.tar.gz
nginx-1.8.0/
nginx-1.8.0/auto/
nginx-1.8.0/conf/
nginx-1.8.0/contrib/
nginx-1.8.0/src/
nginx-1.8.0/configure
nginx-1.8.0/LICENSE
nginx-1.8.0/README
nginx-1.8.0/html/
nginx-1.8.0/man/
nginx-1.8.0/CHANGES.ru
nginx-1.8.0/CHANGES
nginx-1.8.0/man/nginx.8
nginx-1.8.0/html/50x.html
nginx-1.8.0/html/index.html

4,编译安装:

./configure --prefix=/usr/local/nginx   --with-http_ssl_module --with-http_spdy_module --with-http_stub_status_module --with-pcre
               

其中:
--with-http_stub_status_module:支持nginx状态查询
--with-http_ssl_module:支持https
--with-http_spdy_module:支持google的spdy,想了解请百度spdy,这个必须有ssl的支持
--with-pcre:为了支持rewrite重写功能,必须制定pcre
[iyunv@localhost nginx-1.8.0]# ./configure --prefix=/usr/local/nginx   --with-http_ssl_module --with-http_spdy_module --with-http_stub_status_module --with-pcre
checking for OS
+ Linux 2.6.32-431.el6.x86_64 x86_64
checking for C compiler ... found
+ using GNU C compiler
+ gcc version: 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
checking for gcc -pipe switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found

[iyunv@localhost nginx-1.8.0]# make
[iyunv@localhost nginx-1.8.0]# make install


5,[iyunv@localhost html]# vi /usr/local/nginx/conf/nginx.conf



worker_processes  1;
error_log  /data/nginx/error.log;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    access_log      /data/nginx/access.log;
    keepalive_timeout  65;

    gzip  on;
   
  upstream test.com{

        server 192.168.1.245:80;
              }

    server {
         listen       80;
         server_name  localhost;
        access_log  /data/nginx/log/nginx.access.log;



        index index.php  index.html;
         root      /usr/local/nginx/html;
       # root    /data/php;
       # root    /data/test/php;
       # root    /data/www/php;
         error_page 500 502 503 /50x.html;


     location ~ \.php$
         {
            # root   /usr/local/nginx/html/zabbix;
             expires -1s;
             #index index.php  index.html;
             fastcgi_split_path_info ^(.+\.php)(/.+)$;
             include fastcgi_params;
             fastcgi_param PATH_INFO $fastcgi_path_info;
             fastcgi_index index.php;
             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
             fastcgi_pass 127.0.0.1:9000;

           }

    }


}



6,为nginx提供SysV init脚本,新建文件/etc/rc.d/init.d/nginx,把以下内容复制到前面提到的目录下:
#!/bin/sh

#nx - 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:      /etc/nginx/nginx.conf
# config:      /etc/sysconfig/nginx
# pidfile:     /var/run/nginx.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"
prog=$(basename $nginx)

NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"

[ -f /usr/local/nginx ] && . /usr/local/nginx

lockfile=/var/lock/subsys/nginx

make_dirs() {
   # make required directories
   user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
   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
               # echo "creating" $value
               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
    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
}

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


7添加启动项并做成服务:
[iyunv@localhost nginx-1.8.0]chmod +x /etc/rc.d/init.d/nginx
[iyunv@localhost nginx-1.8.0]chkconfig --add nginx
[iyunv@localhost nginx-1.8.0]chkconfig  nginx on
[iyunv@localhost nginx-1.8.0]service nginx start

[iyunv@localhost php]# /etc/init.d/nginx restart
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
Stopping nginx: [  OK  ]
Starting nginx: [  OK  ]
[iyunv@localhost php]# ps -A|grep nginx
11724 ?        00:00:00 nginx
11725 ?        00:00:00 nginx





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-110909-1-1.html 上篇帖子: zabbix监控mysql 下篇帖子: 安装zabbix------安装php
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表