tengine + mysql + nginx + php
1、配置防火墙
vim /etc/sysconfig/iptables
# 允许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 DROP
备注:
添加配置需要防止于commit代码之间
重新启动:
/etc/init.d/iptables restart
2、安装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-devel
安装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.gz
# 下载Tengine
cd /usr/local/lib
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.gz
安装Tengine
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
*/
3、mysql安装
安装
yum install mysql mysql-server
启动
/etc/init.d/mysqld start
设置开机启动
chkconfig mysqld on
4、安装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)
5、配置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