centos7.2 安装 php7
php的下载安装
- 安装 PHP7.4
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm
-
安装扩展
yum install -y --enablerep=remi --enablerepo=remi-php74 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUint php-pecl-xdebug
yum install -y --enablerepo=remi --enablerepo=remi-php74 php-fpm
yum --enablerepo=remi-php74 install -y php-gd php-mysql php-mbstring php-xml php-mcrypt
yum install -y libpng libpng-devel libjpeg libjpeg-devel gd gd-devel libcurl-devel
-
常用命令
查看版本php -v
启动systemctl start php-fpm
停止systemctl stop php-fpm
重启systemctl restart php-fpm
设置开机启动systemctl enable php-fpm
-
php配置
此版本默认配置文件位置:
/etc/php-fpm.d/
/etc/php.d
/etc/php-fpm.conf
/etc/php.ini
-
nginx 配置
一般nginx默认配置文件在 /etc/nginx/nginx.conf ,为不影响其他服务,在 /etc/nginx/conf.d/ 目录下新建一个文件 php.conf ,参考配置如下:
server {
listen 80;
server_name mydomain.com;
client_max_body_size 1m;
location / {
root /root/html;
index index.php index.html index.htm;
}
location ~* \.php$ {
fastcgi_index /root/html;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}