linux php5.4 mysql安装_CentOS下源码安装Apache2.4+PHP5.4+MySQL5.5

一、准备(把所有的源文件放在‘/home/username’目录下)

apr http://mirror.bjtu.edu.cn/apache/apr/apr-1.4.6.tar.gz

apr-util http://mirror.bjtu.edu.cn/apache/apr/apr-util-1.4.1.tar.gz

pcre ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.zip

httpd http://mirror.bjtu.edu.cn/apache/httpd/httpd-2.4.1.tar.gz

php5.4 http://cn2.php.net/get/php-5.4.0.tar.gz/from/this/mirror

mysql http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.21.tar.gz/from/http://mysql.spd.co.il/

首先执行

# yum install gcc gcc-c++ glibc glibc-devel gd gd-devel zlib zlib-devel libtool-ltdl-devel flex autoconf automake

二、安装

2.1 安装 apache

2.1.1安装 apr

# cd /home/username

# tar zxf apr-1.4.6.tar.gz

# cd apr-1.4.6/

# ./configure --prefix=/usr/local/apr

# make

# make install

2.1.2安装 apr-util

# cd /home/username

# tar zxf apr-util-1.4.1.tar.gz

# cd apr-util-1.4.1/

# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

# make

# make install

2.1.3安装 pcre

# cd /home/username

# unzip pcre-8.30.zip

# cd pcre-8.30/

# ./configure --prefix=/usr/local/pcre

# make

# make install

2.1.4安装 apache

# cd /home/username

# tar zxf httpd-2.4.1.tar.gz

# cd httpd-2.4.1/

# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --enable-so --enable-rewrite

# make

# make install

2.1.5将apache安装为系统服务

# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd

然后 vi /etc/rc.d/init.d/httpd 添加(# !/bin/sh下面)

# chkconfig: 2345 50 90

# description: Activates/Deactivates Apache Web Server

保存退出

最后,运行chkconfig把Apache添加到系统的启动服务组里面:

# chkconfig --add httpd

# chkconfig httpd on

然后再service httpd start

2.1.6打开iptables

# iptables -F

# iptables -P INPUT ACCEPT

2.2 安装 mysql

2.2.1安装 cmake

# cd /home/username

# wget http://www.cmake.org/files/v2.8/cmake-2.8.3.tar.gz

# tar zxf cmake-2.8.3.tar.gz

# cd cmake-2.8.3

# yum install gcc

# yum install gcc-c++

# ./configure

# make

# make install

# ln -s /usr/local/bin/cmake /usr/bin/cmake

2.2.2安装mysql

# groupadd mysql

# useradd -r -g mysql mysql

# cd /home/username

# tar zxf mysql-5.5.21.tar.gz

# cd mysql-5.5.21

# yum -y install ncurses-devel

# yum install bison

# cmake .

如果出现错误:

# rm CMakeCache.txt

# cmake .

# make

# make install

# cd /usr/local/mysql/

# chown -R mysql .

# chgrp -R mysql .

# scripts/mysql_install_db --user=mysql

# chown -R root .

# chown -R mysql data

# cp support-files/my-medium.cnf /etc/my.cnf

# bin/mysqld_safe --user=mysql &

# bin/mysqladmin -u root password "111111"

# cp support-files/mysql.server /etc/init.d/mysqld

# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

# chmod +x /etc/init.d/mysqld

# service mysqld start

测试一下:

# mysql -u root -p

然后输入密码,如果能够进入就说明安装好了

把mysql安装为系统启动项

# vi /etc/rc.d/init.d/mysqld 添加(# !/bin/sh下面)

# chkconfig: 2345 51 89

# description: Activates/Deactivates MySQL Server

保存退出

# chkconfig --add mysqld

# chkconfig mysqld on

# service mysqld restart

2.3 安装 php

2.3.1 安装libxml2

#yum install libxml2

#yum install libxml2-devel -y

2.3.2 安装php

#cd /home/username

#tar zxf php-5.4.8.tar.gz

#cd php-5.4.8

#./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/apache2/conf/httpd.conf

确保以下字符串是否存在

LoadModule php5_module modules/libphp5.so

如果没有就加上

在AddType application*后面加如下一行

AddType application/x-httpd-php .php .phtml

在DirectoryIndex index.html加上index.php

DirectoryIndex index.php index.html

尝试启动apache

#service httpd restart

若有error发生

# setenforce 0

# chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache/modules/libphp5.so

# service httpd restart

2.3.3 测试php

# vi /usr/local/apache2/htdocs/index.php

加入

保存退出

#service httpd restart

在浏览器中输入"http://localhost[:port]/index.php",查看是否有phpinfo的消息。

2.3.4 测试php-mysql

# vi /usr/local/apache2/htdocs/php_mysql.php

输入

在浏览器输入“http://localhost[:port]/php_mysql.php”,若显示“connected!”,说明成功了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值