CentOS-7 编译安装php-7.4
<h2>1、环境准备</h2><p> 虚拟机:centos 7 ip:192.168.137.128</p>
<p> php-7.4.8.tar.gz</p>
<h2>2、开始安装</h2>
<p> <span style="font-size: 16px"><strong>添加php用户,用于运行php-fpm进程</strong></span></p>
<p> useradd php -s /sbin/nologin</p>
<p> <img src="https://img2020.cnblogs.com/blog/1453281/202007/1453281-20200727232851240-2118901584.png" alt="" loading="lazy"></p>
<p> <span style="font-size: 16px"><strong>解压php源码包</strong></span></p>
<p><strong> </strong>tar -zxf php-7.4.8.tar.gz</p>
<p> <img src="https://img2020.cnblogs.com/blog/1453281/202007/1453281-20200727232941809-1351004521.png" alt="" loading="lazy"></p>
<p> <span style="font-size: 16px"><strong>安装依赖包</strong></span></p>
<p><strong> </strong>yum install libxml2-devel sqlite-devel libcurl-devel oniguruma-devel libpng-devel libjpeg-devel freetype-devel libzip-devel openssl-devel -y</p>
<p> <span style="font-size: 16px"><strong>编译参数参考</strong></span></p>
<p>./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mhash --with-openssl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv --with-zlib --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-bcmath --enable-shmop --enable-sysvsem --enable-gd --with-jpeg --with-freetype --enable-mbregex --enable-mbstring --enable-ftp --enable-pcntl --enable-sockets --enable-soap --without-pear --with-gettext --enable-session --with-curl --enable-opcache --enable-fpm --with-fpm-user=php --with-fpm-group=php --without-gdbm --enable-fast-install --disable-fileinfo</p>
<p> <span style="font-size: 16px"><strong>编译没有问题就开始安装</strong></span></p>
<div class="cnblogs_code">
<pre># make && make install </pre>
</div>
<p><span style="font-size: 16px"><strong> <img src="https://img2020.cnblogs.com/blog/1453281/202007/1453281-20200728001104513-824783699.png" alt="" loading="lazy"></strong></span></p>
<p><span style="font-size: 16px"><strong> 编译安装完成</strong></span></p>
<p> <img src="https://img2020.cnblogs.com/blog/1453281/202007/1453281-20200728002343318-1145420184.png" alt="" loading="lazy"></p>
<p> <span style="font-size: 16px"><strong>复制相关配置文件到php安装路径</strong></span></p>
<p><span style="font-size: 16px"><strong> </strong></span>启动脚本:php-7.4.8/sapi/fpm/init.d.php-fpm</p>
<div class="cnblogs_code">
<pre># cp init.d.php-fpm /usr/local/php/</pre>
</div>
<p> php.ini配置文件:php-7.4.8/php.ini-production </p>
<div class="cnblogs_code">
<pre># cp php.ini-production /usr/local/php/etc/php.ini</pre>
</div>
<p> <span style="font-size: 16px"><strong>创建php-fpm.conf配置文件</strong></span></p>
<p><span style="font-size: 16px"><strong> </strong></span>进到php的安装路径下面的etc</p>
<div class="cnblogs_code">
<pre># pwd
/usr/local/php/etc
#
# ls
php-fpm.conf.defaultphp-fpm.dphp.ini
# cp php-fpm.conf.default php-fpm.conf</pre>
</div>
<p> <img src="https://img2020.cnblogs.com/blog/1453281/202007/1453281-20200728002956005-1077883205.png" alt="" loading="lazy"></p>
<p> 进入php-fpm.d目录,将里面的文件也重命名一下</p>
<div class="cnblogs_code">
<pre># pwd
/usr/local/php/etc/php-fpm.d
#
# ls
www.conf.default
#
# cp www.conf.default www.conf</pre>
</div>
<p> <img src="https://img2020.cnblogs.com/blog/1453281/202007/1453281-20200728003216393-1262699643.png" alt="" loading="lazy"></p>
<p> <span style="font-size: 16px"><strong>启动php-fpm</strong></span></p>
<p> <strong>执行init.d.php-fpm启动脚本,启动php-fpm</strong></p>
<div class="cnblogs_code">
<pre># bash init.d.php-fpm start</pre>
</div>
<p><strong> <img src="https://img2020.cnblogs.com/blog/1453281/202007/1453281-20200728003426312-2111341540.png" alt="" loading="lazy"></strong></p>
<p> <span style="font-size: 16px"><strong>测试安装是否成功,可结合nginx配置一个index.php 写一个phpinfo的测试页面</strong></span></p>
<p><span style="font-size: 16px"><strong> nginx </strong></span><strong>location 段配置文件</strong></p>
<div class="cnblogs_code">
<pre> location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name;
include fastcgi.conf;
}</pre>
</div>
<p> <strong>index.php 配置文件</strong></p>
<div class="cnblogs_code">
<pre># cat index.php
<?php
phpinfo()
?>
#
# </pre>
</div>
<p> <strong> 启动nginx,访问网页</strong></p>
<p><img src="https://img2020.cnblogs.com/blog/1453281/202007/1453281-20200728003953696-690754089.png" alt="" loading="lazy"></p><br><br>
来源:https://www.cnblogs.com/chenppp/p/13388748.html
頁:
[1]