mac php安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

~ brew search php #搜索php
==> Formulae
brew-php-switcher php@7.2 phplint pcp
php php@7.3 phpmd pup
php-code-sniffer php@7.4 phpmyadmin
php-cs-fixer php@8.0 phpstan
php-cs-fixer@2 phpbrew phpunit
➜ ~ brew install php@7.2 #安装php7.2


#配置文件路径
/usr/local/etc/php/7.2/php.ini
/usr/local/etc/php/7.2/php-fpm.ini
#重启服务
brew services restart php@7.2
#不在后台运行
/usr/local/opt/php@7.2/sbin/php-fpm --nodaemonize

➜ ~ vim /usr/local/etc/php/7.2/php-fpm.conf

#去掉第17行和第24行前面的分号
17 ;pid = run/php-fpm.pid #pid 文件就会自动产生在 /usr/local/var/run/php-fpm.pid
24 ;error_log = log/php-fpm.log



#测试php-fpm配置
php-fpm -t
php-fpm -c /usr/local/etc/php/7.2/php.ini -y /usr/local/etc/php/7.2/php-fpm.conf -t

#启动php-fpm
php-fpm -D
php-fpm -c /usr/local/etc/php/7.1/php.ini -y /usr/local/etc/php/7.1/php-fpm.conf -D

#关闭php-fpm
kill -INT `cat /usr/local/var/run/php-fpm.pid`

#重启php-fpm
kill -USR2 `cat /usr/local/var/run/php-fpm.pid`

#启动|停止|重启 PHP
brew services start|stop|restart php