tengine + mysql + nginx + php

tengine + mysql + nginx + phpphp

一、配置防火牆
vim /etc/sysconfig/iptableshtml

# 容許80端口經過防火牆
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
# 容許3306端口經過防火牆
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
# 容許21端口經過防火牆
-A INPUT -p tcp -m state -m tcp --dport 21 --state NEW -j ACCEPT
# 禁用ping
-A INPUT -p icmp --icmp-type 8 -s 0/0 -j DROPmysql

備註:
添加配置須要防止於commit代碼之間nginx

從新啓動:
/etc/init.d/iptables restartc++

二、安裝tengine
2.1 更新 yum
yum update
2.2 刪除系統自帶的軟件包
yum remove httpd* php*
編譯庫
yum install gcc-c++

安裝依賴庫
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-develweb

安裝ngx_cache_purge模塊
cd /usr/local
wget http://labs.frickle.com/files/ngx_cache_purge-2.1.tar.gz
tar -zxvf ngx_cache_purge-2.1.tar.gz
rm -rf ngx_cache_purge-2.1.tar.gzsql

# 下載Tengine
cd /usr/local/libvim

wget http://tengine.taobao.org/download/tengine-2.0.3.tar.gz
# 解壓,重命名,刪除tengine包
tar -zxvf tengine-2.0.3.tar.gz && rm -rf tengine-2.0.3.tar.gzbash

安裝Tenginetcp

cd tengine-2.0.3 && ./configure --add-module=/usr/local/ngx_cache_purge-2.1 --with-http_stub_status_module --prefix=/usr/local/nginx --user=nginx --group=nginx && make && make install

設置開機啓動
vi /etc/rc.d/init.d/nginx
編輯啓動文件添加下面內容
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# 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/logs/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 /usr/local/nginx/logs/nginx.pid
}
reload() {
echo -n $"Reloading $prog: "
#kill -HUP `cat ${nginx_pid}`
killproc $nginxd -HUP
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


#賦執行權限
chmod 775 /etc/rc.d/init.d/nginx

#設置開機啓動

chkconfig --level 012345 nginx on

添加用戶,組
/usr/sbin/groupadd -f nginx
/usr/sbin/useradd -g nginx nginx

/*
執行啓動報錯
[root@sz-pc182 tengine-2.0.3]# /etc/rc.d/init.d/nginx restart
Stopping nginx: [FAILED]
Starting nginx: nginx: [emerg] getpwnam("nginx") failed
[FAILED]
解決:

/usr/sbin/groupadd -f nginx
/usr/sbin/useradd -g nginx nginx
*/

三、mysql安裝
安裝
yum install mysql mysql-server
啓動
/etc/init.d/mysqld start
設置開機啓動
chkconfig mysqld on


四、安裝PHP5

 

 

# 根據提示輸入Y直到安裝完成

yum install php php-fpm

 

# 這裏選擇以上安裝包進行安裝,根據提示輸入Y回車

yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt

 

# 設置php-fpm開機啓動

chkconfig php-fpm on

 

# 啓動php-fpm (restart:重啓, stop:中止, start:啓動)

/etc/init.d/php-fpm (restart|stop|start)

service php-fpm (restart|stop|start)

 

五、配置nginx支持php

修改nginx 配置
vi /usr/local/nginx/conf/nginx.conf
去除
去除php前配置
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/php$fastcgi_script_name;
include fastcgi_params;
}

同時修改 fastcgi_param 路徑 ,將該路徑指向PHP 文件目錄

新建php文件

<?php phpinfo()?>

從新啓動 nginx

配置完成

參考http://www.cnblogs.com/hzh1990/p/3570453.html

相關文章
相關標籤/搜索