centos7下源码安装Apache2.4.33和php5.6.21

安装Apache2.4.33:

1、先装gcc和make
yum -y install gcc gcc-c++ make 没有这个gcc-c++一会编译不prce
yum -y install openssl-devel

2、安装apr1.6.3:
wget http://mirrors.hust.edu.cn/apache/apr/apr-1.6.3.tar.gz
tar -zvxf apr-1.6.3.tar.gz
cd apr-1.6.3
./configure --prefix=/usr/local/apr
make && make install && cd ..

3、安装apr-util
wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
tar -zvxf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install && cd ..
注:如果报错error: expat.h: No such file or directory则需要安装 expat-devel
yum -y install expat-devel

4、安装pcre
wget https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.bz2
tar -vxf pcre-8.42.tar.bz2    (注:如果没有安装bzip则会报错,yum -y install bzip2)
cd pcre-8.42
./configure
make && make install && cd ..

5、安装apache 一定要先装上面那三个不然编译不了
首先从  http://httpd.apache.org/download.cgi#apache2433
wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.33.tar.gz
tar -zvxf httpd-2.4.33.tar.gz
cd httpd-2.4.33
./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util  --enable-ssl
make && make install && cd ..

6、加入service服务
ln -s /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd

7、配置httpd.conf
添加php扩展模块:

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

添加虚拟站点,web目录等。。。
以下装完PHP会自动加上:
LoadModule php5_module        modules/libphp5.so

安装PHP5.6:

8、安装PHP5.6必要运行库(按需)
yum -y install libxml2-devel  openssl curl-devel libjpeg-devel libpng libpng-devel freetype-devel libmcrypt-devel;
如果yum找不到libmcrypt-devel,则用源码安装
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz 
tar -zxvf libmcrypt-2.5.7.tar.gz 
cd libmcrypt-2.5.7
./configure
make && make install && cd ..

9、从www.php.net下载PHP5.6
wget http://cn2.php.net/distributions/php-5.6.21.tar.gz
切到下载目录
tar -zvxf php-5.6.21.tar.gz
cd php-5.6.21
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --enable-sysvsem --enable-sockets --enable-pcntl --enable-mbstring --enable-mysqlnd --enable-opcache --enable-shmop  --enable-zip --enable-ftp --enable-gd-native-ttf --enable-wddx --enable-soap

如果出现报错:Don't know how to define struct flock on this system, set --enable-opcache=no
vim /etc/ld.so.conf 另起一行加入/usr/local/lib
再执行 ldconfig即可

make && make install;

10、配置和优化php
cp php.ini-production /usr/local/php56/etc/php.ini
vim /usr/local/php56/etc/php.ini
【opcache】加入opcache增强缓存处理速度
zend_extension = /usr/local/php56/lib/php/extensions/no-debug-zts-20131226/opcache.so:
opcache.enable=1
时区更改
date.timezone = PRC

11、测试
OK了,apache的Document目录下写个phpinfo.php看效果吧!
phpinfo();
?>

你可能感兴趣的:(centos7下源码安装Apache2.4.33和php5.6.21)