一 先安装软件安装所需要的环境相关软件包
yum install –y zlib-devel.i* openssl-devel.i* libtermcap-devel.i* libxml2=devel.i*
二 下载apache mysql php实例版本
apache 2.2.11
mysql 6.0.11
ph p 5.2.3
解压并重命名以方便以后操作
tar jxvf apache-*.tar.bz2 mv apache-* apache
tar zxvf mysql-*.tar.gz mv mysql-* mysql
tar jxvf php-*.tar.bz2 mv php-* php
检查编译环境echo $?
为0正确
三 mysql
1 创建安装所需的目录
mkdir /usr/local/mysql mkdir /usr/local/mysql/etc mkdir /usr/local/mysql/database
2 新建用户mysql 为了安全性考虑 useradd mysql
3 编译安装mysql
cd mysql
./configure --prefix=/usr/local/mysql --sysconfdir=/usr/local/mysql/etc \
--localstatedir=/usr/local/mysql/database –with-charset=utf8
make make install
4 安装 mysql test information_schema数据库
cd /usr/local/mysql/
./bin/mysql_install_dh --user=mysql
5 建立mysql配置文件
cd /usr/local/mysql
cp /usr/local/mysql/share/mysql/my-huge.cnf /etc/my.cnf #主配置文件#
cp /usr/local/mysql/share/mysql/musql.server /etc/rc.d/init.d/mysql #开机*启动配置文件#
chown –R mysql:mysql /usr/local/mysql/database/
chown –R mysql:mysql /usr/local/mysql/lib/
./bin/mysql_safe –user=mysql &
6 增加mysql服务 启动服务并配置开机自动加载
chkconfig --add mysql
chkconfig mysql on
service mysql start
7 把mysql的相关命令复制到/sbin/
cp /usr/local/mysql/bin/* /sbin/
8 使用mysqladmin创建mysql管理员及密码
mysqladmin –u root password centos
四apache
1 创建安装所需的目录
mkdir /usr/local/httpd
2 编译安装mysql
cd mysql
./configure --prefix=/usr/local/httpd/ \
--enable-modules=so \
--enable-so –enable-cgi –enable-ssl
make make install
3 复制apache启动文件并配置开机自动启动
cp /usr/local/httpd/bin/apachectl /sbin/
apachectl start
vim /etc/rc.d/rc.local
添加 /sbin/apachectl start
五 php
cd php
1 创建安装所需的目录
mkdir /usr/local/php
2 编译安装php
./configure --prefix=/usr/local/php \
--with-mysql=/usr/local/mysql \
--with-apxs2=/usr/local/httpd/bin/apxs
make make install
3 复制php配置文件
cd php
cp php.ini-dist /usr/local/php/lib/php.ini
六 整合apache 和 php
在 /usr/local/httpd/conf/httpd.conf中添加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php
用一下命令修改selinux
setsebool –P allow_execheap=1
chcon –t textre_shlib_t /usr/local/httpd/modules/libphp5.so
最后重启apache
Apachectl restart
新建一个php页面测试
/usr/local/httpd/htdocs/test.php
<?php
phpinfo();
?>
浏览器打开 ip:test.php