阿里云php源码安装

用yum安装完apache,今天在阿里云EOS部署环境,使用yum安装php5.6的时候一大堆报错,于是就换用源码安装,同样一堆问题,那就一个一个解决呗,整个流程如下:

  1. 下载源码(PHP官方,我选择的是5.6.36版本)
  2. 解压
sudo tar -jxvf  php-5.6.36.tar.bz2 
  1. 安装一些依赖
sudo yum -y install libcurl-devel  (必须安装)
sudo yum -y install libXpm-devel   (必须安装)
sudo yum -y install libxml2-devel  (必须安装)
  1. 进入目录,执行configure(以下是我的参数配置)
cd php-5.6.36 
./configure \
--prefix=/usr/local/php56 \
--with-config-file-path=/etc \
--with-apxs2=/usr/bin/apxs \
--disable-ipv6 \
--enable-calendar \
--enable-ctype \
--enable-dom \
--enable-exif \
--enable-fileinfo \
--enable-filter \
--enable-gd-native-ttf \
--enable-hash \
--enable-json \
--enable-libxml \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-pdo \
--enable-posix \
--enable-session \
--enable-simplexml \
--enable-soap \
--enable-tokenizer \
--enable-xml \
--enable-xmlreader \
--enable-xmlwriter \
--enable-zip \
--with-bz2 \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-iconv \
--with-jpeg-dir \
--with-mcrypt \
--with-mysql=mysqlnd \
--with-openssl \
--with-pdo-mysql=mysqlnd \
#--with-pdo-odbc=unixODBC,/usr/local/unixODBC \#
--with-png-dir \
--with-libedit \
--with-zlib \
--disable-all

以下是相继报出的error

  1. Cannot find OpenSSL's
解决方案:
sudo yum install openssl openssl-devel
sudo ln -s /usr/lib64/libssl.so /usr/lib/

2.configure: error: png.h not found.

解决方案:
sudo yum install libpng libpng-devel

3.Configure: error: Please reinstall the BZip2 distribution

解决方案:
sudo yum install bzip2 bzip2-devel

4.Configure: error: libjpeg.(also) not found.

解决方案:
sudo yum install libjpeg libjpeg-devel

5.configure: error: freetype-config not found.

解决方案:
yum install freetype-devel

6.configure: error: mcrypt.h not found. Please reinstall libmcrypt.

解决方案:
sudo yum install libmcrypt libmcrypt-devel
  1. configure: error: Please reinstall libedit - I cannot find readline.h
解决方案:
sudo yum install  libedit-devel 
******华丽的分割线,configure终于通过了,所以看到error不要慌,来一个解决一个嘛,话说yum还是挺好用的*****
NOW,继续下一步
sudo make & make install

这一步倒没什么error,倒是时间挺长的,最终提示如下,安装成功[开心]

Installing PHP SAPI module:       apache2handler
/usr/lib64/httpd/build/instdso.sh SH_LIBTOOL='/usr/lib64/apr-1/build/libtool' libphp5.la /usr/lib64/httpd/modules
/usr/lib64/apr-1/build/libtool --mode=install install libphp5.la /usr/lib64/httpd/modules/
libtool: install: install .libs/libphp5.so /usr/lib64/httpd/modules/libphp5.so
libtool: install: install .libs/libphp5.lai /usr/lib64/httpd/modules/libphp5.la
libtool: install: warning: remember to run `libtool --finish /home/bian/php-5.6.36/libs'
chmod 755 /usr/lib64/httpd/modules/libphp5.so
[activating module `php5' in /etc/httpd/conf/httpd.conf]
Installing shared extensions:     /usr/local/php56/lib/php/extensions/no-debug-non-zts-20131226/
Installing PHP CLI binary:        /usr/local/php56/bin/
Installing PHP CLI man page:      /usr/local/php56/php/man/man1/
Installing PHP CGI binary:        /usr/local/php56/bin/
Installing PHP CGI man page:      /usr/local/php56/php/man/man1/
Installing build environment:     /usr/local/php56/lib/php/build/
Installing header files:           /usr/local/php56/include/php/
Installing helper programs:       /usr/local/php56/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/php56/php/man/man1/
  page: phpize.1
  page: php-config.1
Installing PDO headers:           /usr/local/php56/include/php/ext/pdo/

接着ln一下

sudo ln php /usr/bin/php
sudo ln phpize /usr/bin/phpize

此时apache的配置文件httpd.conf会自动加上
LoadModule php5_module /usr/lib64/httpd/modules/libphp5.so

接着httpd.conf文件再加上
AddType application/x-httpd-php .php //使apache与扩展名为.php的文件类型相关联

到此安装完毕,可以正常访问网站了

你可能感兴趣的:(阿里云php源码安装)