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

linux下安装apache2.4

本安装过程在centos6.3下测试通过.

?

1. 环境准备

yum install -y cmake autoconf libtool gcc gcc-c++

2.安装pcre

# 查看pcre是否安装: pcre-config -v
cd /opt
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.zip
unzip pcre-8.33.zip
cd pcre-8.33
./configure
make
make install

3. 安装httpd

cd /opt
wget http://mirrors.cnnic.cn/apache/apr/apr-1.4.8.tar.gz
wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.5.2.tar.gz
wget http://mirrors.cnnic.cn/apache/apr/apr-iconv-1.2.1.tar.gz
wget http://mirror.esocc.com/apache/httpd/httpd-2.4.4.tar.bz2

tar zxvf apr-1.4.8.tar.gz
tar zxvf apr-util-1.5.2.tar.gz
tar zxvf apr-iconv-1.2.1.tar.gz
tar jxvf httpd-2.4.4.tar.bz2

# 将httpd依赖的包放入httpd-2.4.4/srclib下并去掉版本号
mv apr-1.4.8 httpd-2.4.4/srclib/apr
mv apr-util-1.5.2 httpd-2.4.4/srclib/apr-util
mv apr-iconv-1.2.1 httpd-2.4.4/srclib/apr-iconv

cd httpd-2.4.4
./configure --with-included-apr --with-pcre
make
make install

vi /usr/local/apache2/conf/httpd.conf
启动: /usr/local/apache2/bin/apachectl -k start
停止:/usr/local/apache2/bin/apachectl -k stop

4. 安装php(先停止httpd)

# 查看php是否安装: php -v
# php依赖libxml2, 如果没有则先安装libxml2
cd /opt
wget ftp://xmlsoft.org/libxml2/libxml2-sources-2.9.0.tar.gz
tar zxvf libxml2-sources-2.9.0.tar.gz
cd libxml2-sources-2.9.0
./configure
make
make install

cd /opt
wget http://jp1.php.net/distributions/php-5.5.0.tar.bz2
tar jxvf php-5.5.0.tar.bz2
cd php-5.5.0
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
make
make install
cp php.ini-development /usr/local/lib/php.ini
vi /usr/local/lib/php.ini
??? 先查看? LoadModule php5_module modules/libphp5.so 是否存在, 如果存在则表示php已经作为apache的插件整合进来了
??? 然后在文件末尾添加以下配置,告知 Apache 将特定的扩展名解析成 PHP:
??? ??? <FilesMatch \.php$>
??? ??? ??? SetHandler application/x-httpd-php
??? ??? </FilesMatch>
最后重启apache
???
5. 安装mysql

先查看是否已经安装了mysql: rpm -qa|grep mysql 如果有则全部卸载(rpm -e --nodeps 完整包名), 不然新的mysql会安装失败
cd /opt
wget http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-server-5.6.12-1.el6.x86_64.rpm
wget http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-client-5.6.12-1.el6.x86_64.rpm
rpm -ivh MySQL-server-5.6.12-1.el6.x86_64.rpm
rpm -ivh MySQL-client-5.6.12-1.el6.x86_64.rpm

mysql5.6 初始密码不为空, 有一个随机密码
查看初始密码:more /root/.mysql_secret
使用初始密码登录后修改密码:set password=password("123456")