CentOS6.4 64位下编译安装nginx1.5.11+php5.5.10+mariaDB5.5.36
时间:2014-10-01 00:27 来源:linux.it.net.cn 作者:it
1、安装Nginx-1.5.11:
mkdir -p /web/source
cd /web/source
yum install wget
yum install pcre
yum install openssl*
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers make
yum -y install gd gd2 gd-devel gd2-devel
/usr/sbin/groupadd www
/usr/sbin/useradd -g www www
ulimit -SHn 65535
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.32.tar.gz
tar zxvf pcre-8.32.tar.gz
cd pcre-8.32
./configure --prefix=/web/server/pcre
make && make install
cd ../
wget http://nginx.org/download/nginx-1.5.11.tar.gz
tar zxvf nginx-1.5.11.tar.gz
cd nginx-1.5.11
./configure --user=www --group=www --prefix=/web/server/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/web/source/pcre-8.32 --with-http_realip_module --with-http_image_filter_module
make
make install
cd ../
添加nginx的service启动脚本
#################nginx脚本开始位置#################
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
#
# 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: /Data/apps/nginx/conf/nginx.conf
nginxd=/Data/apps/nginx/sbin/nginx
nginx_config=/Data/apps/nginx/conf/nginx.conf
nginx_pid=/Data/apps/nginx/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 /var/run/nginx.pid
}
# reload nginx service functions.
reload() {
echo -n $"Reloading $prog: "
$nginxd -s reload
#if your nginx version is below 0.8, please use this command: "kill -HUP `cat ${nginx_pid}`"
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
################nginx脚本结束位置##################
service nginx start
2、安装 mariaDB-5.5.36:
yum install cmake
mkdir -p /web/data/mysql/data
wget https://downloads.mariadb.org/interstitial/mariadb-5.5.36/kvm-tarbake-jaunty-x86/mariadb-5.5.36.tar.gz
tar zxvf mariadb-5.5.36.tar.gz
cmake \
-DCMAKE_INSTALL_PREFIX=/web/server/mysql \
-DMYSQL_DATADIR=/web/data/mysql/data \
-DSYSCONFDIR=/etc
make && make install
chown -R mysql:mysql /web/server/mysql
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
yum install libaio
/web/server/mysql/scripts/mysql_install_db --basedir=/web/server/mysql --datadir=/web/data/mysql/data --user=mysql
cp support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
service mysql start --启动MySQL
sed -i "s#/usr/local/mysql#/web/server/mysql#g" /web/server/mysql/bin/mysqld_safe
3、安装PHP依赖库
mkdir -p /web/server/libs/
wget http://www.ijg.org/files/jpegsrc.v9.tar.gz
tar zxvf jpegsrc.v9.tar.gz
cd jpeg-9/
./configure --prefix=/web/server/libs --enable-shared --enable-static --prefix=/web/server/libs
make
make install
cd ../
wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.2.tar.gz
tar zxvf libpng-1.6.2.tar.gz
cd libpng-1.6.2/
./configure --prefix=/web/server/libs
make
make install
cd ../
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.12.tar.gz
tar zxvf freetype-2.4.12.tar.gz
cd freetype-2.4.12/
./configure --prefix=/web/server/libs
make
make install
cd ../
wget "http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz"
wget "http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz"
wget "http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz"
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure --prefix=/web/server/libs
make
make install
cd libltdl/
./configure --prefix=/web/server/libs --enable-ltdl-install
make
make install
cd ../../
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure --prefix=/web/server/libs
make
make install
cd ../
vi /etc/ld.so.conf
添加:
/web/server/libs/lib
然后:
ldconfig
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
export LDFLAGS="-L/web/server/libs/lib -L/usr/lib"
export CFLAGS="-I/web/server/libs/include -I/usr/include"
touch malloc.h
./configure --prefix=/web/server/libs --with-libmcrypt-prefix=/web/server/libs
make
make install
cd ../
4、编译安装PHP 5.5.10
wget http://www.php.net/get/php-5.5.10.tar.gz/from/tw2.php.net/mirror
tar zxvf php-5.5.10.tar.gz
cd php-5.5.10/
export LIBS="-lm -ltermcap -lresolv"
export DYLD_LIBRARY_PATH="/web/server/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
export LD_LIBRARY_PATH="/web/server/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
./configure --prefix=/web/server/php --with-config-file-path=/web/server/php/etc --with-mysql=/web/server/mysql --with-mysqli=/web/server/mysql/bin/mysql_config --with-iconv-dir --with-freetype-dir=/web/server/libs --with-jpeg-dir=/web/server/libs --with-png-dir=/web/server/libs --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt=/web/server/libs --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-opcache --with-pdo-mysql --enable-maintainer-zts
make
make install
cp php.ini-development /web/server/php/etc/php.ini
cd ../
ln -s /web/server/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
mv /web/server/php/etc/php-fpm.conf.default /web/server/php/etc/php-fpm.conf
添加php5.5.10的service启动脚本
vi /etc/init.d/php-fpm5.5
##############以下是启动脚本内容#####################
#!/bin/bash
exec=/Data/apps/php5.5/sbin/php-fpm
config=/Data/apps/php5.5/etc/php-fpm.conf
pidfile=/Data/apps/php5.5/var/run/php-fpm.pid
start(){
$exec -y $config || echo -n "start $exec -y $config failed."
}
stop(){
kill -QUIT `cat $pidfile` || echo "stop $exec failed."
}
reload(){
kill -HUP `cat $pidfile` || echo "reload $exec failed"
}
test(){
$exec -t -y $config
}
status(){
if [ -f $pidfile ] ; then
if [ -f /proc/`cat $pidfile` ] ; then
echo "$exec -y $config is running ..."
else
echo "$exec -y $config is stopped ..."
fi
fi
echo "$exec -y $config is stopped ..."
}
case "$1" in
start)
echo "starting $exec ok"
start
;;
stop)
echo "stopping $exec ok"
stop
;;
reload)
test
reload
;;
restart)
echo "restarting $exec ok"
stop
start
;;
test)
test
;;
*)
echo "usage: $0 {start|stop|restart|reload|status|test}"
exit 3
;;
esac
exit 0
###############脚本结束位置######################
chmod +x /etc/init.d/php-fpm5.5
service php-fpm5.5 start
5、编译安装PHP扩展
wget http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
tar zxvf autoconf-latest.tar.gz
cd autoconf-2.69/
./configure --prefix=/web/server/libs
make
make install
cd ../
wget http://pecl.php.net/get/memcache-2.2.7.tgz
tar zxvf memcache-2.2.7.tgz
cd memcache-2.2.7/
export PHP_
export PHP_
/web/server/php/bin/phpize
./configure --with-php-config=/web/server/php/bin/php-config
make
make install
cd ../
打开 /web/server/php/etc/php.ini 查找 ; extension_dir = "ext"
在其后增加一行:
extension = "memcache.so"
(责任编辑:IT)
1、安装Nginx-1.5.11:
mkdir -p /web/source
yum -y install gd gd2 gd-devel gd2-devel 添加nginx的service启动脚本
#################nginx脚本开始位置################# service nginx start 2、安装 mariaDB-5.5.36:
yum install cmake
3、安装PHP依赖库
mkdir -p /web/server/libs/
wget tar zxvf jpegsrc.v9.tar.gz cd jpeg-9/ ./configure --prefix=/web/server/libs --enable-shared --enable-static --prefix=/web/server/libs make make install cd ../ wget tar zxvf libpng-1.6.2.tar.gz cd libpng-1.6.2/ ./configure --prefix=/web/server/libs make make install cd ../ wget tar zxvf freetype-2.4.12.tar.gz cd freetype-2.4.12/ ./configure --prefix=/web/server/libs make make install cd ../ wget "http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz" wget "http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz" wget "http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz" tar zxvf libmcrypt-2.5.8.tar.gz cd libmcrypt-2.5.8/ ./configure --prefix=/web/server/libs make make install cd libltdl/ ./configure --prefix=/web/server/libs --enable-ltdl-install make make install cd ../../ tar zxvf mhash-0.9.9.9.tar.gz cd mhash-0.9.9.9/ ./configure --prefix=/web/server/libs make make install cd ../
vi /etc/ld.so.conf
添加:
/web/server/libs/lib
然后:
ldconfig
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/ export LDFLAGS="-L/web/server/libs/lib -L/usr/lib" export CFLAGS="-I/web/server/libs/include -I/usr/include" touch malloc.h ./configure --prefix=/web/server/libs --with-libmcrypt-prefix=/web/server/libs make make install cd ../ 4、编译安装PHP 5.5.10
wget 添加php5.5.10的service启动脚本
vi /etc/init.d/php-fpm5.5 exec=/Data/apps/php5.5/sbin/php-fpm config=/Data/apps/php5.5/etc/php-fpm.conf pidfile=/Data/apps/php5.5/var/run/php-fpm.pid start(){ $exec -y $config || echo -n "start $exec -y $config failed." } stop(){ kill -QUIT `cat $pidfile` || echo "stop $exec failed." } reload(){ kill -HUP `cat $pidfile` || echo "reload $exec failed" } test(){ $exec -t -y $config } status(){ if [ -f $pidfile ] ; then if [ -f /proc/`cat $pidfile` ] ; then echo "$exec -y $config is running ..." else echo "$exec -y $config is stopped ..." fi fi echo "$exec -y $config is stopped ..." } case "$1" in start) echo "starting $exec ok" start ;; stop) echo "stopping $exec ok" stop ;; reload) test reload ;; restart) echo "restarting $exec ok" stop start ;; test) test ;; *) echo "usage: $0 {start|stop|restart|reload|status|test}" exit 3 ;; esac exit 0 ###############脚本结束位置###################### chmod +x /etc/init.d/php-fpm5.5 service php-fpm5.5 start
wget
tar zxvf autoconf-latest.tar.gz cd autoconf-2.69/ ./configure --prefix=/web/server/libs make make install cd ../ wget tar zxvf memcache-2.2.7.tgz cd memcache-2.2.7/ export PHP_ export PHP_ /web/server/php/bin/phpize ./configure --with-php-config=/web/server/php/bin/php-config make make install cd ../
extension = "memcache.so"
|