安装Apache2.2.4+Mysql5.0.27+php5.2.1详细安装说明
安装系统: 红帽子企业服务器Redhat Linux5(不安装任何服务)
也可以安装完整版,然后将Apache,mysql,php卸掉
命令为rpm –qa | grep apache
命令为rpm –qa | grep mysql
命令为rpm –qa | grep php
注意卸包顺序
命令rpm –e 文件名
Web服务: Apache (httpd-2.2.4.tar.gz)
数据库服务: MySQL (mysql-5.0.27.tar)
Php服务: Php (php-5.2.1.tar.gz)
jpegsrc.v6b.tar.gz
libpng-1.2.8.tar.bz2
freetype-2.3.2.tar.gz
gd-2.0.34.tar.gz
libxml2-2.6.24.tar.bz2
zlib-1.2.2.tar.gz
安装apache
先将httpd-2.2.4.tar.gz 拷贝到/tmp
mv httpd-2.2.4.tar.gz /tmp
cd /tmp
解压:
tar zxvf httpd-2.2.4.tar.gz
进入安装目录:
cd httpd-2.2.4
编译安装:
./configure --prefix=/usr/local/apache --enable-so
make
make install
安装 mysql
编译安装MySQL
# tar xzvf mysql-5.0.27.tar.gz
# cd mysql-5.0.27
# ./configure \
"--prefix=/usr/local/mysql" \
"--localstatedir=/var/lib/mysql" \
"--with-comment=Source" \
"--with-server-suffix=-Comsenz" \
"--with-mysqld-user=mysql" \
"--without-debug" \
"--with-big-tables" \
"--with-charset=" \ #这个后边需要指定你所需要的字符集参数(utf8......)
"--with-collation= " \ #字符集校正码(utf8_general_ci,......)
"--with-extra-charsets=all" \
"--with-pthread" \
"--enable-static" \
"--enable-thread-safe-client" \
"--with-client-ldflags=-all-static" \
"--with-mysqld-ldflags=-all-static" \
"--enable-assembler" \
"--without-isam" \
"--without-innodb" \
"--without-ndb-debug"
# make
# make install
# useradd mysql
# cd /usr/local/mysql
# bin/mysql_install_db --user=mysql
# chown -R root:mysql . –注意这个点,不要忘了哦!
# chown -R mysql /var/lib/mysql
# cp share/mysql/my-huge.cnf /etc/my.cnf
# cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld
# chmod 755 /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# /etc/rc.d/init.d/mysqld start
# bin/mysql -u root password "password_for_root" 也可以不选择为mysql添加密码
启动mysql/etc/rc.d/init.d/mysql start
源码编译安装所需包(Source)
安装 (1) jpeg6
建立目录
# mkdir /usr/local/jpeg6
# mkdir /usr/local/jpeg6/bin
# mkdir /usr/local/jpeg6/lib
# mkdir /usr/local/jpeg6/include
# mkdir /usr/local/jpeg6/man
# mkdir /usr/local/jpeg6/man/man1
# cd /usr/local/src
# tar -zxvf jpegsrc.v6b.tar.gz
# cd jpegsrc.v6b
#./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make; make install
安装 (2)libpng
# cd /usr/local/src
# tar -jxvf libpng-1.2.8.tar.bz2
# cd libpng-1.2.8
# cp scripts/makefile.std makefile
# make; make install
安装 (3)freetype
# cd /root/soft
# tar -zxvf freetype-2.3.2.tar.gz
# cd freetype-2.3.2
# ./configure --prefix=/usr/local/freetype
# make;make install
安装 (4)GD2
# cd /usr/local/src
# tar xzvf gd-2.0.34.tar.gz
# cd gd-2.0.34
#./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6 --with-png --with-zlib --with-freetype=/usr/local/freetype
# make
# make install
安装 (5)LibXML2
# cd /usr/local/src
# tar xjvf libxml2-2.6.24.tar.bz2
# cd libxml2-2.6.24
# ./configure --prefix=/usr/local/libxml2
# make
# make install
安装(6)zlib
安装 LibXML2
# cd /usr/local/src
# tar zxvf zlib-1.2.2.tar.gz
# cd zlib-1.2.2
# ./configure --prefix=/usr/local/ zlib
# make
# make install
安装php5
#Cd /usr/local/src
#tar zxvf php-5.2.1.tar.gz
#cd php-5.2.1
#./configure
--prefix=/usr/local/php
--with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql
--with-libxml-dir=/usr/local/libxml2
--with-gd=/usr/local/gd2
--with-jpeg-dir=/usr/local/jpeg6/
--with-zlib-dir=/usr/local/zlib
--with-libpng-dir=/usr/local/lib --with-freetype-dir=/usr/local/freetype --enable-mbstring
#make
#make install
整合配置
配置 httpd.conf 让apache支持PHP
进入指定的安装目录:
# vi /usr/local/apache2/conf/httpd.conf
找到 AddType application/x-gzip .gz .tgz 在其下添加如下内容
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
注意在.php和.phps前面的空格
*设定网页支持类型:
*DirectoryIndex index.html index.php
*设置网站的起始位置:
*DocumentRoot "/var/www/html/"
如果不设置起始位置,那么就为默认位置(你写的文件都要放在这个目录里)
*/usr/local/apache2/htdoes
重启apache
# /usr/local/apache/bin/apachectl restart
可能出现的问题
在这里有一个问题,如果你的系统安装了SELinux模块,那么由于安全控制的原因,会出现如下错误:
Starting httpd: Syntax error on line 57 of /etc/httpd/conf/httpd.conf:
Cannot load /etc/httpd/modules/libphp5.so into server: libxml2.so.2: failed to map segment from shared object: Permission denied
[FAILED]
解决方法
system-config-securitylevel
然后将SElinux设为Disable
然后将php.ini(php的配置文件)放在/etc下
将配置文件中register-golbals = Off改为register-golbals = On
*测试安装配置是否成功:
*cd /var/www/html
(默认位置cd /usr/local/apache2/htdoes)
*touch index.php
*vi index.php
添加以下代码
*
*打开浏览器,输入
,如能显示系统内php版本信息,则apache安装成功!
打开浏览器,输入
, 如能显示It Woke则apache安装成功!