CentOS7Apache2.4.23+php-5.6.30安裝配置-創(chuàng)新互聯(lián)

下載Apache安裝包  httpd-2.4.23.tar.gz

創(chuàng)新互聯(lián)公司是一家集網(wǎng)站建設(shè),興山企業(yè)網(wǎng)站建設(shè),興山品牌網(wǎng)站建設(shè),網(wǎng)站定制,興山網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷,網(wǎng)絡(luò)優(yōu)化,興山網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。

下載地址:http://apache.fayea.com/httpd/

Apache 安裝要求

必須安裝APR、APR-Util、PCRE,gcc、gcc-c++等包

安裝gcc和gcc-c++我采用yum安裝的方式

yum -y install gcc gcc-c++

編譯命令:(除了指定Apache的安裝目錄外,還要安裝apr、apr-util、pcre,并指定參數(shù))

[root@bogon software]# wget http://archive.apache.org/dist/httpd/httpd-2.4.23.tar.gz [root@bogon software]# tar -zxvf httpd-2.4.23.tar.gz [root@bogon software]# cd httpd-2.4.23 [root@bogon httpd-2.4.23]# ./configure --prefix=/usr/local/apache2 \ --with-apr=/usr/local/apr \ --with-apr-util=/usr/local/apr-util/ \ --with-pcre=/usr/local/pcre checking for chosen layout... Apache checking for working mkdir -p... yes checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu configure:  configure: Configuring Apache Portable Runtime library... configure:  checking for APR... configure: error: the --with-apr parameter is incorrect. It must specify an install prefix, a build directory, or an apr-config file. [root@bogon httpd-2.4.23]#

 在編譯Apache時(shí)出現(xiàn)了上面問(wèn)題,因?yàn)槲疫€沒(méi)有安裝apr、apr-util、pcre,接下來(lái)依次安裝依賴

http://apr.apache.org/download.cgi  下載apr-1.5.2.tar.gz、apr-util-1.5.4.tar.gz

http://www.pcre.org/ 官網(wǎng)

https://sourceforge.net/projects/pcre/files/pcre/  選擇pcre下載,不用pcre2

下載最新版本pcre-8.39.tar.gz

解決apr問(wèn)題

[root@bogon software]# wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz [root@bogon software]# tar -zxvf  apr-1.5.2.tar.gz [root@bogon software]# cd apr-1.5.2/ [root@bogon apr-1.5.2]# ./configure --prefix=/usr/local/apr [root@bogon apr-1.5.2]# make && make install

解決APR-util問(wèn)題

[root@bogon software]# wget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz [root@bogon software]# tar -zxvf apr-util-1.5.4.tar.gz [root@bogon software]# cd apr-util-1.5.4/ [root@bogon apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util \ -with-apr=/usr/local/apr/bin/apr-1-config [root@bogon apr-util-1.5.4]# make && make install

make過(guò)程如果遇到下面這個(gè)錯(cuò)誤,可能缺expat的開(kāi)發(fā)庫(kù),安裝expat庫(kù)試試。yum install expat-devel

[root@jdu4e00u53f7 apr-util-1.6.0]# make  make[1]: Entering directory `/liuzhen/source/apr-util-1.6.0' /bin/sh /liuzhen/apr/build-1/libtool --silent --mode=compile gcc -g -O2 -pthread   -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -I/liuzhen/source/apr-util-1.6.0/include -I/liuzhen/source/apr-util-1.6.0/include/private  -I/liuzhen/apr/include/apr-1    -o xml/apr_xml.lo -c xml/apr_xml.c && touch xml/apr_xml.lo xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory  #include <expat.h>                    ^ compilation terminated. make[1]: *** [xml/apr_xml.lo] Error 1 make[1]: Leaving directory `/liuzhen/source/apr-util-1.6.0' make: *** [all-recursive] Error 1

解決pcre-config問(wèn)題

[root@bogon software]# wget https://sourceforge.net/projects/pcre/files/pcre/8.39/pcre-8.39.tar.gz [root@bogon software]# tar -zxvf pcre-8.39.tar.gz [root@bogon software]# cd pcre-8.39 [root@bogon pcre-8.39]# ./configure --prefix=/usr/local/pcre [root@bogon pcre-8.39]# make && make install

 再次編譯httpd-2.4.23:

[root@bogon software]# cd httpd-2.4.23 [root@bogon httpd-2.4.23]# ./configure --prefix=/usr/local/apache2 \ --with-apr=/usr/local/apr \ --with-apr-util=/usr/local/apr-util/ \ --with-pcre=/usr/local/pcre [root@bogon httpd-2.4.23]# make && make install

編輯 httpd.conf 文件

[root@localhost liuzhen]# vi /usr/local/apache2/conf/httpd.conf

找到:

#ServerName www.example.com:80

修改為:

ServerName 127.0.0.1:80或者ServerName localhost:80

記得要去掉前面的“?!?/p>

啟動(dòng)Apache

[root@localhost liuzhen]# /usr/local/apache2/bin/apachectl start

停止Apache

[root@localhost liuzhen]# /usr/local/apache2/bin/apachectl stop

重啟Apache

[root@localhost liuzhen]# /usr/local/apache2/bin/apachectl restart

在瀏覽器中通過(guò)http://localhost:80,如果看到頁(yè)面中顯示“It works!”字樣,則代表Apache驗(yàn)證通過(guò)。

接下來(lái)是PHP相關(guān)配置

編輯 httpd.conf 文件

[root@localhost liuzhen]# vi /usr/local/apache2/conf/httpd.conf

找到:

<IfModule dir_module>

DirectoryIndex index.html

</IfModule>

添加:

<IfModule dir_module>

DirectoryIndex index.php index.html

</IfModule>

 找到:

AddType  application/x-compress .Z

AddType application/x-gzip .gz .tgz

在后面添加(使Apcche支持PHP):

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .php5

修改默認(rèn)的Web站點(diǎn)目錄

   默認(rèn)的目錄為  "/usr/local/apache2/htdocs",修改apache的配置文件httpd.conf,比如在新建一個(gè) /home/gyw/WebSite的目錄作為apache的站點(diǎn)目錄

  找到DocumentRoot這一行修改為:DocumentRoot "/home/gyw/WebSite"

  找到 <Directory> 這一行修改為:<Directory "/home/gyw/WebSite">

測(cè)試:修改到文件夾出現(xiàn)錯(cuò)誤:

“You don't have permission to access /index.html on this server.”

解決方法:

更改文件權(quán)限;chmod 755 index.html

打開(kāi)apache配置文件httpd.conf,找到這么一段:

<Directory />

   Options FollowSymLinks

   AllowOverride None

   Order deny,allow

   deny from all

   Satisfy all

</Directory>

安裝PHP

我在php開(kāi)發(fā)過(guò)程中需要使用gd2,所以順便把安裝gd2安裝上

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

PHP下載地址:http://www.php.net/downloads.php

[root@localhost liuzhen]# wget -O ./php-5.6.30.tar.gz http://hk1.php.net/get/php-5.6.30.tar.gz/from/this/mirror [root@localhost liuzhen]# tar -zxvf php-5.6.30.tar.gz [root@localhost liuzhen]# cd php-5.6.30 [root@localhost php-5.6.30]# ./configure --prefix=/usr/local/php \ --with-apxs2=/usr/local/apache2/bin/apxs \ --with-mysql=mysqlnd \ --with-gd

出現(xiàn)下面錯(cuò)誤

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 /liuzhen/apache2/bin/apxs follows: ./configure: /liuzhen/apache2/bin/apxs: /replace/with/path/to/perl/interpreter: bad interpreter: No such file or directory configure: error: Aborting

解決步驟:

1、根據(jù)不能run apxs 。cd 到apache的bin目錄下運(yùn)行./apxs 運(yùn)行結(jié)果

----------------------------------------------------

bash: ./apxs: /replace/with/path/to/perl/interpreter: bad interpreter: No such file or directory

---------------------------------------------------------

2、vim apxs文件 找“/replace/with/path/to/perl/interpreter”關(guān)鍵字

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

根據(jù)perl的安裝目錄 /usr/bin/perl

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

重新執(zhí)行php configure

[root@localhost php-5.6.30]# ./configure --prefix=/usr/local/php \ --with-apxs2=/usr/local/apache2/bin/apxs \ --with-mysql=mysqlnd \ --with-gd

出現(xiàn)錯(cuò)誤:configure: error: xml2-config not found. Please check your libxml2 installation.

 安裝libxml2和libxml2-devel

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

再次執(zhí)行./configure命令有可能還會(huì)出現(xiàn)下面這個(gè)錯(cuò)誤

PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled. clicommand.inc directorytreeiterator.inc invertedregexiterator.inc directorygraphiterator.inc pharcommand.inc phar.inc Build complete. Don't forget to run 'make test'. -bash: $'\343\200\200make': command not found

php 的編譯時(shí)需要依賴pear package ,目前的問(wèn)題錯(cuò)誤"PEAR package PHP_Archive not installed",已經(jīng)明顯報(bào)出這個(gè)問(wèn)題。
因此編譯使用參數(shù) --without-pear  將pear 屏蔽掉編譯安裝后,再進(jìn)行安裝;同時(shí)因?yàn)閜har 屬于pear的一個(gè)庫(kù) ,所以不將phar關(guān)閉掉,同時(shí)還會(huì)報(bào)這個(gè)錯(cuò)誤,
同時(shí)需要使用 --disable-phar  編譯參數(shù).

./configure --without-pear  --disable-phar make make install

成功編譯安裝完成后,再安裝pear

wget  http://pear.php.net/go-pear.phar  /usr/local/bin/php go-pear.phar

重新運(yùn)行上面的./configure命令

[root@localhost php-5.6.30]# ./configure --prefix=/usr/local/php \ --with-apxs2=/usr/local/apache2/bin/apxs \ --with-mysql=mysqlnd \ --with-gd [root@localhost php-5.6.30]# make && make install

--with-mysql=mysqlnd 加上此參數(shù)支持mysql

--with-gd 支持gd

  注意這里有一個(gè)-with-apxs2=/usr/local/apache2/bin/apxs選項(xiàng),其中apxs是在安裝Apache時(shí)產(chǎn)生的,apxs是一個(gè)為Apache HTTP服務(wù)器編譯和安裝擴(kuò)展模塊的工具,使之可以用由mod_so提供的LoadModule指令在運(yùn)行時(shí)加載到Apache服務(wù)器中。我的理解是通過(guò)這個(gè)工具把PHP模塊動(dòng)態(tài)加載到Apache中

把原來(lái)位于源代碼里面的php.ini-development拷貝到/usr/local/php/lib/php.ini下,并且重命名為php.ini

[root@localhost liuzhen]# cp /liuzhen/php-5.3.29/php.ini-development /usr/local/php/lib/php.ini

編輯/usr/local/php/lib/php.ini文件,找到;extension=php_gd2.dll將前面分號(hào)去掉

先停止apache后重啟apache

[root@localhost liuzhen]# /usr/local/apache2/bin/apachectl stop [root@localhost liuzhen]# /usr/local/apache2/bin/apachectl restart

測(cè)試

  在apache的htdocs下建立一個(gè)php文件test.php,里面的內(nèi)容如下:

  <?php

  phpinfo();

  ?>

  然后在瀏覽器里輸入http://127.0.0.1/test.php

  如果出現(xiàn)php的相關(guān)配置,成功,如果什么都沒(méi)有輸入,說(shuō)明失敗,重新以上步驟或者查找原因

如果決定在安裝后改變配置選項(xiàng),只需重復(fù)最后的三步configure, make, 以及 make install,然后需要重新啟動(dòng) Apache 使新模塊生效。Apache不需要重新編譯。

下面是我留的筆記就不用看了CentOS7 Apache 2.4.23 +  php-5.6.30 安裝 配置

==========================

安裝gd2,安裝gd2的時(shí)候順帶安裝了jpeg,png,zlib

1、安裝zlib

http://www.zlib.net/

http://www.zlib.net/zlib-1.2.11.tar.gz

tar xf zlib-1.2.7.tar.gz

cd zlib-1.2.7

./configure

make

make install

2、安裝 jpeg

https://jpeg.org/

http://www.ijg.org/

http://www.ijg.org/files/jpegsrc.v9b.tar.gz

tar xf jpegsrc.v9a.tar.gz

cd jpeg-9a

./configure --prefix=/usr/local/jpeg --enable-shared --enable-static

make

make install

3、安裝 libpng

http://www.libpng.org/pub/png/libpng.html

http://download.sourceforge.net/libpng/libpng-1.6.28.tar.gz

http://blog.csdn.net/wang02011/article/details/7066361

tar xf libpng-1.6.12.tar.gz

cd libpng-1.6.12

./configure --prefix=/usr/local/libpng

make

make install

4、安裝freetype

https://www.freetype.org/download.html

http://download.savannah.gnu.org/releases/freetype/

http://download.savannah.gnu.org/releases/freetype/freetype-2.7.1.tar.gz

tar xf freetype-2.5.3.tar.gz

cd freetype-2.5.3

./configure --prefix=/usr/local/freetype

make

make install

5、安裝gd2

yum install php-gd

https://libgd.github.io/

https://github.com/libgd/libgd/archive/gd-2.2.4.tar.gz

tar xf libgd-2.1.0.gz

cd libgd-2.1.0

./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg/ --with-png=/usr/local/png/ --with-zlib=/usr/local/zlib/ --with-freetype=/usr/local/freetype/

make

make install

(注,版本這里必須>=2.1.0,否則用php-5.6.0會(huì)報(bào)錯(cuò),可能老版本的php不會(huì)報(bào)錯(cuò))

安裝php是參數(shù)調(diào)整

[root@localhost php-5.6.30]# ./configure --prefix=/usr/local/php \ --with-apxs2=/usr/local/apache2/bin/apxs \ --with-php-config=/usr/local/php/bin/php-config \ --with-jpeg-dir=/usr/local/jpeg \ --with-png-dir=/usr/local/libpng \ --with-freetype-dir=/usr/local/freetype \ --with-mysql=mysqlnd \ --with-gd [root@localhost php-5.6.30]# make && make install

安裝curl

官網(wǎng)地址:https://curl.haxx.se/

下載地址:https://curl.haxx.se/download/curl-7.53.1.tar.gz

[root@bogon liuzhen]# wget https://curl.haxx.se/download/curl-7.53.1.tar.gz [root@bogon liuzhen]# tar -zxvf curl-7.53.1.tar.gz [root@bogon liuzhen]# cd curl-7.53.1 [root@bogon curl-7.53.1]# ./configure --prefix=/usr/local/curl [root@bogon curl-7.53.1]# make && make install

#vim /usr/local/php/lib/php.ini

添加如下一行:

extension=curl.so

安裝php 只要打開(kāi)開(kāi)關(guān) --with-curl=/usr/local/curl 就可以了。

-------------------------------------------------------------------------------------

CentOS7 Apache 2.4.23 +  php-5.6.30 安裝 配置

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

網(wǎng)頁(yè)名稱:CentOS7Apache2.4.23+php-5.6.30安裝配置-創(chuàng)新互聯(lián)
文章出自:http://muchs.cn/article44/dcpdhe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航品牌網(wǎng)站建設(shè)、商城網(wǎng)站、標(biāo)簽優(yōu)化、電子商務(wù)、定制開(kāi)發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司