[转帖]Apche+MySQL+PHP整合安装脚本
Apche+MySQL+PHP整合安装脚本
http://www.chinaunix.net 作者:Nanu
这个脚本可以无需人工干预的完成L.A.M.P的整合工作。
该脚本适用于整合[color=red:271853b841]源码包方式的apache2.0.5x,php4.0.x[/color:271853b841]和[color=red:271853b841]已编译好的(Binary版本)的MySQL4.0.2x[/color:271853b841]。
注意,以上三个包最好从各自的官方站点下载,并且[color=red:271853b841]下载后最好不要改变文件名[/color:271853b841]!
使用方法:
=====
1、将下载好的3个包和本安装脚本(install_lamp.sh)放置在
/home/Nanu下。放置的位置随意,但注意必须把3个包和本安装脚本放在同一目录!
2、Apache和PHP的./configure部分根据需要换成你的编译参数;
3、执行install_lamp.sh;
4、安装完成后,MySQL的root密码默认保存在/usr/local/mysql/passwd.root中,以备忘记。
脚本代码:
=====
[code:1:271853b841]#!/bin/bash
# Mysql4.0.x Start
/bin/tar xzvf mysql*4.0.*.tar.gz
/bin/rm -f mysql*4.0.*.tar.gz
/usr/sbin/useradd mysql
/bin/mv mysql*4.0* /usr/local/mysql
/usr/local/mysql/scripts/mysql_install_db --user=mysql
/bin/chown -R root /usr/local/mysql/.
/bin/chown -R mysql /usr/local/mysql/data
/bin/chgrp -R mysql /usr/local/mysql/.
/bin/cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf
/usr/local/mysql/bin/mysqld_safe --user=mysql &
echo "Please Set Your MySQL root Password:"
read password
/usr/local/mysql/bin/mysqladmin -u root password $password
/bin/touch /usr/local/mysql/passwd.root
echo $password > /usr/local/mysql/passwd.root
/usr/local/mysql/bin/mysqladmin -u root --password=$password shutdown
/bin/cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
/sbin/chkconfig --add mysqld
/etc/rc.d/init.d/mysqld start
# MySQL4.0.x End
# Apache2.0.x Start
/bin/tar xzvf httpd-2.0.*.tar.gz
cd httpd-2.0.*
./configure --prefix=/usr/local/apache --mandir=/usr/share/man --enable-mods-shared=all --enable-so
make
make install
echo "AddType application/x-httpd-php .php" >> /usr/local/apache/conf/httpd.conf
sed -i ';s/"DirectoryIndex index.html index.html.var"/"DirectoryIndex index.htm index.html index.php index.html.var"/g'; /usr/local/apache/conf/httpd.conf
/usr/local/apache/bin/apachectl -k start
# Apache2.0.x End
# PHP4.0.x Start
/bin/tar xzvf php-*.tar.gz
cd php-*
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --mandir=/usr/share/man --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php/etc
make
make install
/bin/cp php.ini-recommended /etc/php.ini
sed -i ';s/"register_globals = Off"/"register_globals = On"/g'; /etc/php.ini
/usr/local/apache/bin/apachectl -k restart
# PHP4.0.x End[/code:1:271853b841]
脚本中肯定还有不完善的地方,水平所限。还请各位多多指教。
--------------------------------------------------------------------------------
Raylzw 回复于:2005-07-23 19:31:54
对我很有用..谢谢..
--------------------------------------------------------------------------------
platinum 回复于:2005-07-23 23:16:28
[quote:1147b363ec]
echo "Please Set Your MySQL root Password:"
read password
[/quote:1147b363ec]
可改为
[quote:1147b363ec]
read -p "Please Set Your MySQL root Password: " password
[/quote:1147b363ec]
--------------------------------------------------------------------------------
huifei 回复于:2005-07-24 12:29:43
/bin/tar xzvf php-*.tar.gz
cd php-*.tar.gz
写错了吧。
--------------------------------------------------------------------------------
platinum 回复于:2005-07-24 12:38:59
[quote:b09fc13d46="huifei"]/bin/tar xzvf php-*.tar.gz
cd php-*.tar.gz
写错了吧。[/quote:b09fc13d46]
应该事 cd php-*
--------------------------------------------------------------------------------
unixer2i 回复于:2005-07-24 23:04:06
[quote:98d14af099="Nanu"]
这个脚本可以无需人工干预的完成L.A.M.P的整合工作。
该脚本适用于整合源码包方式的apache2.0.5x,php4.0.x和已编译好的(Binary版本)的MySQL4.0.2x。
注意,以上三个包最好从各自的官方站点下载,并且下载后最好不要改变文件名!
脚本中肯定还有不完善的地方,水平所限。还请各位多多指教。[/quote:98d14af099]
我在这三个软件的官方网站找到:apache2.0.54 , php4.4.0 mysql4.0.25。能否用这个LAMP整合自动安装脚本进行快速安装?如有答案,请给一个说明即可。
--------------------------------------------------------------------------------
keelort 回复于:2005-07-25 08:39:16
本脚本自动下载并编译安装 Apache v2.0.54 + PHP v4.4.0 + MySQL v4.0.25 及相关软件,并自动修改 mysql 最大连接数 100 为 1000,自动加入 Apache 及 MySQL 自动启动。
参考: http://bbs.micronsky.net/viewtopic.php?t=160
测试系统:Debian Linux Sarge 3.1r0
作者: keelort
网站: http://www.micronsky.net
#!/bin/bash
rm -R bw_mod-0.6 > /dev/null
rm -R ClibPDF > /dev/null
rm -R curl-7.14.0 > /dev/null
rm -R freetype-2.1.10 > /dev/null
rm -R gd-2.0.33 > /dev/null
rm -R httpd-2.0.54 > /dev/null
rm -R jpeg-6b > /dev/null
rm -R libiconv-1.9.2 > /dev/null
rm -R libpng-1.2.8 > /dev/null
rm -R mod_dosevasive > /dev/null
rm -R mod_limitipconn-0.22 > /dev/null
rm -R mysql-4.0.25 > /dev/null
rm -R openssl-0.9.7g > /dev/null
rm -R php-4.4.0 > /dev/null
rm -R ZendOptimizer-2.5.10-linux-glibc21-i386 > /dev/null
rm -R zlib-1.2.2 > /dev/null
##### Download #####
echo "[Downloading...]";echo -e "\a";sleep 6
echo "[1/16]";wget -N http://www.apache.org/dist/httpd/httpd-2.0.54.tar.gz
echo "[2/16]";wget -N http://cn.php.net/distributions/php-4.4.0.tar.gz
echo "[3/16]";wget -N http://download.softagency.net/MySQL/Downloads/MySQL-4.0/mysql-4.0.25.tar.gz
echo "[4/16]";wget -N http://downloads.zend.com/optimizer/2.5.10/ZendOptimizer-2.5.10-linux-glibc21-i386.tar.gz
echo "[5/16]";wget -N http://curl.haxx.se/download/curl-7.14.0.tar.gz
echo "[6/16]";wget -N http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.9.2.tar.gz
echo "[7/16]";wget -N http://www.openssl.org/source/openssl-0.9.7g.tar.gz
echo "[8/16]";wget -N http://savannah.nongnu.org/download/freetype/freetype-2.1.10.tar.gz
echo "[9/16]";wget -N http://www.boutell.com/gd/http/gd-2.0.33.tar.gz
echo "[10/16]";wget -N http://www.fastio.com/clibpdf202r1.tar.gz
echo "[11/16]";wget -N http://www.ijg.org/files/jpegsrc.v6b.tar.gz
echo "[12/16]";wget -N http://switch.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.8.tar.gz
echo "[13/16]";wget -N http://www.zlib.net/zlib-1.2.2.tar.gz
echo "[14/16]";wget -N http://dominia.org/djao/limit/mod_limitipconn-0.22.tar.gz
echo "[15/16]";wget -N http://www.ivn.cl/apache/bw_mod-0.6.tgz
echo "[16/16]";wget -N http://www.nuclearelephant.com/projects/dosevasive/mod_dosevasive_1.10.tar.gz
##### Decompression #####
echo "[Decompressing...]";echo -e "\a";sleep 6
for i in `ls *.gz`;do tar zxvf $i; done;
for i in `ls *.tgz`;do tar zxvf $i; done;
mkdir /data
mkdir /data/mysql-db
mkdir /data/vhosts
mkdir /data/vhosts/0
mkdir /server
mkdir /server/conf
mkdir /server/conf/vhosts
mkdir /server/conf/vhosts-ssl
##### zlib #####
echo "[Installing zlib...]";echo -e "\a";sleep 6
cd zlib-1.2.2
./configure
make && make install
cd ..
rm -R zlib-1.2.2
##### OpenSSL #####
echo "[Intalling OpenSSL...]";echo -e "\a";sleep 6
cd openssl-0.9.7g
./config --prefix=/usr/local \
shared \
zlib
make && make install
cd ..
rm -R openssl-0.9.7g
##### MySQL #####
echo "[Installing MySQL...]";echo -e "\a";sleep 6
cd mysql-4.0.25
sed -i ';s/\&max_connections, 0, GET_ULONG, REQUIRED_ARG, 100,/\&max_connections, 0, GET_ULONG, REQUIRED_ARG, 1000,/g'; ./sql/mysqld.cc
apt-get install libncurses5-dev
groupadd mysql
useradd -g mysql mysql
./configure \
--prefix=/server/mysqld \
--sysconfdir=/server/conf \
--without-isam \
--without-debug \
--enable-assembler \
--with-unix-socket-path=/tmp/mysql.sock \
--with-mysqld-user=mysql \
--with-extra-charset=all \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \
--localstatedir=/data/mysql-db
make && make install
/server/mysqld/bin/mysql_install_db --user=mysql
chown -R mysql /data/mysql-db
chgrp -R mysql /data/mysql-db
chown -R root /server/mysqld
chgrp -R mysql /server/mysqld
cp /server/mysqld/share/mysql/my-medium.cnf /server/conf/my.cnf
/server/mysqld/share/mysql/mysql.server start
sleep 3
/server/mysqld/bin/mysqladmin -u root password 1029384756
cd ..
rm -R mysql-4.0.25
##### Apache2 #####
echo "[Installing Apache2...]";echo -e "\a";sleep 6
cd httpd-2.0.54
./configure --prefix=/server/httpd \
--enable-so \
--with-mysql=/server/mysqld \
--enable-cgi \
--enable-cgid \
--with-config-file-path=/server/conf \
--enable-track-vars \
--enable-mods-shared=all \
--enable-cache \
--enable-disk-cache \
--enable-mem-cache \
--enable-rewrite \
--with-mpm=worker \
--enable-mime-magic \
--enable-static-support \
--enable-static-htpasswd \
--enable-static-htdigest \
--enable-static-rotatelogs \
--enable-static-logresolve \
--enable-static-htdbm \
--enable-static-ab \
--enable-static-checkgid \
--with-ssl=/usr/local \
--enable-ssl
make && make install
mkdir /server/conf/vhosts
mkdir /server/conf/vhosts-ssl
mkdir /data/vhosts
mkdir /data/vhosts/localhost
mv /server/httpd/conf/* /server/conf
rm -R /server/httpd/conf
ln -s /server/conf /server/httpd/conf
cd ..
##### FreeType #####
echo "[Installing FreeType...]";echo -e "\a";sleep 6
cd freetype-2.1.10
./configure --prefix=/usr/local
make && make install
cd ..
rm -R freetype-2.1.10
##### LibPNG #####
echo "[Installing LibPNG...]";echo -e "\a";sleep 6
cd libpng-1.2.8
cp scripts/makefile.linux makefile
make test
make install
cd ..
rm -R libpng-1.2.8
##### Jpeg #####
echo "[Installing Jpeg...]";echo -e "\a";sleep 6
cd jpeg-6b
mkdir /usr/local/man/man1
./configure --prefix=/usr/local --enable-shared --enable-static
make && make install
cd ..
rm -R jpeg-6b
##### GD Library #####
echo "[Installing GD Library...]";echo -e "\a";sleep 6
cd gd-2.0.33
./configure --prefix=/usr/local \
--with-jpeg=/usr/local \
--with-freetype=/usr/local \
--with-png \
--with-zlib
make && make install
cd ..
rm -R gd-2.0.33
##### ClibPDF #####
echo "[Installing ClibPDF...]";echo -e "\a";sleep 6
cd ClibPDF/source
cp Makefile.Linux makefile
make && make install
cd ../../
rm -R ClibPDF
##### LibIconv #####
echo "[Installing LibIconv...]";echo -e "\a";sleep 6
cd libiconv-1.9.2
./configure --prefix=/usr/local
make && make install
cd ..
rm -R libiconv-1.9.2
##### cURL #####
echo "[Installing cURL...]";echo -e "\a";sleep 6
cd curl-7.14.0
./configure --prefix=/usr/local
make && make install
cd ..
rm -R curl-7.14.0
##### PHP #####
echo "[Installing PHP...]";echo -e "\a";sleep 6
cd php-4.4.0
./configure --prefix=/server/php \
--with-apxs2=/server/httpd/bin/apxs \
--with-gd=/usr/local \
--enable-gd \
--enable-gd-native-ttf \
--with-jpeg-dir=/usr/local \
--with-png \
--with-ttf \
--with-zlib \
--with-zlib-dir \
--with-freetype-dir=/usr/local \
--enable-magic-quotes \
--with-mysql=/server/mysqld \
--with-mysql-sock=/tmp/mysql.sock \
--with-iconv=/usr/local \
--with-curl=/usr/local \
--with-mbstring \
--enable-mbstring \
--enable-track-vars \
--enable-force-cgi-redirect \
--enable-ftp \
--with-config-file-path=/server/conf \
--with-openssl=/usr/local \
--with-openssl-dir=/usr/local \
--with-cpdflib=/usr/local \
--with-pear=/server/php/pear
make && make install
cp php.ini-dist /server/conf/php.ini
cd ..
rm -R php-4.4.0
#########################################################################
##### mod_deflate #####
echo "[Installing mod_deflate...]";echo -e "\a";sleep 6
/server/httpd/bin/apxs -i -c -a httpd-2.0.54/modules/filters/mod_deflate.c
rm -R httpd-2.0.54
##### mod_limitipconn #####
echo "[Installing mod_limitipconn...]";echo -e "\a";sleep 6
/server/httpd/bin/apxs -i -c -a mod_limitipconn-0.22/mod_limitipconn.c
rm -R mod_limitipconn-0.22
##### Bandwidth Module #####
echo "[Installing Bandwidth Module...]";echo -e "\a";sleep 6
/server/httpd/bin/apxs -i -c -a bw_mod-0.6/bw_mod-0.6.c
rm -R bw_mod-0.6
##### Apache DoS Evasive Maneuvers Module #####
echo "[Installing Apache DoS Evasive Maneuvers Module...]";echo -e "\a";sleep 6
/server/httpd/bin/apxs -i -c -a mod_dosevasive/mod_dosevasive20.c
rm -R mod_dosevasive
##### Configure Install #####
echo "[Configuring...]";echo -e "\a";sleep 6
sed -i ';s/\#ExtendedStatus On/ExtendedStatus On/g'; /server/conf/httpd.conf
sed -i ';s/\#NameVirtualHost \*/NameVirtualHost \*/g'; /server/conf/httpd.conf
cp /server/httpd/bin/apachectl /etc/init.d/httpd
cp /server/mysqld/share/mysql/mysql.server /etc/init.d/mysqld
##### Run Time #####
cp -R /server/conf /server/conf-bak
sed -i ';s/ServerAdmin you\@example\.com/\#ServerAdmin you\@example\.com/g'; /server/conf/httpd.conf
sed -i ';s/\/server\/httpd\/htdocs/\/data\/vhosts\/localhost/g'; /server/conf/httpd.conf
sed -i ';s/Options Indexes FollowSymLinks/Options FollowSymLinks/g'; /server/conf/httpd.conf
sed -i ';s/DirectoryIndex index.html index.html.var/DirectoryIndex index.html index.htm index.php/g'; /server/conf/httpd.conf
sed -i ';s/AddHandler cgi-script \.cgi/AddHandler cgi-script \.cgi \.pl/g'; /server/conf/httpd.conf
sed -i ';s/UserDir public_html/\#UserDir public_html/g'; /server/conf/httpd.conf
ln -s /etc/init.d/httpd /etc/rc2.d/S20httpd
ln -s /etc/init.d/httpd /etc/rc3.d/S20httpd
ln -s /etc/init.d/httpd /etc/rc4.d/S20httpd
ln -s /etc/init.d/httpd /etc/rc5.d/S20httpd
ln -s /etc/init.d/mysqld /etc/rc2.d/S20mysqld
ln -s /etc/init.d/mysqld /etc/rc3.d/S20mysqld
ln -s /etc/init.d/mysqld /etc/rc4.d/S20mysqld
ln -s /etc/init.d/mysqld /etc/rc5.d/S20mysqld
echo "[Ending...]"
echo $SECONDS "Seconds"
|