[LAMP]安裝PHP5/7
目前主流的php版本是5.6和7.1。和php 5相比,php 7對於效能的提升的很大的,對於自身的處理速度優化了很多,同時也改變了一些語法的使用。但由於很多軟體都是基於php 5的,因此php 5和7的安裝和配置都要熟練掌握。
安裝PHP 5
1、下載安裝包
1
2
3
4
5
6
7
8
9
10
11
|
[root@juispan src] # wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
--2017-07-21 07:39:35-- http: //cn2 .php.net /distributions/php-5 .6.30. tar .gz
正在解析主機 cn2.php.net (cn2.php.net)... 220.181.136.41, 220.181.136.30, 220.181.136.55, ... 正在連線 cn2.php.net (cn2.php.net)|220.181.136.41|:80... 已連線。 已發出 HTTP 請求,正在等待回應... 200 OK 長度:19274631 (18M) [application /x-gzip ]
正在儲存至: “php-5.6.30. tar .gz”
100%[==============================================>] 19,274,631 518KB /s 用時 34s
2017-07-21 07:40:10 (552 KB /s ) - 已儲存 “php-5.6.30. tar .gz” [19274631 /19274631 ])
|
2、解壓壓縮包
1
|
[root@juispan src] # tar zxf php-5.6.30.tar.gz
|
3、配置php
1
2
|
[root@juispan src] # cd php-5.6.30
[root@juispan 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
|
在配置過程中,會遇到一個接一個的配置失敗,這裡需要耐心處理。
問題1:configure: error: xml2-config not found. Please check your libxml2 installation.
1
|
[root@juispan php-5.6.30] # yum install -y libxml2-devel
|
問題2:configure: error: Cannot find OpenSSL`s <evp.h>
1
|
[root@juispan php-5.6.30] # yum install -y openssl-devel
|
問題3:configure: error: Please reinstall the BZip2 distribution
1
|
[root@juispan php-5.6.30] # yum install -y bzip2-devel
|
問題4:configure: error: jpeglib.h not found.
1
|
[root@juispan php-5.6.30] # yum install -y libjpeg-turbo-devel
|
問題5:configure: error: png.h not found.
1
|
[root@juispan php-5.6.30] # yum install -y libpng-devel
|
問題6:configure: error: freetype-config not found.
1
|
[root@juispan php-5.6.30] # yum install -y freetype-devel
|
問題7:configure: error: mcrypt.h not found. Please reinstall libmcrypt.
1
|
[root@juispan php-5.6.30] # yum install -y libmcrypt-devel
|
處理完以上問題後,重新配置出現以下文字:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
Generating files configure: creating . /config .status
creating main /internal_functions .c
creating main /internal_functions_cli .c
+--------------------------------------------------------------------+ | License: | | This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. | | If you do not agree with the terms of this license, you must abort |
| the installation process at this point. | +--------------------------------------------------------------------+ Thank you for using PHP.
config.status: creating php5.spec config.status: creating main /build-defs .h
config.status: creating scripts /phpize
config.status: creating scripts /man1/phpize .1
config.status: creating scripts /php-config
config.status: creating scripts /man1/php-config .1
config.status: creating sapi /cli/php .1
config.status: creating sapi /cgi/php-cgi .1
config.status: creating ext /phar/phar .1
config.status: creating ext /phar/phar .phar.1
config.status: creating main /php_config .h
config.status: executing default commands |
以上文字內容表示配置成功,如果不放心可以用“echo $?”確認下。
4、編譯與安裝
1
2
3
4
|
[root@juispan php-5.6.30] # make &&make install
[root@juispan php-5.6.30] # echo $?
0 [root@juispan php-5.6.30] # cp php.ini-production /usr/local/php/etc/php.ini
|
5、檢視與驗證
1
2
3
4
5
6
|
[root@juispan php-5.6.30] # du -sh /usr/local/apache2.4/modules/libphp5.so
37M /usr/local/apache2 .4 /modules/libphp5 .so
[root@juispan php-5.6.30] # cat /usr/local/apache2.4/conf/httpd.conf | grep -i php
LoadModule php5_module modules /libphp5 .so
[root@juispan php-5.6.30] # /usr/local/apache2.4/bin/httpd -M | tail -1
php5_module (shared)
|
前幾章說過,php在LAMP架構裡的作用只是Apache用於與mysql之間通訊的橋樑。因此,只要apache2.4的modules檔案裡有libphp5.so檔案,且在配置檔案裡有相應的配置即可。即使刪除php的安裝目錄也不會有太大的影響。
安裝PHP 7
1、下載安裝包
1
2
|
[root@juispan php-5.6.30] # cd /usr/local/src
[root@juispan src] # wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
|
2、解壓壓縮包
1
2
3
4
5
6
7
|
[root@juispan src] # tar jxf php-7.1.6.tar.bz2
tar (child): bzip2 :無法 exec : 沒有那個檔案或目錄
tar (child): Error is not recoverable: exiting now
tar : Child returned status 2
tar : Error is not recoverable: exiting now
[root@juispan src] # yum install -y bzip2
[root@juispan src] # tar jxf php-7.1.6.tar.bz2
|
3、配置php
1
2
3
4
|
[root@juispan src] # cd php-7.1.6
[root@juispan 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@juispan php-7.1.6] # echo $?
0 |
4、編譯與安裝
1
2
3
|
[root@juispan php-7.1.6] # make &&make install
[root@juispan php-7.1.6] # echo $?
0 |
5、檢視與驗證
1
2
3
4
5
6
7
8
9
|
[root@juispan php-7.1.6] # ls /usr/local/apache2.4/modules/libphp7.so
/usr/local/apache2 .4 /modules/libphp7 .so
[root@juispan php-7.1.6] # cp php.ini-production /usr/local/php7/etc/php.ini
[root@juispan php-7.1.6] # cat /usr/local/apache2.4/conf/httpd.conf | grep -i php
LoadModule php5_module modules /libphp5 .so
LoadModule php7_module modules /libphp7 .so
[root@juispan php-7.1.6] # /usr/local/apache2.4/bin/httpd -M | tail -2
php5_module (shared)
php7_module (shared)
|
相關文章
- php5安裝PHP
- lamp安裝LAMP
- Ubuntu php5安裝UbuntuPHP
- yum安裝lampLAMP
- LAMP原始碼安裝+wordpress安裝LAMP原始碼
- 原始碼安裝lamp原始碼LAMP
- LAMP:用yum安裝LAMP
- php5安裝後phpinfo顯示空白PHP
- 編譯安裝LAMP環境編譯LAMP
- LAMP原始碼編譯安裝LAMP原始碼編譯
- Ubuntu Linux下為PHP5安裝cURLUbuntuLinuxPHP
- ubuntu sever 倆個命令安裝 lampUbuntuLAMP
- centos6.0LAMP原始碼安裝CentOSLAMP原始碼
- php擴充套件模組安裝-lampPHP套件LAMP
- LAMP一體環境快速安裝LAMP
- [LAMP]Php-5.3.29編譯安裝LAMPPHP編譯
- [LAMP]Mysql-5.6.28編譯安裝LAMPMySql編譯
- LAMP兩種編譯安裝模式LAMP編譯模式
- LAMP 編譯安裝基本步驟LAMP編譯
- LAMP架構(LAMP介紹,mysql/mariaDB介紹,Mysql安裝)LAMP架構MySql
- 如何在DebianStretch中安裝使用PHP5PHP
- centos5安裝PHP5時遇到問題CentOSPHP
- [LAMP]【轉載】——PHP7.0的安裝LAMPPHP
- 在Ubuntu上安裝LAMP伺服器UbuntuLAMP伺服器
- 詳解LAMP原始碼編譯安裝LAMP原始碼編譯
- linux下LAMP原始碼安裝部署LinuxLAMP原始碼
- LAMP原始碼編譯安裝配置+wordpressLAMP原始碼編譯
- 搭建LAMP中安裝PHP遇到的故障LAMPPHP
- [LAMP]Apache-2.2.31編譯安裝LAMPApache編譯
- virtualboxcentos7虛擬機器安裝lamp(apache+mysql5.5+php5.5+redis)CentOS虛擬機LAMPApacheMySqlPHPRedis
- centos7lamp搭建CentOSLAMP
- centos 7.2 64位 docker安裝lamp環境CentOSDockerLAMP
- CentOS下LAMP一鍵yum安裝指令碼CentOSLAMP指令碼
- LAMP架構的安裝與經驗技巧LAMP架構
- LAMP架構介紹、MYSQL介紹、安裝LAMP架構MySql
- [LAMP]php動態擴充套件模組安裝LAMPPHP套件
- LAMP純原始碼編譯安裝日誌LAMP原始碼編譯
- 搭建lamp環境以及安裝配置phpmyadminLAMPPHP