相關依賴包的檢查與安裝
rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel
rpm -qa freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel
yum -y install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel
yum -y install freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel
rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel
rpm -qa freetype-devel libpng-devel gd-devel libcurl-devel libxslt-develphp
安裝libiconv軟件時,可能會報錯:*gets未聲明,不在函數內等*解決方法:cd /usr/local/libiconv/srclib
sed -i -e '/gets is a security/d' ./stdio.in.h
3.安裝其餘軟件
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum -y install libmcrypt-devel
yum -y install mhash
yum -y install mcrypt
4.cd /home/tools 上傳php-5.6.36.tar.gz
5.解壓:tar -zxvf php-5.6.36.tar.gz
cd php-5.6.36
./configure --prefix=/application/php5.6.36 \
--with-mysql=/application/mysql \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr/ \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-ftp \
--enable-opcache=no
ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/
touch ext/phar/phar.phar
make
make install
ln -s /application/php5.6.36/ /application/php
cp php.ini-production /application/php/lib/php.ini
cd /application/php/etc/
cp php-fpm.conf.default php-fpm.conf
/application/php/sbin/php-fpm 啓動php-fpm
ps -ef |grep php-fpm
lsof -i:9000
說明:mysql
- --with-mysql=/application/mysql mysql的安裝位置
- --with-fpm-user=www nginx的用戶
- --with-fpm-group=www nginx的組
- 按照上面的安裝以後,測試nginx配合php解析沒有問題,在php與mysql鏈接時,會出現500錯誤,通過一番努力得以解決:
- yum install php-mysql -y
- 編輯php.ini文件:修改前:mysqli.default_socket = 修改後:mysqli.default_socket =/tmp/mysql.sock cat /etc/my.cnf 查看mysql.sock的位置,尋找socket。
- 在編寫linux與mysql鏈接的測試文件時,注意其編碼格式!注意格式!注意格式!不要複製!不要複製!不要複製!:<?php$link=mysqlconnect("localhost", "root", "workjob");if ( $link ) {echo "success";}else{echo mysqlerror();}?>**