编译安装httpd:http://my.oschina.net/forlinux/blog/362617
通用二进制安装mysql:http://my.oschina.net/forlinux/blog/362335
本篇博客将php编译为httpd的模块,运行phpMyadmin管理mysql
php-5.4.31.tar.bz2、mysql-5.6.22-linux-glibc2.5-x86_64.tar.gz、phpMyAdmin-4.2.13.1-all-languages.zip
3.1添加yum源
[root@Machine1 ~]# vim /etc/yum.repos.d/ali.repo [root@Machine1 ~]# cat /etc/yum.repos.d/ali.repo [epel] name=aliyun epel baseurl=http://mirrors.aliyun.com/epel/$releasever/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-6 [root@Machine1 ~]# yum repolist Loaded plugins: security repo id repo name status base CentOS-6 - Base 6,518 epel aliyun epel 11,154 extras CentOS-6 - Extras 36 openlogic CentOS-6 - openlogic packages for x86_64 32 updates CentOS-6 - Updates 530 repolist: 18,270
3.2安装编译php所依赖的软件
[root@Machine1 ~]# yum -y install libxml2-devel bzip2-devel \ >libmcrypt-devel mhash-devel php-mbstring
[root@Machine1 php-5.4.31]# ./configure \ >--prefix=/usr/local/php \ >--with-mysql=/usr/local/mysql \ >--with-mysqli=/usr/local/mysql/bin/mysql_config \ >--with-openssl \ >--enable-mbstring \ >--with-freetype-dir \ >--with-jpeg-dir \ >--with-png-dir \ >--with-zlib \ >--with-libxml-dir=/usr \ >--enable-xml \ >--enable-sockets \ >--with-apxs2=/usr/local/httpd/bin/apxs \ >--with-mcrypt \ >--with-config-file-path=/etc \ >--with-config-file-scan-dir=/etc/php.d \ >--with-bz2 \ >--enable-maintainer-zts
--prefix=PATH #安装路径
--with-mysql #php连接mysql的驱动
--with-mysqli #mysql的高级接口,一般必须指定
--with-apxs2 # php要想编译成httpd的模块,必须基于此接口编译
--with-config-file-path #php的主配置文件路径
--with-config-file-scan-dir #其他配置文件,次路径下所有.ini的文件都识别为配置文件的一部分
--enable-maintainer-zts #当httpd使用worker、event模型时,php需要编译为此格式
[root@Machine1 php-5.4.31]# make && make install [root@Machine1 php-5.4.31]#cp php.ini-production /etc/php.ini
修改主配置文件:
主配置文件中添加AddType application/x-httpd-php .php
但是有的php网页文件是以.phps结尾,所以再添加一行AddType application/x-httpd-php-source .phps
还需要让httpd知道默认主页面DirectoryIndex index.php
测试:
[root@Machine1 php-5.4.31]# vim /usr/local/httpd/htdocs/index.php
<?php
phpinfo();
?>
[root@Machine2 ~]vim /usr/local/httpd/htdocs/index.php <?php $link=mysql_connect(localhost,root,rootroot); if ($link) echo "Success..."; else echo "Failure..."; ?>
[root@Machine1 ~]# unzip phpMyAdmin-4.3.1-all-languages.zip
[root@Machine1 ~]# cp -R phpMyAdmin-4.3.1-all-languages/* /usr/local/httpd/htdocs/
[root@Machine1 ~]#cd /usr/local/httpd/htdocs/
[root@Machine1 ~]# cp config.sample.inc.php config.inc.php
[root@Machine1 ~]#vim config.inc.php $cfg['blowfish_secret'] = 'a8b7c6d'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */