前言 腾讯云:Centos linux release 8.5.2111Nginx:1.14.1PHP:7.2.24 查看php源 shell> yum info phpLast metadata e
shell> yum info phpLast metadata expiration check: 1:26:18 aGo on Thu 12 Jan 2023 02:30:20 PM CST.Available PackagesName : phpVersion : 7.2.24Release : 1.module_el8.2.0+313+b04d0a66Architecture : x86_64Size : 1.5 MSource : php-7.2.24-1.module_el8.2.0+313+b04d0a66.src.rpmRepository : AppStreamSummary : PHP scripting language for creating dynamic WEB sitesURL : Http://www.php.net/License : PHP and Zend and BSD and MIT and ASL 1.0Description : PHP is an html-embedded scripting language. PHP attempts to make it : easy for developers to write dynamically generated web pages. PHP also : offers built-in database integration for several commercial and : non-commercial database management systems, so writing a : database-enabled webpage with PHP is fairly simple. The most common : use of PHP coding is probably as a replacement for CGI scripts. : : The php package contains the module (often referred to as mod_php) : which adds support for the PHP language to Apache HTTP Server.
或者
shell> yum list php*Last metadata expiration check: 2:25:54 ago on Thu 12 Jan 2023 02:30:20 PM CST.Available Packagesphp.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStreamphp-cli.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStreamphp-common.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStreamphp-fpm.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStreamphp-IDNA_Convert.noarch 0.8.0-14.el8 epel php-adodb.noarch 5.20.6-9.el8 epel php-bcmath.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-dba.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-dbg.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-devel.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-embedded.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-enchant.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-gd.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-geshi.noarch 1.0.9.1-9.el8 epel php-gmp.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-intl.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-JSON.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-kolabfORMat.x86_64 1.2.0-8.el8 epel php-ldap.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-mbstring.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-Mysqlnd.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-odbc.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-opcache.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-pdo.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-pear.noarch 1:1.10.5-9.module_el8.2.0+313+b04d0a66 AppStream php-pear-Auth-SASL.noarch 1.1.0-6.el8 epel php-pear-Cache-Lite.noarch 1.8.3-1.el8 epel php-pear-CodeGen.noarch 1.0.7-24.el8 epel php-pear-CodeGen-PECL.noarch 1.1.3-26.el8 epel php-pear-Date.noarch 1.4.7-22.el8 epel php-pear-HTTP-Request.noarch 1.4.4-18.el8 epel php-pear-Mail.noarch 1.4.1-6.el8 epel php-pear-Net-SMTP.noarch 1.9.0-1.el8 epel php-pear-Net-Socket.noarch 1.2.2-6.el8 epel php-pear-Net-URL.noarch 1.0.15-20.el8 epel php-pear-Text-Diff.noarch 1.2.2-9.el8 epel php-pecl-apcu.x86_64 5.1.12-2.module_el8.2.0+313+b04d0a66 AppStream php-pecl-apcu-devel.x86_64 5.1.12-2.module_el8.2.0+313+b04d0a66 AppStream php-pecl-zip.x86_64 1.15.3-1.module_el8.2.0+313+b04d0a66 AppStream php-pgsql.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-process.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-recode.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-snmp.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-soap.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-xml.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-xmlrpc.x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 AppStream php-xmpphp.noarch 0.1-0.23.rc2.r77.el8 epel phpldapadmin.noarch 1.2.6.3-1.el8 epel
shell> yum install php php-fpm
shell> php -vPHP 7.2.24 (cli) (built: Oct 22 2019 08:28:36) ( NTS )Copyright (c) 1997-2018 The PHP GroupZend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
打开www.conf
shell> vim /etc/php-fpm.d/www.conf
将user和group改为nginx
; Unix user/group of processes; Note: The user is mandatory. If the group is not set, the default user's group; will be used.; RPM: apache user chosen to provide access to the same directories as httpduser = nginx; RPM: Keep a group allowed to write in log dir.group = nginx
打开www.conf
shell> vim /etc/php-fpm.d/www.conf
将port改为9000
; The address on which to accept FastCGI requests.; Valid syntaxes are:; 'ip.add.re.ss:port' - to listen on a tcp socket to a specific IPv4 address on;a specific port;; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on;a specific port;; 'port' - to listen on a TCP socket to all addresses;(IPv6 and IPv4-mapped) on a specific port;; '/path/to/unix/socket' - to listen on a unix socket.; Note: This value is mandatory.;listen = /run/php-fpm/www.socklisten = 127.0.0.1:9000
启动php-fpm服务:
shell> systemctl start php-fpm
查看php-fpm服务运行状态:
shell> systemctl status php-fpm● php-fpm.service - The PHP FastCGI Process Manager Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled) Active: active (running) since Thu 2023-01-12 16:04:15 CST; 4s ago Main PID: 2161302 (php-fpm) Status: "Ready to handle connections" Tasks: 6 (limit: 49524) Memory: 11.1M CGroup: /system.slice/php-fpm.service ├─2161302 php-fpm: master process (/etc/php-fpm.conf) ├─2161303 php-fpm: pool www ├─2161304 php-fpm: pool www ├─2161305 php-fpm: pool www ├─2161306 php-fpm: pool www └─2161307 php-fpm: pool wwwJan 12 16:04:15 tencent-test-03 systemd[1]: Starting The PHP FastCGI Process Manager...Jan 12 16:04:15 tencent-test-03 systemd[1]: Started The PHP FastCGI Process Manager.
查看php-fpm进程:
shell> ps -ef | grep php-fpmroot 2164803 1 0 16:27 ? 00:00:00 php-fpm: master process (/etc/php-fpm.conf)nginx 2164804 2164803 0 16:27 ? 00:00:00 php-fpm: pool wwwnginx 2164805 2164803 0 16:27 ? 00:00:00 php-fpm: pool wwwnginx 2164806 2164803 0 16:27 ? 00:00:00 php-fpm: pool wwwnginx 2164807 2164803 0 16:27 ? 00:00:00 php-fpm: pool wwwnginx 2164808 2164803 0 16:27 ? 00:00:00 php-fpm: pool www
查看php-fpm服务占用的端口:
shell> netstat -tlnp | grep 9000tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 2164803/php-fpm: ma
或者
shell> netstat -tlnp | grep php-fpmtcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 2164803/php-fpm: ma
打开default.conf
shell> vi /etc/nginx/conf.d/default.conf
配置fastcgi
location ~ \.php$ { root /usr/share/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
nginx重载配置
shell> nginx -tshell> nginx -s reload
shell> vim /usr/share/nginx/html/index.php
测试页面代码:
测试页面代码:
http://127.0.0.1/index.php
shell> cd /var/lib/phpshell> chown -R root:nginx *
务必保证php-fpm的启动账户(本文设置的启动账户为nginx)对存放session的目录具有读写权限,否则将不能正确使用session。
--结束END--
本文标题: CentOS8安装PHP7
本文链接: https://www.lsjlt.com/news/389392.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0