先安装一下这个命令 add-apt-repository
apt-get install software-properties-common
添加第三方源:
add-apt-repository ppa:ondrej/php apt-get update
安装php:
apt-get install php7.4 php7.4-fpm php7.4-MysqL php7.4-gd php7.4-mbstring php7.4-curl php7.4-xml
查看php版本
php -v
启动、重启、关闭 php服务
service php7.4-fpm start service php7.4-fpm restart service php7.4-fpm stop
nginx配置(注意fastcgi_pass)
server { listen 88; server_name www.dingsky.com; # 默认网站根目录(www目录) root /var/www/html/; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { # 这里改动了 定义首页索引文件的名称 index index.php index.html index.htm; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } # 这里新加的 # PHP 脚本请求全部转发到 FastCGI处理. 使用FastCGI协议默认配置. # Fastcgi服务器和程序(PHP,Python)沟通的协议. location ~ \.php$ { # 设置监听端口 # fastcgi_pass 127.0.0.1:9000; # fastcgi_pass 如果是 sock形式,可能是下面的配置 fastcgi_pass unix:/run/php/php7.4-fpm.sock; # 设置nginx的默认首页文件(上面已经设置过了,可以删除) fastcgi_index index.php; # 设置脚本文件请求的路径 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # 引入fastcgi的配置文件 include fastcgi_params; } }
nginx启动、重启、关闭
service nginx start 启动 service nginx reload 重新启动 service nginx stop 停止服务 service nginx status 查看状态
查看PHP 安装情况
<?php phpinfo(); ?>
随缘而来,乘风而去,山高海阔,自有我风采!
所属分类:
计算机基础