先看下历史笔记:
Ubuntu 14 编译安装 PHP 5.4.45 + Nginx 1.4.7 + MySQL 5.6.26 笔记
################################################## ### 安装PHP依赖库 ################################################## # 安装依赖库 sudo apt-get -y install libxml2-dev libjpeg-dev libpng-dev libfreetype6-dev libiconv-hook-dev libiconv-hook1 libltdl-dev libssl-dev sudo ln -s /usr/lib/libiconv_hook.so.1.0.0 /usr/lib/libiconv.so sudo ln -s /usr/lib/libiconv_hook.so.1.0.0 /usr/lib/libiconv.so.1 # 安装 libmcryp cd /usr/local/src/ubuntu-sdk/source2/php sudo tar -xzvf ./libmcrypt-2.5.8.tar.gz cd ./libmcrypt-2.5.8 sudo ./configure --prefix=/usr sudo make sudo make install # 安装 mhash cd /usr/local/src/ubuntu-sdk/source2/php sudo tar -xzvf ./mhash-0.9.9.9.tar.gz cd ./mhash-0.9.9.9 sudo ./configure --prefix=/usr sudo make sudo make install # 安装 mcrypt sudo /sbin/ldconfig # 搜索出可共享的动态链接库 cd /usr/local/src/ubuntu-sdk/source2/php sudo tar -xzvf ./mcrypt-2.6.8.tar.gz cd ./mcrypt-2.6.8 sudo ./configure --prefix=/usr sudo make sudo make install # 安装 libiconv #cd /usr/local/src/ubuntu-sdk/source2/php #sudo tar -xzvf ./libiconv-1.14.tar.gz #cd ./libiconv-1.14 #sudo ./configure --prefix=/usr/local/libiconv #sudo make #sudo make install #安装bzip2 cd /usr/local/src/ubuntu-sdk/source2/php sudo tar -xzvf ./bzip2-1.0.6.tar.gz cd ./bzip2-1.0.6 sudo make sudo make install # 降级 openssl wget https://www.openssl.org/source/old/1.0.2/openssl-1.0.2l.tar.gz tar zxvf openssl-1.0.2l.tar.gz cd openssl-1.0.2l sudo ./config --prefix=/usr/local/openssl shared sudo make sudo make install # 创建 数据 文件夹 sudo mv /fiisoo/php /fiisoo/php.$(date "+%Y-%m-%d.%s") sudo mkdir -pv /fiisoo/php/conf sudo mkdir -pv /fiisoo/php/conf/php-fpm.d sudo mkdir -pv /fiisoo/php/log # 解压 php-5.6.30 cd /usr/local/src/ubuntu-sdk/source2/php sudo tar -xzvf ./php-5.6.30.tar.gz cd ./php-5.6.30 # 生成 配置 sudo ./configure \ --prefix=/usr/local/php/php-5.6 \ --with-config-file-path=/fiisoo/php/conf \ --with-openssl=/usr/local/openssl \ --with-zlib \ --with-bz2 \ --with-gd \ --with-jpeg-dir \ --with-png-dir \ --with-gettext \ --with-mhash \ --with-freetype-dir \ --with-mcrypt \ --with-iconv \ --with-curl \ --with-xmlrpc \ --with-pdo-mysql \ --with-mysqli \ --enable-calendar \ --enable-pdo \ --enable-zip \ --enable-mbstring \ --enable-mbregex \ --enable-bcmath \ --enable-soap \ --enable-sockets \ --enable-ftp \ --enable-gd-native-ttf \ --enable-shmop \ --enable-sysvmsg \ --enable-sysvsem \ --enable-sysvshm \ --enable-xml \ --enable-pcntl \ --enable-fpm \ --enable-opcache \ --without-pear # 编译 安装 sudo make sudo make install # 配置 php.ini sudo rm -rf /etc/php.ini sudo \cp -rf /usr/local/src/ubuntu-sdk/config/php-5.6/php.ini /fiisoo/php/conf/ sudo ln -s /fiisoo/php/conf/php.ini /etc/php.ini # 配置 php-fpm sudo \cp -rf /usr/local/src/ubuntu-sdk/config/php-5.6/php-fpm.conf /fiisoo/php/conf/ # 设置 php-fpm 开机启动 sudo \cp -rf /usr/local/src/ubuntu-sdk/config/php-5.6/php-fpm.init /etc/rc.d/init.d/php-fpm sudo chmod +x /etc/rc.d/init.d/php-fpm sudo chkconfig php-fpm on # 配置 php 命令行工具 sudo rm /usr/local/bin/php sudo rm /usr/local/bin/phpize sudo rm /usr/local/bin/php-config sudo ln -s /usr/local/php/php-5.6/bin/php /usr/local/bin/php sudo ln -s /usr/local/php/php-5.6/bin/phpize /usr/local/bin/phpize sudo ln -s /usr/local/php/php-5.6/bin/php-config /usr/local/bin/php-config # 启动 php-fpm sudo killall php-fpm sudo service php-fpm start # 查看 配置信息 sudo \cp -rf /usr/local/src/ubuntu-sdk/config/phpinfo.php /fiisoo/nginx/html/
遇到的问题
Deepin 15 编译 php5.6 openssl 报错
原因是:系统自带的 openssl 版本过高。
解决方案:openssl 版本降级
# 降级 openssl wget https://www.openssl.org/source/old/1.0.2/openssl-1.0.2l.tar.gz tar zxvf openssl-1.0.2l.tar.gz cd openssl-1.0.2l sudo ./config --prefix=/usr/local/openssl shared sudo make sudo make install