1. 程式人生 > 實用技巧 >centos8 安裝php7.4

centos8 安裝php7.4

安裝php-fpm rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm dnf module install php:7.4 配置php-fpm服務 # vim /etc/php-fpm.d/www.conf user = nginx # 這個值原來是apache group = nginx # 這個值原來是apache 記得在編輯的時候記錄一下listen的值,一會配置nginx的時候要用到 listen = /run/php-fpm/www.sock 啟動php-fpm服務 # systemctl enable php-fpm # systemctl start php-fpm 配置nginx
# vim /etc/nginx/conf.d/default.conf
server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /var/www/html;
        index  index
.html index.htm; if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { root /var/www/html; fastcgi_split_path_info
^(.+\.php)(/.+)$; fastcgi_pass unix:/run/php-fpm/www.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } }

啟動nginx服務 systemctl enable nginx systemctl start nginx centos中gd庫開啟 yum -y install php-gd systemctl restart nginx
CentOS 安裝 MySQL PDO 擴充套件
yum install php-pdo_mysql sudo service php-fpm restart