nginx作正向代理搭建bugfree

下載地址:

Nginx下載地址:http://download.csdn.net/detail/terrly88/9099117php

bugfree下載地址:http://download.csdn.net/detail/terrly88/9099133html

一、準備環境

yum -y install libmcrypt-devel mhash-devel libxslt-devel \mysql

libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \nginx

zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel \sql

ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel \數據庫

krb5 krb5-devel libidn libidn-devel openssl openssl-devel瀏覽器

二、安裝php-fpm

1)wget http://cn2.php.net/distributions/php-5.5.29.tar.gz(安裝wget命令:yum -y install wget)服務器

2)tar zvxf php-5.5.29.tar.gzcurl

3)cd php-5.5.29socket

4)./configure --prefix=/usr/local/php  --enable-fpm --with-mcrypt \

--enable-mbstring --disable-pdo --with-curl --disable-debug  --disable-rpath \

--enable-inline-optimization --with-bz2  --with-zlib --enable-sockets \

--enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex \

--with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli \

--with-gd --with-jpeg-dir

5)make && make install

6)添加www-data用戶

groupadd www-data

useradd -g www-data www-data

7)修改php-fpm.conf配置文件

a)         cd /usr/local/php

b)         cp etc/php-fpm.conf.default etc/php-fpm.conf

c)         vi etc/php-fpm.conf

d)         修改user = www-data     group = www-data

8)配置php.ini,目錄/etc/php.ini

enable_dl = On  是否使dl()有效.

cgi.force_redirect = 0 

cgi.fix_pathinfo=1 

fastcgi.impersonate = 1 

cgi.rfc2616_headers = 1 

allow_url_fopen = On是否容許把URLs看成http:.. 或把文件看成ftp

參考:http://blog.csdn.net/motian06/article/details/21172783

三、安裝Nginx步驟:

1)從http://nginx.org/download/上下載相應的版本

(或者wget http://nginx.org/download/nginx-1.9.4.tar.gz直接在Linux上用命令下載)

1)  解壓 tar -zxvf nginx-1.9.4.tar.gz

2)  yum -y install pcre-devel

3)  yum -y install openssl openssl-devel

4)  ./configure --prefix=/usr/local/nginx

5)  make && make install

6)  修改配置文件,以下:

7)  訪問瀏覽器

四、測試php文件是否能訪問

1)在/usr/local/nginx/html新建index.php文件,添加以下內容:

<?php

    echo "Hello";

?>

2)啓動服務php-fpm

3)重啓Nginx:./nginx –s reload

4)瀏覽器訪問http://你的服務器ip/index.php

結果:提示找不到文件

5)檢查Nginx配置文件,再次修改以下:

6)刷新瀏覽器

五、安裝bugfree

1)上傳bugfree.zip

2)解壓tar zxvf bugfree.zip

3)cd bugfree3.0.1

4)更名:mv bugfree3.0.1 bugfree

5)拷貝到/usr/local/nginx/html

6)打開瀏覽器http://ip:端口/bugfree/install

7)新建文件夾,並修改BugFile和bugfree的權限

8)刷新瀏覽器頁面

9)  點擊繼續

這裏注意服務器名寫localhost或者服務器的IP地址

數據庫名隨便

用戶名:root

密碼爲空,不要填寫

前綴:隨意

10)  點擊安裝

緣由:因爲我是在本機上用瀏覽器訪問的,而不是在安裝的虛擬機上,因此須要將localhost改成虛擬機的ip ,並填寫上數據庫密碼

11)  加上數據庫的密碼,再次點擊安裝

安裝成功

六、打開bugfree,並登錄

 

七、將Nginx添加爲系統服務

因爲出現service nginx restart nginx: 未被識別的服務

1)在/etc/init.d/目錄下編寫腳本,名爲nginx

#!/bin/sh
#
# 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:      /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 /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx

lockfile=/var/lock/subsys/nginx

start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    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
killall -9 nginx
}

restart() {
    configtest || return $?
    stop
    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
    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

2)修改權限和添加服務

cp nginx /etc/init.d/

chmod 755 /etc/init.d/nginx

chkconfig --add nginx

3)nginx啓動、中止、無間斷服務重啓

service nginx start

service nginx stop

service nginx reload

4)驗證下,再次執行service nginx restart命令

相關文章
相關標籤/搜索