首先,要先准备几个必要的类库包安装,如GD类库的
1、libxml2-2.7.8.tar
它的安装如下
先解压tar -zxvf libxml2-2.7.8.tar
再进入包libxml2-2.7.8中,
./configure --prefix=/usr/local/libxml2 为它指定安装地址
make && make install 安装,不般不会出现什么异常问题。
2、图式格式支持包jpeg6源码包
由于这个包不会自动生成子目录,所以用事先手动创建目录名
mkdir -p /usr/local/jpeg6
mkdir -p /usr/local/jpeg6/bin
mkdir -p /usr/local/jpeg6/include
mkdir -p /usr/local/jpeg6/lib
mkdir -p /usr/local/man
3、由于系成自动有其它的apache支持的包,所以不进行再次安装,现在直接安装httpd-2.2.22.tar,但要事先建立用户useradd -s /sbin/nologin apache
解压tar -xvf httpd-2.2.22.tar
进入 cd httpd-2.2.22
配置安装路径和模块
./configure --prefix=/usr/local/apache2.2 \
--enable-so
先作简单的配置
make && make install
安装完成后会在/usr/local/apache2.2生成各种系统文件
配置chkconfig管理
cp /usr/local/apache2.2/bin/apachectl /etc/rc.d/init.d/httpd
chkconfig --add httpd
chkconfig --level 35 httpd on
启动/usr/local/apache2.2/bin/apachectl start 或者 start httpd start
4、安装mysql数据库,首先要源码包mysql-5.1.54.tar
先解压tar -zxvf mysql-5.1.54.tar
这mysql添加使用用户useradd -s /sbin/nologin mysql
之后 cd mysql-5.1.54
./configure --prefix=/usr/local/mysql \
--with-extra-charsets=all 支持多语言
之后出现问题
configure: error: No curses library functions found
configure: error: /bin/sh '/home/niewf/software/erlang_R13B01/erts/configure' failed for erts
在网上找到解决方法上下载一个ncurses5.6.tar.gz
直接解压,./configure && make && make install 就可
再回来配置mysql的安装,能成功,之后就能顺利安装了。
但是这还没有成功做完,新的mysql没有初始授权表,所以执行下列命运创建
/usr/local/mysql/bin/mysql_install_db --user=mysql
添加mysql的配置目录
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
使用chkconfig管理
cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld //开机启动
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
5、安装php-5.4.0.tar,同样要解压
cd php-5.4.0
这个配置是非常关键的
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache2.2/bin/apxs --with-libxml-dir=/usr/local/libxml2 --with-mysqli=/usr/local/mysql/bin/mysql_config
--with-jpeg-dir=/usr/local/jpeg6 --enable-soap
6、 配置httpd.conf
>vi /usr/local/apache2.2/conf/httpd.conf
找到"AddType application/x-gzip .tgz"在它的下面添加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
找到"DirectoryIndex index.html
在index.html 前添加 index.php
在重启apache时,出现cannot restore segment prot after reloc:Permission denied ,上网一查,原来是selinux的问题,所以进入
/usr/local/apache2.2/modules/
chcon -t texrel_shlib_t libphp5.so就可解决
或者将selinux关闭也可以
7.测试,在/user/localh/apache2.2/htdocs上录内添加index.php文件
内容为:
<?php
phpinfo();
?>
在浏览器输入http://localhost/index.php能正常看到php请明页面。
在测试mysql,建立mysql.php:
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
else echo "connecto mysql successful!!";
// some code
mysql_close($con);
?>
最后在浏览器上输入http://localhost/mysql.php
弹出页面内容为: connecto mysql successful!! 说明也成功啦!!!