CentOS6.5 安装apache2.4及PHP5.6

文章目录 收缩

卸载原有Apache

查看linux下是否有apache的rpm包命令:

rpm -qa|grep httpd

如果不存在则执行完命令后不会有任何的显示,如果存在则会显示相关的包名(如:httpd-2.2.4-11.el5_2.centos.5)

卸载rpm包命令:

rpm –e httpd-2.2.4-11.el5_2.centos.5

编译安装apache2.4

参考这篇文章:http://www.884358.com/centos7-apache/

这篇文章中,将添加httpd服务开启启动里面的systemctl enable httpd |去掉。

配置httpd.conf
去掉LoadModule rewrite_module modules/mod_rewrite.so前面的注释符号

PHP依赖包安装

yum -y install libmcrypt-devel mhash-devel libxslt-devel \
libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \
zlib zlib-devel glibc glibc-devel glib2 glib2-develbzip2bzip2-devel \
ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel \
krb5 krb5-devel libidn libidn-devel openssl openssl-devel libpng-devel

编译安装php

cd /usr/local/src

wget https://www.php.net/distributions/php-5.6.36.tar.gz

tar -zvxf php-5.6.36.tar.gz

cd php-5.6.36

mkdir -p /usr/local/php5

./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache/bin/apxs --with-libxml-dir=/usr/local/libxml2 --with-config-file-path=/usr/local/apache/conf --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-gd --enable-gd-native-ttf --with-zlib --with-pdo-mysql=mysqlnd --enable-shmop --enable-soap --enable-sockets --enable-wddx --enable-zip --with-xmlrpc --enable-fpm --enable-mbstring  --with-zlib-dir --with-bz2 --with-curl --enable-exif --enable-ftp --with-jpeg-dir=/usr/local/jpeg6 --with-png-dir=/usr/local/libpng --with-freetype-dir=/usr/local/freetype --with-mcrypt=/usr/local/libmcrypt --disable-fileinfo

make && make install

配置httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so下面添加一行:

LoadModule php5_module modules/libphp5.so

配置php.ini

查找apahe调用的php.ini的路径:

/usr/local/php5/bin/php --ini

可以在编译的时候使用--with-config-file-path参数来修改php.ini的存放位置。

例如:

--with-config-file-path=/etc

把php.ini存放到/etc下面,然后可以从源码包中拷贝php.ini-development到/etc/php.ini。

重启apache

发表评论

电子邮件地址不会被公开。 必填项已用*标注