centos安装apache2.4和php5.6 [ 网站地图 ]

发表于:2018-10-10 浏览:33 作者:zhaods 来源:互联网

关键字:Centos,apache2.4,php5.6

描述: 安装apache2.4 安装基础依赖: #yuminstallgccgcc-c++glibcglibc-develgdgd-develzlibzlib-devellibtool-ltdl-develflexautoconfautomake apache需要依赖apr和apr-util、apr-iconv、pcre 所以

 安装 apache2.4

安装基础依赖:
# yum install gcc gcc-c++ glibc glibc-devel gd gd-devel zlib zlib-devel libtool-ltdl-devel flex autoconf automake

apache 需要依赖apr 和 apr-util、apr-iconv、pcre

所以还需要先安装 apr和apr-util、apr-iconv
# wget http://apache.fayea.com//apr/apr-1.5.2.tar.gz
# wget http://apache.fayea.com//apr/apr-util-1.5.4.tar.gz
# wget http://apache.fayea.com//apr/apr-iconv-1.2.1.tar.gz
# wget https://sourceforge.net/projects/pcre/files/pcre/7.9/pcre-7.9.zip

# tar xzvf apr-1.5.2.tar.gz
# tar xzvf apr-util-1.5.4.tar.gz
# tar xzvf apr-iconv-1.2.1.tar.gz
# cd apr-1.5.2
# ./configure --prefix=/usr/local/apr 
# make 
# make install 
# cd .. 
# cd apr-util-1.5.4
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr 
# make 
# make insatll
# cd .. 
# cd apr-iconv-1.2.1
# ./configure --prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr 
# make 
# make insatll

# 安装pcre
# unzip pcre-7.9.zip
# cd pcre-7.9
# ./configure --prefix=/usr/local/pcre
# make && make install

apache历史版本下载地址:
# wget http://archive.apache.org/dist/httpd/httpd-2.4.9.tar.gz

# tar xzvf httpd-2.4.9.tar.gz
# cd httpd-2.4.9
# ./configure --prefix=/usr/local/apache --enable-track-vars --enable-cgi --enable-proxy-fcgi  --with-config-file-path=/usr/local/apache/conf --with-apr=/usr/local/apr -with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
# make 
# make install

说明:enable-cgi 支持CGI;enable-track-vars 为启动cookie的get/post等追踪功能

将apache安装为系统服务

# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd

# service httpd start

 

 

安装php5.6

下载:
# wget http://cn2.php.net/distributions/php-5.6.25.tar.bz2
解压
# bunzip2 php-5.6.25.tar.bz2
# tar xvf php-5.6.25.tar

# cd php-5.6.25
# ./configure --prefix=/usr/local/php5.6 \
--with-libxml-dir=/usr/include/libxml2 --with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/apache/conf \
--with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd --enable-gd-native-ttf \
--with-zlib --with-mcrypt --with-pdo-mysql=/usr/local/mysql --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/lib --with-png-dir=/usr/lib \
--with-freetype-dir=/usr/lib/ --with-pgsql=/usr/local/pgsql --with-pdo-pgsql=/usr/local/pgsql

注意引用的相关数据库和工具的路径,不然编译会报错误,编译引入了apache,是因为要支持使用apache服务器,需要先安装apache

其中 --with-config-file-path表示php.ini的配置文件路径, --with-apxs2 标识编译apache2的链接为共享Handler模式。

# make
# make install

建议修改一下php的时间格式,默认是美国时间
修改php.ini文件:
date.timezone = Asia/Shanghai

php5.6安装完毕

修改httpd.conf配置文件
1. 添加php支持。
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
2. 添加默认索引页面index.php,再找到“DirectoryIndex”,在index.html后面加上“ index.php”
DirectoryIndex index.html index.php
3. 不显示目录结构,找到“Options Indexes FollowSymLinks”,修改为
Options FollowSymLinks
4. 开启Apache支持伪静态,找到“AllowOverride None”,修改为
AllowOverride All

重启apache服务即可。

创建一个php文件测试看能否显示php信息

<?
phpinfo();


版权所有 域名频道(www.dns110.com) 沪ICP备05004089号