####Mac下编译安装php-7.0
- 首先在PHP官网下载PHP源代码
- 解压:tar -zxvf php-7.04.tar.gz
- cd php-7.04 进入源文件内部
php7.0 不在支持取消mysql直连扩展,请使用mysqli 或者pdo方式连接数据库
- --prefix =/usr/local/php 指定安装目录
- --with-config-file-path 指定php.ini位置
./configure --prefix=/usr/local/php --with-config-file-path=/etc/php --enable-fpm --enable-pcntl --enable-mysqlnd --enable-opcache --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-shmop --enable-zip --enable-ftp --enable-soap --enable-xml --enable-mbstring --disable-rpath --disable-debug --disable-fileinfo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pcre-regex --with-iconv --with-zlib --with-mcrypt --with-gd --with-mhash --with-xmlrpc --with-curl --with-imap-ssl
sudo make && make install
创建配置文件,并将其复制到正确的位置
cp php.ini-development /usr/local/php/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf
cp sapi/fpm/php-fpm /usr/local/bin
到此PHP就安装完成了 #####Nginx
通过home brew 来安装nginx
brew install nginx
修改默认的location块,使其支持.php文件
location / {
root html;
index index.php index.html index.htm;
}
配置.php文件请求被传送到后端的php-fpm模块取消默认的php配置快的注释
location ~* \.php$ {
fastcgi_index index.php;
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;
}
启动php-fpm
/usr/local/bin/php-fpm
启动nginx
sudo nginx //启动nginx
small tips:
重启nginx:sudo nginx -s reload
附录:
- 报错信息
需要将/usr/local/etc/php-fpm.d/下的www.conf.default.conf 改名为www.conf
3.WARNING: Nothing matches the include pattern '/usr/local/etc/php-fpm.d/*.conf' from /usr/local/etc/php-fpm.conf at line 125.
ERROR:. No pool defined at least one pool section must be specified in config file
ERROR: failed to post process the configuration
ERROR: FPM initialization failed
solution:
cp www.conf.default www.conf