PHP安裝提示
直接 yum install php-cli 安裝的是5.x版本,建議直接下載源碼編譯安裝
安裝:
https://www.cnblogs.com/houss/p/11296285.html
php7編譯選項
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php --enable-mbstring --enable-ftp --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --without-pear --disable-phar --enable-sockets --with-freetype-dir=/usr --with-zlib --with-libxml-dir=/usr --with-xmlrpc --enable-zip --enable-fpm --enable-xml --enable-sockets --with-gd --with-zlib --with-iconv --enable-zip --with-freetype-dir=/usr/lib/ --enable-soap --enable-pcntl --enable-cli --with-curl --with-apxs2
注意 --with-apxs2 選項,沒有這個選項無法編譯出 libphp7.so 文件,導(dǎo)致apache無法正常鏈接
使用 --with-apxs2 可能的錯誤:
Sorry, I cannot run apxs. Possible reasons follow:
Perl is not installed
apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
Apache was not built using --enable-so (the apxs usage page is displayed)
解決辦法:
when `httpd -l` does not list `mod_so.c`, `DSO` won't work, because it's an essential prerequisite; according to the [documentation](https://httpd.apache.org/docs/2.4/programs/apxs.html). otherwise `APXS` can be installed with the package manager:
* `sudo yum install httpd-devel` (CentOS)
* `sudo apt-get install apache2-dev` (Ubuntu)
this installs it as `/usr/bin/apxs` and `./configure --with-apxs` works (without passing a path). one does not even have to install `httpd` / `apache2`, in order to use it's development tools - which then can be used to configure `PHP` with `APXS`.
./configure ...
make install
完成后 .so 文件位置 libs/libphp7.so, 將其拷貝到對應(yīng)對方備用
Apache 配置:
修改httpd.conf , 在適當(dāng)問之添加 LoadModule php7_module modules/libphp7.so
php 配置文件:
/etc/httpd/conf.modules.d/10-php.conf
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
apachectl restart 重啟apache服務(wù)器,php生效