安装Tengine php mysql
系统环境:
[root@web02 soft]# lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 5.9 (Final)
Release: 5.9
Codename: Final
[root@web02 soft]# cat /etc/redhat-release
CentOS release 5.9 (Final)
[root@web02 soft]# uname -a
Linux web02 2.6.18-348.el5 #1 SMP Tue Jan 8 17:53:53 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
系统采用163 epel源,已经清除32位包
软件版本:
Tengine.1.4.4
php 5.3.24
mysql 5.5.31
libiconv 1.14
libmcrypt 2.5.8
mhash 0.9.9.9[root@web02 ~]# mkdir soft
[root@web02 ~]# cd soft
[root@web02 soft]# wget http://tengine.taobao.org/download/tengine-1.4.4.tar.gz
[root@web02 soft]# wget http://cn2.php.net/get/php-5.3.24.tar.gz/from/this/mirror
[root@web02 soft]# wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.31-linux2.6-x86_64.tar.gz/from/http://cdn.mysql.com/
[root@web02 soft]# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
[root@web02 soft]# wget http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz/download
[root@web02 soft]# wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
安装Tengine
[root@web02 soft]# useradd www -s /sbin/nologin
[root@web02 soft]# yum -y install pcre* gcc* libxml2-devel gd-devel openssl-devel curl*
[root@web02 soft]# tar xf tengine-1.4.4.tar.gz
[root@web02 soft]# cd tengine-1.4.4
[root@web02 tengine-1.4.4]# ./configure --user=www --group=www --prefix=/usr/local/tengine --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --with-http_upstream_check_module --with-pcre
[root@web02 tengine-1.4.4]# make && make install
[root@web02 tengine-1.4.4]# vim /usr/local/tengine/conf/fcgi.conf
if ($request_filename ~* (.*)\.php) {
set $php_url $1;
}
if (!-e $php_url.php) {
return 403;
}
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with--enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
安装mysql
[root@web02 soft]# useradd mysql -s /sbin/nologin
[root@web02 soft]# tar xf mysql-5.5.31-linux2.6-x86_64.tar.gz -C /usr/local/
[root@web02 local]# ln -sv mysql-5.5.31-linux2.6-x86_64/ mysql
create symbolic link `mysql' to `mysql-5.5.31-linux2.6-x86_64/'
[root@web02 local]# cd mysql
[root@web02 mysql]# scripts/mysql_install_db --user=mysql
[root@web02 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@web02 mysql]# cp support-files/my-huge.cnf /etc/my.cnf
[root@web02 mysql]# /etc/init.d/mysqld start
Starting MySQL... [ OK ]
[root@web02 mysql]# echo 'PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
[root@web02 mysql]# mysql
安装php
在安装之前呢 我们需要安装libiconv libmcrypt mhash
[root@web02 soft]# tar xf libiconv-1.14.tar.gz
[root@web02 soft]# tar xf mhash-0.9.9.9.tar.gz
[root@web02 soft]# tar xf php-5.3.24.tar.gz
[root@web02 soft]# tar xf libmcrypt-2.5.8.tar.gz
[root@web02 soft]# cd libiconv-1.14
[root@web02 libiconv-1.14]# ./configure
[root@web02 libiconv-1.14]# make && make install
[root@web02 libiconv-1.14]# cd ../mhash-0.9.9.9
[root@web02 mhash-0.9.9.9]# ./configure
[root@web02 mhash-0.9.9.9]# make && make install
[root@web02 mhash-0.9.9.9]# cd ../libmcrypt-2.5.8
[root@web02 libmcrypt-2.5.8]# ./configure
[root@web02 libmcrypt-2.5.8]# make && make install
[root@web02 libmcrypt-2.5.8]# cd libltdl/
[root@web02 libltdl]# ./configure --with-gmetad --enable-gexec --enable-ltdl-install
[root@web02 libltdl]# make && make install
[root@web02 libltdl]# vim /etc/ld.so.conf.d/lib.conf
/usr/local/lib/
/usr/local/mysql/lib
[root@web02 libltdl]# ldconfig
正式安装php
[root@web02 soft]# cd php-5.3.24
[root@web02 php-5.3.24]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/etc/php.d --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-soap --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --with-gettext
[root@web02 php-5.3.24]# make ZEND_EXTRA_LIBS='-liconv'
[root@web02 php-5.3.24]# make install
[root@web02 php-5.3.24]# cp php.ini-production /usr/local/php/etc/php.ini
[root@web02 php-5.3.24]# cd /usr/local/php/etc/
[root@web02 etc]# cp php-fpm.conf.default php-fpm.conf
[root@web02 etc]# vim php-fpm.conf
pid = /usr/local/php/var/run/php-fpm.pid
user = www
group = www
添加Tengine让其支持php[root@web02 etc]# vim /usr/local/tengine/conf/nginx.conf
server
{
listen 80;
server_name www.yoursite.com;
indexindex.htm index.html index.php;
root /var/www/html/yoursite;
error_page 404 = http://www.yoursite.com/404.html;
location ~ .*\.(php|php5)?$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
}
这样就支持php了
附: php启动脚本 Tengine启动脚本
php-fpm启动脚本
#! /bin/sh
### BEGIN INIT INFO
# Provides: php-fpm
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts php-fpm
# Description: starts the PHP FastCGI Process Manager daemon
### END INIT INFO
prefix=/usr/local/php
exec_prefix=${prefix}
php_fpm_BIN=${exec_prefix}/sbin/php-fpm
php_fpm_CONF=${prefix}/etc/php-fpm.conf
php_fpm_PID=${prefix}/var/run/php-fpm.pid
php_opts="--fpm-config $php_fpm_CONF"
wait_for_pid () {
try=0
while test $try -lt 35 ; do
case"$1"in
'created')
if [ -f "$2" ] ; then
try=''
break
fi
;;
'removed')
if [ ! -f "$2" ] ; then
try=''
break
fi
;;
esac
echo -n .
try=`expr $try + 1`
sleep 1
done
}
case"$1"in
start)
echo -n "Starting php-fpm "
$php_fpm_BIN $php_opts
if [ "$?" != 0 ] ; then
echo " failed"
exit 1
fi
wait_for_pid created $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
stop)
echo -n "Gracefully shutting down php-fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -QUIT `cat $php_fpm_PID`
wait_for_pid removed $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed. Use force-quit"
exit 1
else
echo " done"
fi
;;
force-quit)
echo -n "Terminating php-fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -TERM `cat $php_fpm_PID`
wait_for_pid removed $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n "Reload service php-fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -USR2 `cat $php_fpm_PID`
echo " done"
;;
*)
echo "Usage: $0 {start|stop|force-quit|restart|reload}"
exit 1
;;
esac
nginx启动脚本
#! /bin/sh
# chkconfig: 2345 55 25
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and
# run 'update-rc.d -f nginx defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: 'chkconfig --add nginx'
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/local/tengine/sbin/$NAME
CONFIGFILE=/usr/local/tengine/conf/$NAME.conf
PIDFILE=/usr/local/tengine/logs/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
set -e
[ -x "$DAEMON" ] || exit 0
do_start() {
$DAEMON -c $CONFIGFILE || echo -n "nginx already running"
}
do_stop() {
kill -INT `cat $PIDFILE` || echo -n "nginx not running"
}
do_reload() {
kill -HUP `cat $PIDFILE` || echo -n "nginx can't reload"
}
case"$1"in
start)
echo -n "Starting $DESC: $NAME"
do_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
do_stop
echo "."
;;
reload|graceful)
echo -n "Reloading $DESC configuration..."
do_reload
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
do_stop
do_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac
exit 0