首页 > 服务与支持 > 源码安装lamp

源码安装lamp

源码安装apache+mysql+php
#环境:
# 1. CentOS5.5或RHEL5.4,配置好IP地址,主机名等信息
# 3. 必须的软件:gcc,gcc-c++,make,unzip,openssl-devel,libxml2-devel
# yum install -y gcc-c++
# yum install -y make
# yum install -y unzip
# yum install -y openssl-devel
# yum install -y libxml2-devel
# 4. 关闭selinux—vi /etc/selinux/config—修改“SELINUX=disabled”
# 5. 禁用iptables—service iptables stop
#1.apr: http://apache.freelamp.com/apr/apr-1.4.2.tar.gz
#2.apr-util: http://apache.freelamp.com/apr/apr-util-1.3.9.tar.gz
#3.pcre: http://sourceforge.net/projects/pcre/files/
#4.apache: http://labs.renren.com/apache-mirror/httpd/httpd-2.3.6.tar.gz
#5.mysql: http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.48-linux-i686-glibc23.tar.gz/from/http://ftp.iij.ad.jp/pub/db/mysql/
#6.php: http://cn2.php.net/get/php-5.3.2.tar.gz/from/cn.php.net/mirror
#1. 安装apr
function aprinstall() {
tar -xzf apr-1.4.2.tar.gz
cd apr-1.4.2
./configure –prefix=/usr/local/apr
make && make install
cd .. && rm -rf apr-1.4.2
}
#2.安装apr-util
function aprutilinstall() {
tar -xzf apr-util-1.3.9.tar.gz
cd apr-util-1.3.9
./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr
make && make install
cd .. && rm -rf apr-util-1.3.9
}
#3. 安装pcre
function pcreinstall() {
unzip pcre-8.10.zip
cd pcre-8.10
./configure –prefix=/usr/local/pcre
make && make install
cd .. && rm -rf pcre-8.10
}
#4. 安装apache
function apacheinstall() {
tar -xzf httpd-2.3.6.tar.gz
cd httpd-2.3.6
./configure –prefix=/usr/local/apache2 \
–enable-so –enable-rewrite –enable-cgi \
–enable-suexec –enable-ssl –enable-charset-lite \
–with-apr=/usr/local/apr \
–with-apr-util=/usr/local/apr-util \
–with-pcre=/usr/local/pcre
make && make install
cd .. && rm -rf httpd-2.3.6
cp -pf /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
service httpd start
echo “service httpd start” >> /etc/rc.local
}
#5. 安装mysql
function mysqlinstall() {
tar -xzf mysql-5.1.48-linux-i686-glibc23.tar.gz -C /usr/local/
pushd /usr/local/
mv mysql-5.1.48-linux-i686-glibc23/ mysql
useradd -M -s /sbin/nologin mysql
cd mysql
cp support-files/my-medium.cnf /etc/my.cnf
chown -R mysql.mysql .
./scripts/mysql_install_db –user=mysql
chown -R root .
chown -R mysql data
cp support-files/mysql.server /etc/init.d/mysqld
chmod a+x /etc/init.d/mysqld
chkconfig –add mysqld
chkconfig –level 35 mysqld on
chmod a+x /etc/init.d/mysqld
chkconfig –add mysqld
chkconfig –level 35 mysqld on
echo “/usr/local/mysql/lib” >> /etc/ld.so.conf
ldconfig
./bin/mysqld_safe –user=mysql &
mysqladmin -u root password “P@ssw0rd”
popd
}
#6. 安装PHP
function phpinstall() {
#yum install -y libxml2-devel
tar -xzf php-5.3.2.tar.gz
cd php-5.3.2
./configure –prefix=/usr/local/php5 \
–enable-mbstring –enable-sockets \
–with-apxs2=/usr/local/apache2/bin/apxs \
–with-mysql=/usr/local/mysql \
–with-config-file-path=/usr/local/php5
make && make install
cp php.ini-production /usr/local/php5/php.ini
./build/shtool install -c ext/phar/phar.phar /usr/local/php5/bin
ln -s -f /usr/local/php5/bin/phar.phar /usr/local/php5/bin/phar
cd .. && rm -rf php-5.3.2
echo “ServerName `hostname`” >> /usr/local/apache2/conf/httpd.conf
echo “AddTyep application/x-httpd-php .php” >> /usr/local/apache2/conf/httpd.conf
echo “AddType image/x-icon .ico” >> /usr/local/apache2/conf/httpd.conf
echo “DirectoryIndex index.php” >> /usr/local/apache2/conf/httpd.conf
service httpd restart
}
#建立测试页
function testinfo() {
cat > /usr/local/apache2/htdocs/test.php < < END
END
_IPADDR=`grep “IPADDR” /etc/sysconfig/network-scripts/ifcfg-eth0 | cut -d “=” -f 2`
echo “请打开浏览器访问
http://$_IPADDR/test.php
如果显示Successful并显示PHP,则安装成功!”
}
aprinstall
aprutilinstall
pcreinstall
apacheinstall
mysqlinstall



go top