1. 安裝php5php
• PHP官網www.php.netmysql
• 當前主流版本爲5.6/7.1sql
• cd /usr/local/src/apache
• wget http://cn2.php.net/get/php-5.6.35.tar.gz/from/this/mirror安全
• tar -zxvf mirrorphp7
• cd php-5.6.35/app
• ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exifcurl
• make && make installsocket
• cp php.ini-production /usr/local/php/etc/php.ini函數
2.參數詳解:
--prefix 指定php安裝目錄
--with-apxs2 表示使用apache2.0以上版本,此參數自動加載擴展模塊
--with-config-file-path 指定php配置文件php.ini位置
--with-mysql mysql安裝目錄,對myslq的支持
--with-pdo-mysql
--with-mysqli mysqli文件目錄,優化支持
--enable-safe-mode 打開安全模式
--enable-ftp 打開ftp的支持
--enable-zip 打開對zip的支持
--with-bz2 打開對bz2文件的支持
--with-jpeg-dir 打開對jpeg圖片的支持
--with-png-dir 打開對png圖片的支持
--with-freetype-dir 打開對freetype字體庫的支持
--without-iconv 關閉iconv函數,種字符集間的轉換
--with-libXML-dir 打開libxml2庫的支持
--with-XMLrpc 打開xml-rpc的c語言
--with-zlib-dir 打開zlib庫的支持
--with-gd 打開gd庫的支持
--enable-gd-native-ttf 支持TrueType字符串函數庫
--with-curl 打開curl瀏覽工具的支持
--with-curlwrappers 運用curl工具打開url流
--with-ttf 打開freetype1.*的支持,能夠不加了
--with-xsl 打開XSLT 文件支持,擴展了libXML2庫 ,須要libxslt軟件
--with-gettext 打開gnu 的gettext 支持,編碼庫用到
--with-pear 打開pear命令的支持,PHP擴展用的
--enable-calendar 打開日曆擴展功能
--enable-mbstring 多字節,字符串的支持
--enable-bcmath 打開圖片大小調整,用到zabbix監控的時候用到了這個模塊
--enable-sockets 打開 sockets 支持
--enable-exif 圖片的元數據支持
--enable-magic-quotes 魔術引用的支持
--disable-rpath 關閉額外的運行庫文件
--disable-debug 關閉調試模式
3. 安裝過程當中報錯信息:
報錯1:configure: error: Cannot find OpenSSL's <evp.h>
解決:yum install openssl openssl-devel
報錯2: configure: error: Please reinstall the BZip2 distribution
解決: yum install bzip2 bzip2-devel
報錯3: configure: error: jpeglib.h not found.
解決; yum install -y gd gd-devel libjpeg-devel
報錯4: configure: error: mcrypt.h not found. Please reinstall libmcrypt
解決: yum install -y epel-release install libmcrypt-devel
4. php相關文件及操做:
4.1 核心二進制文件目錄:
/usr/local/php/bin/
4.2 apache下php的擴展模塊:
/usr/local/apche2.4/modules/libphp5.so
4.3 查看php加載的模塊有哪些:
4.4 PHP是做爲apache的擴展模塊存在:
/usr/local/apache2.4/bin/apachectl -M
php5_module (shared)
4.5 /usr/local/apache2.4/conf/httpd.conf apache配置文件內家在了一行php模塊
1. 安裝php7:
• cd /usr/local/src/
• wget http://cn2.php.net/get/php-7.2.4.tar.gz/from/this/mirror
• tar -zxvf mirror
• cd php-7.2.4/
• ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
• make && make install
• cp php.ini-production /usr/local/php7/etc/php.ini
2. php7相關文件及操做:
2.1 查看apache中加載的php7模塊:
ls /usr/local/apache2.4/modules/libphp7.so
2.2 apache配置文件中加載php7模塊
注:能夠修改此處配置文件切換使用php5或則php7