PHP
RHEL
在线安装
在线安装依赖Remi镜像源,安装前需确保已经正确安装并配置好。
1. php
bash
# 查询
dnf module list | grep php
# 安装方式一
sudo dnf module reset php
sudo dnf module enable php:remi-8.3 -y
sudo dnf module enable php:remi-7.4 -y
sudo dnf module install php
# 安装方式二
sudo dnf module reset php
sudo dnf module install php:remi-8.3
#
sudo dnf install php php-bcmath
sudo dnf install php php-cli php-common php-fpm php-mysql php-sodium php-xml
sudo dnf install -y php-{common,mysql,xml,xmlrpc,curl,gd,imagick,cli,fpm,mbstring,opcache,zip,sodium}
#
sudo dnf remove -y php-{common,mysql,xml,xmlrpc,curl,gd,imagick,cli,fpm,mbstring,opcache,zip,sodium}
# 检查是否安装成功
php -v
2. php-fpm
配置
bash
# vi /etc/php-fpm.d/www.conf
user = nginx
group = nginx
#
listen = /run/php-fpm/www.sock
3. 启动
bash
# 随系统启动
systemctl enable php-fpm
# 取消系统启动
systemctl disable php-fpm
# 启动服务
systemctl start php-fpm
# 重启服务
systemctl restart php-fpm
# 重新加载
systemctl reload php-fpm
# 停止服务
systemctl stop php-fpm
# 查看状态
systemctl status php-fpm
4. Nginx
nginx
server {
listen 80;
server_name localhost;
location / {
root /var/www/html;
index index.html index.htm;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
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;
}
}
Composer
镜像设置
bash
# 更新
composer self-update
# 清空缓存
composer clear
# 全局设置
composer config -g repos.packagist composer https://mirrors.cloud.tencent.com/composer/
composer config -g repos.packagist composer https://mirrors.aliyun.com/composer/
# 项目项目
composer config repos.packagist composer https://mirrors.aliyun.com/composer/
composer config repos.packagist composer https://mirrors.cloud.tencent.com/composer/
# 恢复官方镜像
composer config -g --unset repos.packagist
composer config -g repos.packagist composer https://packagist.org
XDebug
MacOS
编译安装
bash
#
brew install autoconf
#
sudo xcode-select -switch /Applications/Xcode.app
#
/Applications/XAMPP/xamppfiles/bin/phpize-7.4.8
#
./configure --enable-xdebug --with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config-7.4.8
#
make
#
sudo cp modules/* /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20190902/
PECL 安装
bash
# Intel
arch -x86_64 sudo pecl install xdebug
# M1
arch -arm64e sudo pecl install xdebug
配置 - MacOS
bash
[xdebug]
zend_extension="xdebug.so"
xdebug.mode=debug
xdebug.idekey=XDebugIDE
xdebug.start_with_request=trigger
配置 - Windows
bash
[xdebug]
zend_extension="php_xdebug.dll"
zend_extension="D:\Dev\php\xampp\php\ext\php_xdebug.dll"
xdebug.mode=debug
xdebug.idekey=XDebugIDE
xdebug.start_with_request=trigger