linux下怎么安裝php環境

linux下安裝php環境的方法:1、安裝cmake;2、安裝libzip;3、安裝php依賴;4、創建www用戶;5、下載php源碼并進行預配置;6、編譯安裝;7、創建啟動腳本。

linux下怎么安裝php環境

安裝步驟如下:

(推薦教程:java視頻教程

第一步:安裝cmake

yum?install?epel-release?-y yum?install?cmake3?-y cp?/usr/bin/cmake3?/usr/bin/cmake

執行命令cmake -version?查看是否安裝成功:

立即學習PHP免費學習筆記(深入)”;

#輸出cmake?version?3.16.1 CMake?suite?maintained?and?supported?by?Kitware?(kitware.com/cmake).

第二步:安裝libzip1.5.2

#安裝bzip2-devel依賴包yum?install?bzip2?bzip2-devel?-y #安裝libzipcd?~ wget?https://libzip.org/download/libzip-1.5.2.tar.gz tar?xf?libzip-1.5.2.tar.gz? cd?libzip-1.5.2 mkdir?buildcd?build cmake?.. make#make?testmake?install

第三步:安裝php依賴

?yum?install?gcc? ??????????????gcc-c++? ??????????????libxml2? ??????????????libxml2-devel? ??????????????openssl? ??????????????openssl-devel? ??????????????libcurl? ??????????????libcurl-devel? ??????????????freetype? ??????????????freetype-devel? ??????????????libjpeg? ??????????????libjpeg-devel? ??????????????libpng? ??????????????libpng-devel? ??????????????libxslt? ??????????????libxslt-devel? ??????????????systemd-devel? ??????????????libicu-devel? ??????????????libedit-devel

第四步:創建www用戶

useradd?-M?-s?/sbin/nologin?www

修改庫加載路徑

vim?/etc/ld.so.conf
#添加如下幾行/usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64

使之生效:

ldconfig?-v

或者

echo?/usr/local/lib64?>>/etc/ld.so.conf? echo?/usr/local/lib?>>/etc/ld.so.conf? echo?/usr/lib?>>/etc/ld.so.conf? echo?/usr/lib64?>>/etc/ld.so.conf? ldconfig?-v

最終再次進行預配置

第五步:下載php源碼并預配置

#安裝wget工具 yum?install?wget?-y #下載php源碼 wget?https://www.php.net/distributions/php-7.3.12.tar.gz #解壓php?tar包 tar?xf?php-7.3.12.tar.gz #進入php解壓后的目錄 cd?php-7.3.12 #預配置 ./configure?--prefix=/usr/local/php? ????--with-config-file-path=/usr/local/php/etc? ????--with-config-file-scan-dir=/usr/local/php/etc/conf.d? ????--disable-cgi? ????--enable-fpm? ????--with-fpm-user=www? ????--with-fpm-group=www? ????--enable-ftp? ????--with-curl? ????--with-gd? ????--with-gettext? ????--with-iconv-dir? ????--with-kerberos? ????--with-libedit? ????--with-openssl? ????--with-pcre-regex? ????--with-pdo-mysql? ????--with-xsl? ????--with-zlib? ????--with-mhash? ????--with-mysqli? ????--with-png-dir=/usr/lib? ????--with-jpeg-dir=/usr/lib ????--with-freetype-dir=/usr/lib? ????--enable-mysqlnd? ????--enable-bcmath? ????--enable-libxml? ????--enable-inline-optimization? ????--enable-gd-jis-conv? ????--enable-mbregex? ????--enable-mbstring? ????--enable-opcache? ????--enable-pcntl? ????--enable-shmop? ????--enable-soap? ????--enable-sockets? ????--enable-sysvsem? ????--enable-xml? ????--enable-zip? ????--enable-calendar? ????--enable-intl? ????--enable-exif

查看最后輸出是否出現Error:

如果沒有error出現,并且出現如下字眼,則進行下一步

Thank?you?for?using?PHP

第六步:進行編譯安裝

make?&&?make?install

第七步:創建啟動腳本

?cp?php.ini-development??/usr/local/php/etc/php.ini? ?cd?/usr/local/php/etc/ ?cp?php-fpm.conf.default??php-fpm.conf

默認官方提供了一個systemd管理腳本

路徑為:/root/php-7.3.12/sapi/fpm下php-fpm.service

#復制一份配置文件 cp?php-fpm.conf.default?php-fpm.conf #拷貝啟動腳本到指定目錄 cp?/root/php-7.3.13/sapi/fpm/php-fpm.service?/usr/lib/systemd/system/ systemctl?daemon-reload systemctl?start?php-fpm systemctl?enable?php-fpm systemctl?status?php-fpm

這個時候還沒完,啟動 會提示你找不到包含的配置文件:

cd?/usr/local/php/etc/php-fpm.d/ cp?www.conf.default?www.conf systemctl?start?php-fpm systemctl?status?php-fpm

這個時候不出意外就是正常狀態:

查看進程是否存在

ps?-ef|grep?php-fpm

查看端口是否啟動:

ss?-lntup|grep?9000

相關推薦:java視頻教程

以上就是

? 版權聲明
THE END
喜歡就支持一下吧
點贊7 分享