源碼安裝php7.4php
下載地址:mysql
一、安裝wget工具:sql
yum install -y wget
二、安裝PHP依賴包vim
yum install gcc libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel
三、獲取php7.4源碼包並安裝api
wget https://www.php.net/distributions/php-7.4.8.tar.gz tar -xzf php-7.4.8.tar.gz cd php-7.4.8 預編譯: ./configure '--prefix=/usr/local/php' '--with-config-file-path=/usr/local/php/etc' '--enable-fpm' '--with-fpm-user=www' '--with-fpm-group=www' '--with-mysqli' '--with-pdo-mysql' '--with-iconv-dir' '--with-freetype-dir' '--with-jpeg-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' --disable-mbregex '--enable-ftp' '--with-gd' '--with-openssl' '--with-mhash' '--enable-pcntl' '--enable-sockets' '--with-xmlrpc' '--enable-zip' '--enable-soap' '--without-pear' '--with-gettext' '--disable-fileinfo' '--enable-maintainer-zts' 如編譯報錯:No package 'oniguruma' found : 解決方法1: yum install http://rpms.remirepo.net/enterprise/7/remi/x86_64//oniguruma5-6.9.4-1.el7.remi.x86_64.rpm yum install http://rpms.remirepo.net/enterprise/7/remi/x86_64//oniguruma5-devel-6.9.4-1.el7.remi.x86_64.rpm 解決方法2: 「--enable-mbstring」後再添加「--disable-mbregex」參數。這樣的配置將再也不須要oniguruma庫。 編譯: make 安裝: make install
四、編譯完成以後,咱們添加PHP命令到環境變量裏php7
vim /etc/profile 在文件末尾加入: PATH=$PATH:/usr/local/php/bin export PATH 要使改動當即生效執行 source /etc/profile 查看PHP 版本 php -v cp php.ini-production /etc/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /usr/src/php-7.4.6/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod 755 /etc/init.d/php-fpm chkconfig --add php-fpm chkconfig php-fpm on
php-fpm.conf是php服務程序重要的配置文件之一,咱們須要啓用該配置文件中第25行左右的pid文件保存目錄,而後分別將第148和149行的user與group參數分別修改成www帳戶和用戶組名稱:curl
vim /usr/local/php/etc/php-fpm.confsocket
25 pid = run/php-fpm.pid ………………省略部分輸出信息……………… 148 user = www 149 group = www ………………省略部分輸出信息……………… cp /usr/local/php/etc/php-fpm.d/www.conf.default www.conf /etc/init.d/php-fpm start