编译安装时的参数
如果apache2和mysql5.7已经安装到指定目录,编译php时直接指定即可。
如果是使用apt安装的,则指定到需要指定目录的上一级即可,比如:
--with-apxs2=/usr/sbin/apxs
--with-config-file-path=/etc
--with-mysql=/usr
--with-mysqli=/usr/bin/mysql_config
一键安装脚本如下
# download php
wget http://mirrors.sohu.com/php/php-5.6.40.tar.bz2
# ln libmysqlclient.so.20 to libmysqlclient_r.so
ln -s /usr/local/mysql/lib/libmysqlclient.so.20 /usr/local/mysql/lib/libmysqlclient_r.so
# do
tar jxvf php-5.6.40.tar.bz2
cd php-5.6.40
./configure
--prefix=/usr/local/php
--with-apxs2=/usr/local/apache2/bin/apxs
--with-mysql=/usr/local/mysql
--with-mysqli=/usr/local/mysql/bin/mysql_config
--with-pdo-mysql=/usr/local/mysql/bin/mysql_config
make
make install
cp php.ini-production /usr/local/php/lib/php.ini
cd ..
# clean php
rm -rf php-5.6.40*
# configure apache2
sed -i "390 i AddType application/x-httpd-php .php" /usr/local/apache2/conf/httpd.conf
echo "<?php phpinfo(); ?>" > /usr/local/apache2/htdocs/index.php
/usr/local/apache2/bin/apachectl -k restart
echo "-----------------------------------------"
echo "-------------php installed---------------"
echo "-----------------------------------------"