红联Linux门户
Linux帮助

CentOS 5.0下自动安装MYSQL+APACHE+PHP+ZEND+GD

发布时间:2008-08-21 21:34:29来源:红联作者:Entertr
适合操作系统CENTOS 带YUM功能的LINUX

实验系统为:CENTOS5 最小化安装,就是用第一张CD装 不提示要第2张的那种

需要使用ROOT用户安装

希望能给大家帮助,本人初学LINUX,欢迎对文档进行2次更改发布

请先运行yum程序安装所需软件包(以下为标准的RPM包名称)

# yum install ntp vim-enhanced gcc gcc-c++ flex bison autoconf automake bzip2-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel kernel netconfig

脚本下载地址
# wget http://www.zzlan.cn/httpd/lmapz.sh

把脚本里的 yourpassword 更改成你的MYSQL_ROOT用户密码
# chmod 700 lmapz.sh
# ./lmapz.sh

脚本如下[code]#!/bin/bash
# BY ESUN
# QQ:667302
# MAIL:esunnet@qq.com
# BLOG:http://hi.baidu.com/667302/
# Please manual operation yum of before Operation.....

# yum install ntp vim-enhanced gcc gcc-c++ flex bison autoconf \
# automake bzip2-devel ncurses-devel libjpeg-devel libpng-devel \
# libtiff-devel freetype-devel pam-devel kernel netconfig

#########################################
ntpdate 210.72.145.44
mkdir /home/temp/
cd /home/temp/

wget http://www.openssl.org/source/openssl-0.9.8g.tar.gz
wget http://mirror.mcs.anl.gov/openssh/portable/openssh-4.7p1.tar.gz

wget http://apache.mirror.phpchina.com/httpd/httpd-2.2.6.tar.gz
wget http://cn2.php.net/distributions/php-5.2.4.tar.gz
wget http://download.discuz.net/env/mysql-5.0.27.tar.gz
wget http://downloads.phpchina.com/zend/optimizer/3.3.0/ZendOptimizer-3.3.0-linux-glibc21-i386.tar.gz

wget http://www.libgd.org/releases/oldreleases/gd-2.0.34.tar.gz
wget ftp://xmlsoft.org/libxml2/libxml2-2.6.29.tar.gz
wget http://jaist.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.8.tar.bz2
wget http://cronolog.org/download/cronolog-1.6.2.tar.gz

#########################################
# TAR
tar -xzvf httpd-2.2.6.tar.gz
tar -xzvf mysql-5.0.27.tar.gz
tar -xzvf php-5.2.4.tar.gz
tar -xzvf ZendOptimizer-3.3.0-linux-glibc21-i386.tar.gz

tar -xzvf gd-2.0.34.tar.gz
tar -xzvf libxml2-2.6.29.tar.gz
tar -xjvf libmcrypt-2.5.8.tar.bz2
tar -xzvf cronolog-1.6.2.tar.gz

tar -xzvf openssl-0.9.8g.tar.gz
tar -xzvf openssh-4.7p1.tar.gz


#########################################
# INSTALL GD
cd gd-2.0.34
./configure \
"--prefix=/usr/local/gd2"
make
make install

#########################################
# INSTALL LibXML2
cd ../libxml2-2.6.29
./configure \
"--prefix=/usr/local/libxml2"
make
make install
#########################################
# INSTALL LibMcrypt
cd ../libmcrypt-2.5.8
./configure \
"--prefix=/usr/local/libmcrypt"
make
make install

#########################################
# INSTALL cronolog
cd ../cronolog-1.6.2
./configure \
"--prefix=/usr/local/cronolog"
make
make install

#########################################
# INSTALL OpenSSL
cd ../openssl-0.9.8g
./configure \
"--prefix=/usr/local/openssl"
make
make test
make install

#########################################
# INSTALL OpenSSH
cd ../openssh-4.7p1
./configure \
"--prefix=/usr" \
"--with-pam" \
"--with-zlib" \
"--sysconfdir=/etc/ssh" \
"--with-ssl-dir=/usr/local/openssl" \
"--with-md5-passwords"
make
make install

#########################################
# INSTALL MYSQL
cd ../mysql-5.0.27

./configure \
"--prefix=/usr/local/mysql" \
"--localstatedir=/var/lib/mysql" \
"--with-comment=Source" \
"--with-server-suffix=-ESUN_SERVER" \
"--with-mysqld-user=mysql" \
"--without-debug" \
"--with-big-tables" \
"--with-charset=gbk" \
"--with-collation=gbk_chinese_ci " \
"--with-extra-charsets=all" \
"--with-pthread" \
"--enable-static" \
"--enable-thread-safe-client" \
"--with-client-ldflags=-all-static" \
"--with-mysqld-ldflags=-all-static" \
"--enable-assembler" \
"--without-isam" \
"--without-innodb" \
"--without-ndb-debug"
make
make install

# MYSQL ZERO
/usr/local/mysql/bin/mysql_install_db

# ADD MYSQL URL
useradd -M -o -r -d /var/lib/mysql -s /bin/bash -c "MySQL Server" -u 27 mysql

# copy mysql cnf
cp /usr/local/mysql/share/mysql/my-large.cnf /etc/my.cnf

# CHOWN MYSQL
chown -R mysql:mysql /var/lib/mysql

# add mysql init.d service
cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 3 mysqld on
service mysqld start

# Change mysql root password
/usr/local/mysql/bin/mysqladmin -uroot password 'yourpassword'

#########################################
#INSTALL apache
cd ../httpd-2.2.6

./configure \
"--prefix=/usr/local/apache2" \
"--with-included-apr" \
"--enable-so" \
"--enable-deflate=shared" \
"--enable-expires=shared" \
"--enable-rewrite=shared" \
"--enable-static-support" \
"--disable-userdir"

make
make install

# jianli ruanliejie
ln -s /usr/local/apache2/bin/apachectl /usr/sbin/apachectl
ln -s /usr/local/apache2/bin/httpd /usr/sbin/httpd
ln -s /usr/local/apache2/conf/httpd.conf /etc/httpd.conf

cp /home/temp/httpd-2.2.6/build/rpm/httpd.init /etc/init.d/httpd
chkconfig --add httpd
chkconfig --level 3 httpd on
service httpd start

# edit httpd.conf
sed -i 's/#ServerName www.example.com:80/ServerName 127.0.0.1/g' /etc/httpd.conf

# add index.php to default.
sed -i 's/ DirectoryIndex index.html/ DirectoryIndex index.php index.html index.htm/g' /etc/httpd.conf
echo "AddType application/x-httpd-php .php" >> /etc/httpd.conf

#########################################
# INSTALL PHP
cd ../php-5.2.4

./configure \
"--prefix=/usr/local/php" \
"--with-apxs2=/usr/local/apache2/bin/apxs" \
"--with-config-file-path=/usr/local/php/etc" \
"--with-mysql=/usr/local/mysql" \
"--with-libxml-dir=/usr/local/libxml2" \
"--with-gd=/usr/local/gd2" \
"--with-jpeg-dir" \
"--with-png-dir" \
"--with-bz2" \
"--with-freetype-dir" \
"--with-iconv-dir" \
"--with-zlib-dir " \
"--with-openssl=/usr/local/openssl" \
"--with-mcrypt=/usr/local/libmcrypt" \
"--enable-soap" \
"--enable-gd-native-ttf" \
"--enable-memory-limit" \
"--enable-ftp" \
"--enable-mbstring" \
"--enable-exif" \
"--disable-ipv6" \
"--disable-cgi" \
"--disable-cli"

make
make install
cp php.ini-dist /usr/local/php/etc/php.ini
ln -s /usr/local/php/etc/php.ini /etc/php.ini

#########################################
# INSTALL ZendOptimizer
cd ../ZendOptimizer-3.3.0-linux-glibc21-i386
./install

echo "LINUX+MYSQL+APACHE2+PHP5+ZEND INSTALL OK"

#rm -rf /home/temp/[/code]出处:http://hi.baidu.com/667302/
文章评论

共有 2 条评论

  1. cdq502 于 2011-03-26 00:33:20发表:

    无敌!太好了!谢谢!楼主!

  2. cqs510 于 2011-03-18 10:45:54发表:

    杀花