日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

apxs php5,安装PHP5和PHP7

發(fā)布時間:2024/9/19 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 apxs php5,安装PHP5和PHP7 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

11.10-11.12 安裝PHP5

PHP官網www.php.net

當前主流版本為5.6/7.1

cd /usr/local/src/

#進入到src目錄

[root@localhost mysql]# cd ../src/

下載

#下載PHP軟件包 由于是國內的鏡像,有可能失效

[root@localhost src]# wget http://cn2.php.net/distributions/php-5.6.30.tar.gz

解壓

#解壓軟件包

[root@localhost src]# tar zxvf php-5.6.30.tar.gz

進入到php-5.6.30目錄里

[root@localhost src]# cd php-5.6.30

[root@localhost php-5.6.30]#

yum安裝支持庫

[root@taoyun php-5.6.30]# yum install -y libxml2-devel

[root@taoyun php-5.6.30]# yum install -y openssl-devel

[root@taoyun php-5.6.30]# yum install -y bzip2-devel

[root@taoyun php-5.6.30]# yum -y install libjpeg-devel

[root@taoyun php-5.6.30]# yum -y install libpng-devel

[root@taoyun php-5.6.30]# yum -y install freetype-devel

[root@taoyun php-5.6.30]# yum install -y epel-release

[root@taoyun php-5.6.30]# yum install -y libmcrypt-devel

安裝

[root@localhost php-5.6.30]# \

./configure --prefix=/usr/local/php \

#指定安裝目錄

--with-apxs2=/usr/local/apache2.4/bin/apxs \

#apxs2是Apache的工具,可以自動安裝擴展模塊和配置

--with-config-file-path=/usr/local/php/etc \

#指定配置文件所在路徑

--with-mysql=/usr/local/mysql \

#指定mysql的路徑

#老版本的php用mysql

--with-pdo-mysql=/usr/local/mysql \

#指定pdo-mysql的路徑

--with-mysqli=/usr/local/mysql/bin/mysql_config \

#指定mysqli的路徑

#新版本用mysqli,不在使用mysql

#上述三種是mysql不同的庫,原因是生成一個識別交換驅動模塊

--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@taoyun 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個報錯:

翻譯:

對不起,我不能運行apxs。可能的原因:

1 .工作Perl是沒有安裝

2。apx型沒有發(fā)現(xiàn)。嘗試通過使用- apxs2=/path/to/ apxs來傳遞路徑

3 .產品Apache并沒有使用- enable -所以(apxs使用頁面被顯示)

/usr/local/apache2.4/bin/apxs的輸出如下:

./configure: /usr/local/apache2.4/bin/apxs: /replace/with/path/to/perl/interpreter:沒有這樣的文件或目錄

配置:錯誤:異常終止

解決步驟:

1、根據不能run apxs 。cd 到apache的bin目錄下運行./apxs 運行結果

[root@localhost bin]# ./apxs

-bash: ./apxs: /replace/with/path/to/perl/interpreter: 壞的解釋器: 沒有那個文件或目錄

2、vim apxs文件 找“/replace/with/path/to/perl/interpreter”關鍵字

在第一個行 :#!/replace/with/path/to/perl/interpreter -w

根據perl的安裝目錄 /usr/bin/perl

修改為:#! /usr/bin/perl -w

3、運行第一步。或者直接 ./configure ^^^^^

第2個報錯

checking for xml2-config path...

configure: error: xml2-config not found. Please check your libxml2 installation.

解決方法:

#查找libxml2

[root@localhost php-5.6.30]# yum list |grep libxml2

#yum安裝libxml2庫

[root@localhost php-5.6.30]# yum -y install libxml2-devel

第3個報錯

checking for pkg-config... /usr/bin/pkg-config

configure: error: Cannot find OpenSSL's

解決方法:

[root@localhost php-5.6.30]# yum install -y openssl-devel

第4個報錯

checking for BZip2 in default path... not found

configure: error: Please reinstall the BZip2 distribution

解決方法:

[root@localhost php-5.6.30]# yum install -y bzip2-devel

第5個報錯

checking whether to enable JIS-mapped Japanese font support in GD... no

If configure fails try --with-vpx-dir=

configure: error: jpeglib.h not found.

解決方法:

[root@localhost php-5.6.30]# yum -y install libjpeg-devel

第6個報錯

checking for jpeg_read_header in -ljpeg... yes

configure: error: png.h not found.

解決方法:

[root@localhost php-5.6.30]# yum -y install libpng-devel

第7個報錯

If configure fails try --with-xpm-dir=

configure: error: freetype-config not found.

解決方法:

[root@localhost php-5.6.30]# yum -y install freetype-devel

第8個報錯

checking for mcrypt support... yes

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

解決方法:

[root@localhost php-5.6.30]# yum install -y epel-release

[root@localhost php-5.6.30]# yum install -y libmcrypt-devel

安裝完畢!

開始編譯與安裝

make && make install

查看一下PHP文件

[root@localhost php-5.6.30]# ls /usr/local/php/bin/

pear peardev pecl phar phar.phar php php-cgi php-config phpize

#查看一下文件大小

[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

#php是通過libphp5.so文件結合起來

#查看PHP所加載的模塊命令,并且全部都是靜態(tài)的

[root@localhost php-5.6.30]# /usr/local/php/bin/php -m

開配置配置文件

[root@localhost php-5.6.30]# cp php.ini-production /usr/local/php/etc/php.ini

[root@localhost php-5.6.30]# vim /usr/local/php/etc/php.ini

11.13 安裝PHP7

下載源碼包到/usr/local/src/目錄下

#進入src目錄

[root@localhost ~]# cd /usr/local/src/

[root@localhost src]#

#下載

[root@localhost src]# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2

[root@localhost src]# ls

php-7.1.6.tar.bz2

解壓壓縮包

解壓

[root@localhost src]# tar jxvf php-7.1.6.tar.bz2

[root@localhost src]# ls

php-7.1.6 php-7.1.6.tar.bz2

進入目錄

[root@localhost src]# cd php-7.1.6

[root@localhost 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

第一個報錯:

Configuring SAPI modules

checking for Apache 2.0 handler-module support via DSO through APXS...

Sorry, I cannot run apxs. Possible reasons follow:

1. Perl is not installed

2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs

3. Apache was not built using --enable-so (the apxs usage page is displayed)

The output of /usr/local/apache2.4/bin/apxs follows:

./configure: line 6199: /usr/local/apache2.4/bin/apxs: No such file or directory

configure: error: Aborting

解決方法:

安裝apache,安裝方法請查看https://blog.51cto.com/3622288/2051242

第二個報錯:

checking libxml2 install dir... yes

checking for xml2-config path...

configure: error: xml2-config not found. Please check your libxml2 installation.

解決方法:

[root@localhost php-7.1.6]# yum -y install libxml2-devel

第三個報錯:

checking for pkg-config... /usr/bin/pkg-config

configure: error: Cannot find OpenSSL's

解決方法:

[root@localhost php-7.1.6]# yum -y install openssl-devel

第四個報錯:

checking for BZip2 in default path... not found

configure: error: Please reinstall the BZip2 distribution

解決方法:

[root@localhost php-7.1.6]# yum -y install bzip2-devel

第五個報錯:

If configure fails try --with-webp-dir=

configure: error: jpeglib.h not found.

解決方法:

[root@localhost php-7.1.6]# yum -y install libjpeg-devel

第六個報錯:

checking for jpeg_read_header in -ljpeg... yes

configure: error: png.h not found.

解決方法:

[root@localhost php-7.1.6]# yum -y install libpng-devel

第七個報錯:

If configure fails try --with-xpm-dir=

configure: error: freetype-config not found.

解決方法:

[root@localhost php-7.1.6]# yum -y install freetype-devel

第八個報錯:

checking for mcrypt support... yes

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

解決方法:

[root@localhost php-7.1.6]# yum -y install epel-release

#安裝libtomcrypt-devel之前必須安裝epel-release,原因是依賴關系

[root@localhost php-7.1.6]# yum -y install libtomcrypt-devel

第九個報錯:

mysql_config not found

configure: error: Please reinstall the mysql distribution

解決方法:

#安裝完成后執(zhí)行

[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

配置成功!

最后執(zhí)行 make && make install

如果不確定有沒有編譯安裝好,可以在執(zhí)行命令之后 用echo $? 檢查命令是否出錯。

安裝完畢!

php模塊路徑

[root@localhost php7]# ls /usr/local/apache2.4/modules/libphp7.so

/usr/local/apache2.4/modules/libphp7.so

查看php7加載模塊

[root@localhost php7]# /usr/local/php7/bin/php -m

查看apache加載了幾個php,通過修改配置文件來指定使用php5還是php7模塊,不要的就注釋掉

[root@localhost php7]# vim /usr/local/apache2.4/conf/httpd.conf

把php7的參考配置文件復制到php7的配置文件目錄下

[root@taoyun php-7.1.6]# cp php.ini-production /usr/local/php7/etc/php.ini

[root@taoyun php-7.1.6]# ls /usr/local/php7/etc/

pear.conf php.ini

總結

以上是生活随笔為你收集整理的apxs php5,安装PHP5和PHP7的全部內容,希望文章能夠幫你解決所遇到的問題。

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