#下載PHP
一、https://www.php.net/downloads.phpphp
#安裝依賴庫
二、```
yum -y install epel-release
yum -y install gcc gcc-c++ make pcre pcre-devel libzip libzip-devel zlib zlib-devel openssl openssl-devel libxml2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel openldap openldap-devel libmcrypt libmcrypt-develhtml
#編譯安裝
三、./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-ctype --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-freetype-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --with-gettext --enable-fpm --with-jpeg-dir --with-png-dirmysql
echo $?
make && make installnginx
#錯誤解決 錯誤1:checking for libzip... configure: error: system libzip must be upgraded to version >= 0.11 解:----------
yum remove -y libzip #先刪除舊版本 #下載編譯安裝 wget https://nih.at/libzip/libzip-1.2.0.tar.gz tar -zxvf libzip-1.2.0.tar.gz cd libzip-1.2.0 ./configure
make && make install 錯誤2:configure: error: off_t undefined; check your library configuration 解決:----------
vim /etc/ld.so.conf
#添加以下幾行
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64
#保存退出
:wq
ldconfig -v # 使之生效c++
錯誤3:/usr/local/include/zip.h:59:21: 致命錯誤:zipconf.h make: *** [ext/zip/php_zip.lo] 錯誤 1 解決:-------
cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
#配置環境變量和systemctl
四、vim /etc/profile export PATH=$PATH:/usr/local/php/sbin:/usr/local/php/bin vim /usr/lib/systemd/system/php-fpm.service [Unit] Description=php-fpm After=network.target [Service] Type=forking ExecStart=/usr/local/php/sbin:/sur/local/php/bin [install] WantedBy=multi-user.target
systemctl daemon-reload 加載一下,告訴systemd系統。web
#啓動
五、sytemctl start php-fpmsql
#調試PHP與nginx環境,修改配置nginx.conf
六、vim nginx.conf
增長一個index.php
index index.html index.htm index.php;
取消註釋:
location ~ .php$ {
root /data/nginx/web;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#並把/scripts替換$document_root這個vim
#測試:
vim 1.php
<?php
phpinfo();
?>curl