Created
March 30, 2017 02:51
-
-
Save leapar/2c3816bf7245406f531be5ecd0f422a6 to your computer and use it in GitHub Desktop.
centos 安装apache 和 php5.6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
centos 安装 php5.6,安装前需要先安装数据库和apache | |
安装 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(); | |
./configure --prefix=/usr/local/php5.6 \ | |
--with-libxml-dir=/usr/include/libxml2 --with-apxs2=/usr/local/apache/bin/apxs \ | |
--with-mysql --with-config-file-path=/usr/local/apache/conf \ | |
--with-mysqli=/usr/bin/mysql_config --with-gd --enable-gd-native-ttf \ | |
--with-zlib --with-mcrypt --with-pdo-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/ | |
yum -y install libxml2 libxml2-devel bzip2 bzip2-devel gd gd-devel libmcrypt libmcrypt-devel mysql-devel | |
cp /usr/lib64/mysql/libmysqlclient.so.15.0.0 /usr/lib/libmysqlclient.so |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wget https://github.com/phpredis/phpredis/archive/3.1.2.tar.gz
tar -zxf 3.1.2.tar.gz
cd phpredis-3.1.2
export PATH=$PATH:/usr/local/php5.6/bin/
phpize
./configure
make && make install