日期:2014-05-16  浏览次数:20635 次

lamp (linux+apache+mysql+php) 环境安装脚本
这是网上流传的LAMP (Linux+Apache+MySQL+PHP) 环境安装的脚本,很简洁的脚本,省去了不少麻烦。shell中所有用到的软件包需要自己下载。安装完成之后需要注意的事:mysql 的两个帐号 mysql 和root 需要修改密码。

#!/bin/bash
echo "1.please input the mysql's path where will installed [default:/usr/local/mysql]"
read sqlread
if [ "$sqlread" != "" ];then
sql=$sqlread
else
sql="/usr/local/mysql"
fi

echo "2.please input the httpd's path where will installed [default:/usr/local/httpd]"
read httpdread
if [ "$httpdread" != "" ];then
httpd=$httpdread
else
httpd="/usr/local/httpd"
fi

echo "3.please input the php's path where will installed [default:/usr/local/php]"
read phpread
if [ "$phpread" != "" ];then
php=$phpread
else
php="/usr/local/php"
fi

mkdir -p $sql
mkdir -p $httpd
mkdir -p $php
useradd mysql
tar zxvf `ls | grep mysql | grep tar`
cd `ls -d */ | grep mysql`
./configure --prefix=$sql --enable-thread-safe-client --with-extra-charsets=gbk >> make >> make install
cp ./support-files/my-medium.cnf /etc/my.cnf
${sql}/bin/mysql_install_db --user=mysql
cd ..

tar zxvf `ls | grep http | grep tar`
cd `ls -d */ | grep http`
./configure --prefix=$httpd --enable-so --enable-rewrite >> make >> make install
cd ..

tar zxvf `ls | grep php | grep tar`
cd `ls -d */ | grep php`
./configure --prefix=$php --with-mysql=$sql --with-apxs2=${httpd}/bin/apxs --with-config-file-path=/usr/local/lib/ >> make >> make install
cp -f `ls | grep php.ini | head -1` /usr/local/lib/php.ini
cd ..

ln -s ${sql}/bin/* /usr/bin/
ln -s ${httpd}/bin/* /usr/bin/
ln -s ${php}/bin/* /usr/bin/
echo "${httpd}/bin/apachectl start" >> /etc/rc.d/rc.local
echo "${sql}/bin/mysqld_safe --user=mysql >" >> /etc/rc.d/rc.local
echo "AddType application/x-httpd-php .php" >> ${httpd}/conf/httpd.conf