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

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > php >内容正文

php

centos7 php7 httpd

發(fā)布時(shí)間:2025/3/15 php 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 centos7 php7 httpd 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

安裝php之前,要先安裝幾個(gè)

1.下載php源碼:http://cn2.php.net/distributions/php-7.0.6.tar.gz。

2.然后使用命令:tar -zxvf?php-7.0.6.tar.gz,進(jìn)行解壓。

3.使用php時(shí)還要先安裝幾個(gè)其他的東西,否則安裝會(huì)出錯(cuò),或者不生成php.so擴(kuò)展文件,

  先從ftp://xmlsoft.org/libxml2/libxml2-2.7.2.tar.gz下載這個(gè)插件,注意不要下載最新版本除非需要,版本越新需要的依賴越多,下載完成后使用tar解壓,

  執(zhí)行1../configure,2.make,3.make install ,三個(gè)命令來(lái)編譯安裝這個(gè)東西。

  然后檢查是否安裝了httpd_devel,如果沒(méi)有安裝,執(zhí)行yum install?httpd-devel,進(jìn)行安裝,如果不安裝的話,后期不會(huì)生成.so的擴(kuò)展文件。

4.進(jìn)入解壓完的php文件,然后根據(jù)自己的需要,來(lái)配置./configure的參數(shù)

  

./configure \
--prefix=/usr/local/php7 \
--exec-prefix=/usr/local/php7 \
--bindir=/usr/local/php7/bin \
--sbindir=/usr/local/php7/sbin \
--includedir=/usr/local/php7/include \
--libdir=/usr/local/php7/lib/php \
--mandir=/usr/local/php7/php/man \
--with-config-file-path=/usr/local/php7/etc \
--with-mysql-sock=/var/run/mysql/mysql.sock \
--with-mcrypt=/usr/include \
--with-mhash \
--with-openssl \
--with-pdo-mysql=shared,mysqlnd \
--with-mysqli=shared,mysqlnd \
--with-pdo-mysql=shared,mysqlnd \
--with-gd \
--with-iconv \
--with-zlib \
--enable-zip \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-freetype-dir \
--enable-fpm \
--without-gdbm \
--enable-opcache=no \
--disable-fileinfo

  注意,每個(gè)參數(shù)都可能會(huì)有依賴,比如:--with-zlib \ --enable-zip,是需要事先安裝對(duì)應(yīng)文件的,如果不需要,可以不指定對(duì)應(yīng)參數(shù),最好指定的編譯參數(shù)是:--prefix?--with-mysqli?--with-apxs2 。

  編譯完成如果么有錯(cuò)誤,那就執(zhí)行 make && make install .如果報(bào)錯(cuò),看是否是缺少什么依賴,在重新編譯前,先執(zhí)行:make clean,否則可能會(huì)產(chǎn)生錯(cuò)誤,錯(cuò)誤信息:***lo' is not a valid libtool object。

5.復(fù)制配置文件:php的推薦配置文件,已經(jīng)存在于源碼文件中了,使用find命令查找一下,一般是兩個(gè):php.ini-production,php.ini-development,至于將那個(gè)當(dāng)配置使用,就看自己的了。

6.根據(jù)安裝位置,將對(duì)應(yīng)的php文件位置添加到PATH中,文件位置:/etc/profile,在最后添加:

  PATH=$PATH:/usr/local/webserver/php/bin:/usr/local/webserver/mysql/bin -- 注意添加的不是php可執(zhí)行的本身,而是上一級(jí)目錄,否則不能使用,
  export PATH

  最后執(zhí)行source /etc/profile 重新加載配置文件,然后echo $PATH,來(lái)看路徑是否添加進(jìn)了環(huán)境變量。

7.以上修改完畢之后應(yīng)該是已經(jīng)可以在本地執(zhí)行php文件了,如果不能,則是有問(wèn)題,要查看是php文件,還是path路徑配置問(wèn)題。

8.配置httpd.conf文件,

  在配置文件中搜素: ?AddType 關(guān)鍵字,在其后面追加下面三行,如果不追加,httpd會(huì)直接打印php文件內(nèi)容,不會(huì)調(diào)用php執(zhí)行。

? ? AddType application/x-httpd-php .php
? ? AddType application/x-httpd-php .php .phtml .php3
? ? AddType application/x-httpd-php-source .phps

 接下來(lái)添加默認(rèn)搜索php文件,在配置文件中查找DirectoryIndex 關(guān)鍵字,如果后面沒(méi)有index.php,就在后面追加index.php,這樣httpd才能默認(rèn)訪問(wèn)php文件

? ?接下來(lái)添加對(duì)php的支持,搜索LoadModule關(guān)鍵字,添加:LoadModule php7_module modules/libphp7.so,如果后期出現(xiàn)不能加載libphp7.so,則表示php編譯有問(wèn)題,最大可能就是沒(méi)添加--with-apxs2參數(shù),或者設(shè)置錯(cuò)誤,需要重編php源碼文件,直到能 ? ?在系統(tǒng)內(nèi)搜索到libphp7.so為止。

 在httpd.conf內(nèi)最好手動(dòng)執(zhí)行php的配置文件位置,方式為PHPIniDir "/usr/local/php7/bin",這樣能保證重啟httpd服務(wù)的時(shí)候,重新裝載對(duì)的php配置。

 以上完成之后應(yīng)該是配置完畢,找到index.html正確位置,添加index.php文件并將其他命名為index的文件改成其他名字,否則默認(rèn)不會(huì)加載index.php,在index.php中添加代碼

 

<?php phpinfo(); ?>

然后重啟httpd服務(wù)器,使用IP訪問(wèn)測(cè)試,如果不行,先檢查防火墻是否關(guān)閉,或者開(kāi)放了指定的端口。

測(cè)試端口是否打開(kāi):firewall-cmd --query-port=80/tcp

打開(kāi)指定端口:firewall-cmd --add-port=80/tcp

 或者直接關(guān)閉防火墻:

  systemctl start firewalld.service#啟動(dòng)firewall
  systemctl stop firewalld.service#停止firewall
  systemctl disable firewalld.service#禁止firewall開(kāi)機(jī)啟動(dòng)

?編譯過(guò)程中可能出現(xiàn)的錯(cuò)誤和解決辦法:

運(yùn)行之后遇到的問(wèn)題:

error 1

checking for xml2-config path...?
configure: error: xml2-config not found. Please check your libxml2 installation.

(看提示就明白 是一個(gè)lib庫(kù)沒(méi)裝? 先用 yum search 名字 看是否能搜到名字 ,找到名字后 把軟件包 開(kāi)發(fā)包裝上)

解決辦法

yum install libxml2-devel.x86_64

error 2

checking for pkg-config... /usr/bin/pkg-config
configure: error: Cannot find OpenSSL's <evp.h>

這是ssl沒(méi)裝

解決辦法

?yum? install? openssl.x86_64 openssl-devel.x86_64 -y

error 3

checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution

這是bzip2軟件包沒(méi)有安裝

解決辦法

yum install bzip2-devel.x86_64 -y

error 4

configure: error: Please reinstall the libcurl distribution -
??? easy.h should be in <curl-dir>/include/curl/

curl和curl庫(kù)文件沒(méi)有安裝

解決辦法

yum install libcurl.x86_64 libcurl-devel.x86_64 -y

error 5

checking whether to enable JIS-mapped Japanese font support in GD... no
checking for fabsf... yes
checking for floorf... yes
configure: error: jpeglib.h not found

GD庫(kù)沒(méi)有安裝

解決辦法

yum install libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 -y

error 6

checking for stdarg.h... (cached) yes
checking for mcrypt support... yes
configure: error: mcrypt.h not found. Please reinstall libmcrypt.

libmcrypt庫(kù)沒(méi)有安裝 ,要是不能用yun安裝的話? 就要去下載個(gè)gz包 自己編譯安裝

(編譯安裝? ./configure --piefix=/usr/local/libmcrypt?? make && make install)

要是錯(cuò)誤里面含有mysql的? 那是mysql-devel 沒(méi)有安裝

轉(zhuǎn)載于:https://www.cnblogs.com/likui360/p/5511909.html

總結(jié)

以上是生活随笔為你收集整理的centos7 php7 httpd的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。