为了账号安全,请及时绑定邮箱和手机立即绑定

源码安装apache+mysql+php

标签:
PHP

源码安装apache+mysql+php

#!/bin/sh

#byliangz at 2010-08-14

#环境:

#     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

functionaprinstall() {

       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

functionaprutilinstall() {

       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

functionpcreinstall() {

       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

functionapacheinstall() {

       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

functionmysqlinstall() {

       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

functionphpinstall() {

#     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

}

#建立测试页

functiontestinfo() {

cat >/usr/local/apache2/htdocs/test.php << END

<?php

\$link=mysql_connect('localhost','test','');

if(\$link)echo "Successful !!!";

mysql_close();

phpinfo();

?>

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

phpinstall

testinfo


点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消