安装zabbix php和nginx配置,zabbix安装-----nginx安装和配置

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安装。[root@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.

[root@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

[root@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进行解压[root@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[root@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

[root@localhost nginx-1.8.0]# make

[root@localhost nginx-1.8.0]# make install5,[root@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;

}

}

}

备注:

常见的安装配置一:./configure --prefix=/usr/local/nginx \

--with-http_ssl_module \

--with-http_gzip_static_module \

--with-http_realip_module  \

--with-http_stub_status_module \

--with-http_stub_status_module \

--with-pcre=/tmp/install/nginx/pcre-8.36 \

--with-openssl=/tmp/install/nginx/openssl-1.0.2a \

--with-zlib=/tmp/install/nginx/zlib-1.2.8

常见的安装配置二:./configure --prefix=/usr/local/nginx \

--user=nginx \

--group=nginx \

--with-http_ssl_module \

--with-http_realip_module \

--with-http_flv_module \

--with-http_gunzip_module \

--with-http_gzip_static_module \

--with-http_stub_status_module \

--http-log-path=/data/logs/nginx/access.log \

--error-log-path=/data/logs/nginx/error.log

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添加启动项并做成服务:[root@localhost nginx-1.8.0]chmod +x /etc/rc.d/init.d/nginx

[root@localhost nginx-1.8.0]chkconfig --add nginx

[root@localhost nginx-1.8.0]chkconfig  nginx on

[root@localhost nginx-1.8.0]service nginx start

[root@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  ]

[root@localhost php]# ps -A|grep nginx

11724 ?        00:00:00 nginx

11725 ?        00:00:00 nginx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值