鹏's profile皓月清风PhotosBlogListsMore Tools Help

Blog


    January 30

    Red Hat Linux AS4 安装PHP5

    为了将公司原有的论坛移植到新服务器上,需要在新服务器上安装论坛程序。但是在安装时报出不支持MYSQL的错误信息。

    当初在新服务器安装LINUX AS4的时候,PHPAPACHE是默认安装的,而且PHP脚本可以被解释。试着写了几个PHP页面,发现在连接MYSQL的时候报错:

    Call to undefined function: mysql_connect()

    这说明数据库连接方法出错。到/etc/php.ini里去看,发现默认端口和默认SOCKET都没有设置,把3306/var/lib/mysql/mysql.sock写上去,重起APACHE,还是不行,很奇怪。   

    经过查询,找到这么一篇文章:

    http://blog.chinaunix.net/u/15010/showart_395725.html

    MYSQL4版本以上,调用libmysqlclient.so 的方式改了,跟MYSQL3.23不一样,而PHP4.3.2APACHE还是以旧的方式来调用,因此就找不到libmysqlclient.so 了。
    英文原文如下:
    -------------------------------------------
    Ensure that you don't have any MySQL clients that use shared libraries (like the Perl DBD::mysql module). If you do, you should recompile them, because the data structures used in `libmysqlclient.so' have changed. The same applies to other MySQL interfaces as well, such as the Python MySQLdb module.
    -------------------------------------------

    而默认安装的PHP4.x的,MYSQL5.x的,所以说还是版本冲突造成的无法连接数据库,需要安装PHP5

     

    先卸载PHP,在执行rpm –e 的时候报错,有其他包依赖PHP包,不能卸载。这时记录下有依赖关系的包,逐个强行卸载。

    PHP提供的是源码,需要自己编译,所以安装PHP5之前先安装MYSQL的开发包:MySQL-devel-community-5.0.45-0.rhel4.i386.rpm然后在/usr/include/mysql/目录下找到mysql.h文件。

    /home/bet310下把PHP的源码包解压,目录是php-5.2.5

    然后进入cd php-5.2.5

    配置 ./configure \

    --prefix=/usr/local/php5.2.5 \

    --with-mysql=/usr/include/mysql/ \

    --with-apxs2=/usr/sbin/apxs

           这里设置了PHP安装路径:/usr/local/php5.2.5;指定了mysql.h路径:/usr/include/mysql/;指定了APX2路径:/usr/sbin/apxs

    配置完成以后 make

                              make install

    复制PHP配置文件到安装目录 cp /home/bet310/php-5.2.5/php.ini.dist /usr/local/php5.2.5/lib/php.ini

        安装完毕。

     

        然后开始配置PHP。首先在/etc/httpd/conf/httpd.conf文件里找到这样一段:

    #

    # AddType allows you to add to or override the MIME configuration

    # file mime.types for specific file types.

    #

    在下面加上:

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

    AddType application/x-httpd-php-source .phps

     

    然后找到这里:

    #

    # Dynamic Shared Object (DSO) Support

    #

    发现在加载模块列表的最后已经自动加上了这样一行:

    LoadModule php5_module        /usr/lib/httpd/modules/libphp5.so

    最后重起APACHE就可以了。

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://lunar-wind.spaces.live.com/blog/cns!DBB349ACF8876C02!218.trak
    Weblogs that reference this entry
    • None