RHEL6环境下MediaWiki安装过程记录

这周,应要求在某台服务器上部署MediaWiki系统。安装配置Wiki本身是件极其容易的事情,但在RHEL6环境下却遇到几个小问题,花费了些许时间来解决,故记录之。

替换CentOS更新源

删除rhel6自带的yum

rpm -aq|grep yum|xargs rpm -e --nodeps

下载CentOS6的yum

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

安装rpm包

rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
rpm -ivh yum-3.2.29-40.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

将CentOS-Base.repo放到/etc/yum.repos.d/
清除yum的缓存

yum clean all 

卸载RHEL自带PHP,下载源码重新安装PHP5.5.1

因RHEL自带的PHP5.3.3默认不支持mysql,yum install php-mysql后也无作用,故下载源码手动编译

卸载RHEL自带PHP

rpm -qa|grep php
rpm -e php-mysql
rpm -e php-pdo
rpm -e php-cli
rpm -e php
rpm -e php-cli
rpm -e php-gd
rpm -e php-common

下载PHP5.5.1源码

wget http://www.php.net/get/php-5.5.1.tar.bz2/from/tw2.php.net/mirror
tar xvf php-5.5.1.tar.bz2

配置、编译、安装

yum -y install cc gcc 
yum -y install libxml2 libxml2-devel

./configure --prefix=/usr/local/php  --with-apxs2=/usr/sbin/apxs --with-mysql --with-mysqli=/usr/bin/mysql_config --with-config-file-path=/usr/local/php --enable-mbstring=all
make & makeinstall

./configure错误解决方法:

(1)使用rhel6自带apache服务在安装php时会找不到apxs文件

yum -y install httpd-devel  

安装后的apxs文件存放于/usr/sbin/目录下

(2)找不到mysql-header-files

checking for MySQL support… yes
checking for specified location of the MySQL UNIX socket… no
checking for MySQL UNIX socket location… no
configure: error: Cannot find MySQL header files under /usr/bin/mysql.
Note that the MySQL client library is not bundled anymore.

需安装mysql-devel

yum -y install mysql-devel  

复制php.ini

将php-5.5.1目录中的php.ini-production文件复制到php安装目录,并重命名为php.ini (若是开发环境建议用php.ini-development,若是生产或测试环境建议用php.ini-production)

将php添加到Path

vi /etc/profile
    export PATH=$PATH:/usr/local/php/bin
source /etc/profile

在Apache中添加php支持

vi /etc/httpd/conf/httpd.conf

设置php文件后缀
查找”AddType application/x-gzip .gz .tgz”,在下面添加:

AddType application/x-httpd-php .php  

设置apache的默认文件名次序
查找”index.html”,后面添加“index.php”

index.htm index.html  index.php

重启Apache服务

service httpd restart




Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>