日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

【CentOS 7LAMP架构4】,PHP5和PHP7的安装和配置#171219

發布時間:2025/3/8 php 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【CentOS 7LAMP架构4】,PHP5和PHP7的安装和配置#171219 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業重金招聘Python工程師標準>>>

hellopasswd


安裝PHP5

  • PHP官網www.php.net
  • 當前主流版本為5.6/7.1
  • cd /usr/local/src
  • wget http://cn2.php.net/distributions/php-5.6.30.tar.bz2
  • bzip2 -d php-5.6.30.tar.bz2
  • tar xvf php-5.6.30.tar
  • cd php-5.6.30
  • ./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-exif
  • make && make install
  • cp php.ini-production /usr/local/php/etc/php.ini
[root@localhost ~]# cd /usr/local/src [root@localhost src]# wget http://cn2.php.net/distributions/php-5.6.30.tar.bz2 --2017-12-19 04:25:24-- http://cn2.php.net/distributions/php-5.6.30.tar.bz2 Resolving cn2.php.net (cn2.php.net)... 123.125.23.169, 123.125.23.172, 123.125.23.168, ... Connecting to cn2.php.net (cn2.php.net)|123.125.23.169|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 15011816 (14M) [application/octet-stream] Saving to: ‘php-5.6.30.tar.bz2’100%[======================================================================================>] 15,011,816 367KB/s in 47s 2017-12-19 04:26:11 (313 KB/s) - ‘php-5.6.30.tar.bz2’ saved [15011816/15011816][root@localhost src]# bzip2 -d php-5.6.30.tar.bz2 [root@localhost src]# tar -xf php-5.6.30.tar [root@localhost src]# cd php-5.6.30/ [root@localhost php-5.6.30]# ./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-exif#編譯過程... [root@localhost php-5.6.30]# echo $? 1

編譯過程會存在錯誤,就需要添加對應庫

安裝依賴庫

configure: error: xml2-config not found. Please check your libxml2 installation.‘ [root@localhost php-5.6.30]# yum install -y libxml2-devel Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile* epel: mirror.rise.ph Resolving Dependencies --> Running transaction check ---> Package libxml2-devel.x86_64 0:2.9.1-6.el7_2.3 will be installed --> Processing Dependency: libxml2 = 2.9.1-6.el7_2.3 for package: libxml2-devel-2.9.1-6.el7_2.3.x86_64 --> Processing Dependency: xz-devel for package: libxml2-devel-2.9.1-6.el7_2.3.x86_64 --> Running transaction check ---> Package libxml2.x86_64 0:2.9.1-5.el7 will be updated ---> Package libxml2.x86_64 0:2.9.1-6.el7_2.3 will be an update ---> Package xz-devel.x86_64 0:5.2.2-1.el7 will be installed --> Processing Dependency: xz-libs = 5.2.2-1.el7 for package: xz-devel-5.2.2-1.el7.x86_64 --> Running transaction check ---> Package xz-libs.x86_64 0:5.1.2-8alpha.el7 will be updated --> Processing Dependency: xz-libs = 5.1.2-8alpha.el7 for package: xz-5.1.2-8alpha.el7.x86_64 ---> Package xz-libs.x86_64 0:5.2.2-1.el7 will be an update --> Running transaction check ---> Package xz.x86_64 0:5.1.2-8alpha.el7 will be updated ---> Package xz.x86_64 0:5.2.2-1.el7 will be an update --> Finished Dependency ResolutionDependencies Resolved================================================================================================================================Package Arch Version Repository Size ================================================================================================================================ Installing:libxml2-devel x86_64 2.9.1-6.el7_2.3 base 1.0 M Installing for dependencies:xz-devel x86_64 5.2.2-1.el7 base 46 k Updating for dependencies:libxml2 x86_64 2.9.1-6.el7_2.3 base 668 kxz x86_64 5.2.2-1.el7 base 229 kxz-libs x86_64 5.2.2-1.el7 base 103 kTransaction Summary ================================================================================================================================ Install 1 Package (+1 Dependent package) Upgrade ( 3 Dependent packages)Total download size: 2.1 M Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. (1/5): libxml2-2.9.1-6.el7_2.3.x86_64.rpm | 668 kB 00:00:02 (2/5): xz-5.2.2-1.el7.x86_64.rpm | 229 kB 00:00:01 (3/5): libxml2-devel-2.9.1-6.el7_2.3.x86_64.rpm | 1.0 MB 00:00:03 (4/5): xz-devel-5.2.2-1.el7.x86_64.rpm | 46 kB 00:00:00 (5/5): xz-libs-5.2.2-1.el7.x86_64.rpm | 103 kB 00:00:00 -------------------------------------------------------------------------------------------------------------------------------- Total 470 kB/s | 2.1 MB 00:00:04 Running transaction check Running transaction test Transaction test succeeded Running transactionUpdating : xz-libs-5.2.2-1.el7.x86_64 1/8 Installing : xz-devel-5.2.2-1.el7.x86_64 2/8 Updating : libxml2-2.9.1-6.el7_2.3.x86_64 3/8 Installing : libxml2-devel-2.9.1-6.el7_2.3.x86_64 4/8 Updating : xz-5.2.2-1.el7.x86_64 5/8 Cleanup : xz-5.1.2-8alpha.el7.x86_64 6/8 Cleanup : libxml2-2.9.1-5.el7.x86_64 7/8 Cleanup : xz-libs-5.1.2-8alpha.el7.x86_64 8/8 Verifying : xz-devel-5.2.2-1.el7.x86_64 1/8 Verifying : libxml2-devel-2.9.1-6.el7_2.3.x86_64 2/8 Verifying : libxml2-2.9.1-6.el7_2.3.x86_64 3/8 Verifying : xz-5.2.2-1.el7.x86_64 4/8 Verifying : xz-libs-5.2.2-1.el7.x86_64 5/8 Verifying : libxml2-2.9.1-5.el7.x86_64 6/8 Verifying : xz-5.1.2-8alpha.el7.x86_64 7/8 Verifying : xz-libs-5.1.2-8alpha.el7.x86_64 8/8 Installed:libxml2-devel.x86_64 0:2.9.1-6.el7_2.3 Dependency Installed:xz-devel.x86_64 0:5.2.2-1.el7 Dependency Updated:libxml2.x86_64 0:2.9.1-6.el7_2.3 xz.x86_64 0:5.2.2-1.el7 xz-libs.x86_64 0:5.2.2-1.el7 Complete!

然后再編譯一次,直到成功

configure: error: Please reinstall the BZip2 distribution [root@localhost php-5.6.30]# yum install -y bzip2-devel Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile* epel: mirror.vinahost.vn Resolving Dependencies --> Running transaction check ---> Package bzip2-devel.x86_64 0:1.0.6-13.el7 will be installed --> Finished Dependency ResolutionDependencies Resolved================================================================================================================================Package Arch Version Repository Size ================================================================================================================================ Installing:bzip2-devel x86_64 1.0.6-13.el7 base 218 kTransaction Summary ================================================================================================================================ Install 1 PackageTotal download size: 218 k Installed size: 382 k Downloading packages: bzip2-devel-1.0.6-13.el7.x86_64.rpm | 218 kB 00:00:03 Running transaction check Running transaction test Transaction test succeeded Running transactionInstalling : bzip2-devel-1.0.6-13.el7.x86_64 1/1 Verifying : bzip2-devel-1.0.6-13.el7.x86_64 1/1 Installed:bzip2-devel.x86_64 0:1.0.6-13.el7 Complete! configure: error: jpeglib.h not found. [root@localhost php-5.6.30]# yum install -y libjpeg-devel Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile* epel: mirror01.idc.hinet.net Resolving Dependencies --> Running transaction check ---> Package libjpeg-turbo-devel.x86_64 0:1.2.90-5.el7 will be installed --> Finished Dependency ResolutionDependencies Resolved================================================================================================================================Package Arch Version Repository Size ================================================================================================================================ Installing:libjpeg-turbo-devel x86_64 1.2.90-5.el7 base 98 kTransaction Summary ================================================================================================================================ Install 1 PackageTotal download size: 98 k Installed size: 314 k Downloading packages: libjpeg-turbo-devel-1.2.90-5.el7.x86_64.rpm | 98 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transactionInstalling : libjpeg-turbo-devel-1.2.90-5.el7.x86_64 1/1 Verifying : libjpeg-turbo-devel-1.2.90-5.el7.x86_64 1/1 Installed:libjpeg-turbo-devel.x86_64 0:1.2.90-5.el7 Complete! configure: error: png.h not found. [root@localhost php-5.6.30]# yum install -y libpng-devel Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile* epel: mirror01.idc.hinet.net Resolving Dependencies --> Running transaction check ---> Package libpng-devel.x86_64 2:1.5.13-7.el7_2 will be installed --> Finished Dependency ResolutionDependencies Resolved================================================================================================================================Package Arch Version Repository Size ================================================================================================================================ Installing:libpng-devel x86_64 2:1.5.13-7.el7_2 base 122 kTransaction Summary ================================================================================================================================ Install 1 PackageTotal download size: 122 k Installed size: 211 k Downloading packages: libpng-devel-1.5.13-7.el7_2.x86_64.rpm | 122 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transactionInstalling : 2:libpng-devel-1.5.13-7.el7_2.x86_64 1/1 Verifying : 2:libpng-devel-1.5.13-7.el7_2.x86_64 1/1 Installed:libpng-devel.x86_64 2:1.5.13-7.el7_2 Complete! configure: error: freetype-config not found [root@localhost php-5.6.30]# yum install -y freetype-devel Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile* epel: mirror01.idc.hinet.net Resolving Dependencies --> Running transaction check ---> Package freetype-devel.x86_64 0:2.4.11-15.el7 will be installed --> Finished Dependency ResolutionDependencies Resolved================================================================================================================================Package Arch Version Repository Size ================================================================================================================================ Installing:freetype-devel x86_64 2.4.11-15.el7 base 356 kTransaction Summary ================================================================================================================================ Install 1 PackageTotal download size: 356 k Installed size: 2.4 M Downloading packages: freetype-devel-2.4.11-15.el7.x86_64.rpm | 356 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transactionInstalling : freetype-devel-2.4.11-15.el7.x86_64 1/1 Verifying : freetype-devel-2.4.11-15.el7.x86_64 1/1 Installed:freetype-devel.x86_64 0:2.4.11-15.el7 Complete! configure: error: mcrypt.h not found. Please reinstall libmcrypt. [root@localhost php-5.6.30]# yum install -y libmcrypt-devel Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile* epel: mirror01.idc.hinet.net Resolving Dependencies --> Running transaction check ---> Package libmcrypt-devel.x86_64 0:2.5.8-13.el7 will be installed --> Processing Dependency: libmcrypt = 2.5.8-13.el7 for package: libmcrypt-devel-2.5.8-13.el7.x86_64 --> Processing Dependency: libmcrypt.so.4()(64bit) for package: libmcrypt-devel-2.5.8-13.el7.x86_64 --> Running transaction check ---> Package libmcrypt.x86_64 0:2.5.8-13.el7 will be installed --> Finished Dependency ResolutionDependencies Resolved================================================================================================================================Package Arch Version Repository Size ================================================================================================================================ Installing:libmcrypt-devel x86_64 2.5.8-13.el7 epel 13 k Installing for dependencies:libmcrypt x86_64 2.5.8-13.el7 epel 99 kTransaction Summary ================================================================================================================================ Install 1 Package (+1 Dependent package)Total download size: 112 k Installed size: 302 k Downloading packages: (1/2): libmcrypt-devel-2.5.8-13.el7.x86_64.rpm | 13 kB 00:00:00 (2/2): libmcrypt-2.5.8-13.el7.x86_64.rpm | 99 kB 00:00:00 -------------------------------------------------------------------------------------------------------------------------------- Total 112 kB/s | 112 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transactionInstalling : libmcrypt-2.5.8-13.el7.x86_64 1/2 Installing : libmcrypt-devel-2.5.8-13.el7.x86_64 2/2 Verifying : libmcrypt-devel-2.5.8-13.el7.x86_64 1/2 Verifying : libmcrypt-2.5.8-13.el7.x86_64 2/2 Installed:libmcrypt-devel.x86_64 0:2.5.8-13.el7 Dependency Installed:libmcrypt.x86_64 0:2.5.8-13.el7 Complete!

上面的包依賴于epel-release的擴展源,必須先安裝

[root@localhost php-5.6.30]# ./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-exif#編譯過程... [root@localhost php-5.6.30]# echo $?0 [root@localhost php-5.6.30]# make && make install#編譯過程... [root@localhost php-5.6.30]# echo $?0 [root@localhost php-5.6.30]# ls /usr/local/php bin etc include lib php [root@localhost php-5.6.30]# du -sh /usr/local/php/bin/php 36M /usr/local/php/bin/php [root@localhost php-5.6.30]# du -sh /usr/local/apache2.4/modules/libphp5.so 37M /usr/local/apache2.4/modules/libphp5.so

靜態模塊

[root@localhost php-5.6.30]# /usr/local/php/bin/php -m [PHP Modules] bz2 Core ctype date dom ereg exif fileinfo filter gd hash iconv json libxml mbstring mcrypt mysql mysqli openssl pcre PDO pdo_mysql pdo_sqlite Phar posix Reflection session SimpleXML soap sockets SPL sqlite3 standard tokenizer xml xmlreader xmlwriter zlib[Zend Modules]

對比apache

[root@localhost php-5.6.30]# /usr/local/apache2.4/b -M bin/ build/ [root@localhost php-5.6.30]# /usr/local/apache2.4/bin/httpd -M AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message Loaded Modules:core_module (static)so_module (static)http_module (static)mpm_event_module (static)authn_file_module (shared)authn_core_module (shared)authz_host_module (shared)authz_groupfile_module (shared)authz_user_module (shared)authz_core_module (shared)access_compat_module (shared)auth_basic_module (shared)reqtimeout_module (shared)filter_module (shared)mime_module (shared)log_config_module (shared)env_module (shared)headers_module (shared)setenvif_module (shared)version_module (shared)unixd_module (shared)status_module (shared)autoindex_module (shared)dir_module (shared)alias_module (shared)php5_module (shared)

apache配置文件

[root@localhost php-5.6.30]# vi /usr/local/apache2.4/conf/httpd.conf/php5.so152 LoadModule php5_module modules/libphp5.so [root@localhost php-5.6.30]# /usr/local/php/bin/php -i | lessphpinfo() PHP Version => 5.6.30System => Linux localhost.localdomain 3.10.0-123.el7.x86_64 #1 SMP Mon Jun 30 12:09:22 UTC 2014 x86_64 Build Date => Dec 19 2017 05:07:49 Configure Command => './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-exif' Server API => Command Line Interface Virtual Directory Support => enabled Configuration File (php.ini) Path => /usr/local/php/etc: [root@localhost php-5.6.30]# ls /usr/local/php/etc/ pear.conf

但并沒有加載任何配置,因為/usr/local/php/etc為空

[root@localhost php-5.6.30]# cp php.ini-production /usr/local/php/etc/php.ini Build Date => Dec 19 2017 05:07:49

php.ini-development開發環境使用 php.ini-production生產環境使用

[root@localhost php-5.6.30]# /usr/local/php/bin/php -i | less Configure Command => './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-exif' Server API => Command Line Interface Virtual Directory Support => enabled Configuration File (php.ini) Path => /usr/local/php/etc :PHP Warning: Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Unknown on line 0

將date.timezone = Asia/Shanghai

安裝PHP7

  • cd /usr/local/src/
  • wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
  • tar jxf php-7.1.6.tar.bz2
  • ./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
  • ls /usr/local/apache2.4/modules/libphp7.so
  • cp php.ini-production /usr/local/php7/etc/php.ini
[root@localhost php-5.6.30]# cd /usr/local/src/ [root@localhost src]# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2 --2017-11-03 23:10:53-- http://cn2.php.net/distributions/php-7.1.6.tar.bz2 Resolving cn2.php.net (cn2.php.net)... 123.125.23.169, 123.125.23.171, 123.125.23.172, ... Connecting to cn2.php.net (cn2.php.net)|123.125.23.169|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 15732452 (15M) [application/octet-stream] Saving to: ‘php-7.1.6.tar.bz2’100%[=============================================>] 15,732,452 3.53MB/s in 6.0s 2017-11-03 23:10:59 (2.48 MB/s) - ‘php-7.1.6.tar.bz2’ saved [15732452/15732452] [root@localhost src]# tar jxf php-7.1.6.tar.bz2 [root@localhost src]# cd php-7.1.6/ [root@localhost php-7.1.6]# ./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#編譯過程... [root@localhost php-7.1.6]# make && make install#編譯過程... [root@localhost php-7.1.6]# du -sh /usr/local/apache2.4/modules/libphp7.so 37M /usr/local/apache2.4/modules/libphp7.so [root@localhost php-7.1.6]# /usr/local/php7/bin/php -m [PHP Modules] bz2 Core ctype date dom exif fileinfo filter gd hash iconv json libxml mbstring mcrypt mysqli openssl pcre PDO pdo_mysql pdo_sqlite Phar posix Reflection session SimpleXML soap sockets SPL sqlite3 standard tokenizer xml xmlreader xmlwriter zlib[Zend Modules]

與php5加載的模塊是一致的

查看apache加載的php

[root@localhost php-7.1.6]# /usr/local/apache2.4/bin/apachectl -M AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message Loaded Modules:core_module (static)so_module (static)http_module (static)mpm_event_module (static)authn_file_module (shared)authn_core_module (shared)authz_host_module (shared)authz_groupfile_module (shared)authz_user_module (shared)authz_core_module (shared)access_compat_module (shared)auth_basic_module (shared)reqtimeout_module (shared)filter_module (shared)mime_module (shared)log_config_module (shared)env_module (shared)headers_module (shared)setenvif_module (shared)version_module (shared)unixd_module (shared)status_module (shared)autoindex_module (shared)dir_module (shared)alias_module (shared)php5_module (shared)php7_module (shared) [root@localhost php-7.1.6]# vi /usr/local/apache2.4/conf/httpd.conf145 #LoadModule negotiation_module modules/mod_negotiation.so146 LoadModule dir_module modules/mod_dir.so147 #LoadModule actions_module modules/mod_actions.so148 #LoadModule speling_module modules/mod_speling.so149 #LoadModule userdir_module modules/mod_userdir.so150 LoadModule alias_module modules/mod_alias.so151 #LoadModule rewrite_module modules/mod_rewrite.so152 LoadModule php5_module modules/libphp5.so153 LoadModule php7_module modules/libphp7.so154 155 <IfModule unixd_module>156 #157 # If you wish httpd to run as a different user or group, you must run158 # httpd as root initially and it will switch.159 #160 # User/Group: The name (or #number) of the user/group to run httpd as.

若不使用有不使用則注釋那一行

145 #LoadModule negotiation_module modules/mod_negotiation.so146 LoadModule dir_module modules/mod_dir.so147 #LoadModule actions_module modules/mod_actions.so148 #LoadModule speling_module modules/mod_speling.so149 #LoadModule userdir_module modules/mod_userdir.so150 LoadModule alias_module modules/mod_alias.so151 #LoadModule rewrite_module modules/mod_rewrite.so152 LoadModule php5_module modules/libphp5.so153 #LoadModule php7_module modules/libphp7.so154 155 <IfModule unixd_module>156 #157 # If you wish httpd to run as a different user or group, you must run158 # httpd as root initially and it will switch.159 #160 # User/Group: The name (or #number) of the user/group to run httpd as. [root@localhost php-7.1.6]# cp php.ini-production /usr/local/php7/etc/php.ini [root@localhost php-7.1.6]# /usr/local/php7/bin/php -i | less phpinfo() PHP Version => 7.1.6System => Linux localhost.localdomain 3.10.0-123.el7.x86_64 #1 SMP Mon Jun 30 12:09:22 UTC 2014 x86_64 Build Date => Nov 3 2017 23:24:40 Configure Command => './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' Server API => Command Line Interface Virtual Directory Support => enabled Configuration File (php.ini) Path => /usr/local/php7/etc Loaded Configuration File => /usr/local/php7/etc/php.ini

修改與171219

轉載于:https://my.oschina.net/hellopasswd/blog/1591683

總結

以上是生活随笔為你收集整理的【CentOS 7LAMP架构4】,PHP5和PHP7的安装和配置#171219的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。