Mac下使用homebrew安装php环境
2018-01-10 10:02
405 查看
1. 安装apache
brew install httpd
2. 安装nginx
brew install nginx
3. 添加php拓展库
brew tap homebrew/homebrew-php
4. 安装php
brew install homebrew/php/php56 --with-httpd --with-fpm
–with-httpd:编译libphp5.so给httpd
–with-fpm:nginx需要php-fpm
5. 配置apche
# httpd.conf 添加这三行 LoadModule php5_module /usr/local/Cellar/php56/5.6.32_8/libexec/apache2/libphp5.so AddType application/x-httpd-php .php DirectoryIndex index.php index.htm index.html
6. 配置nginx
# nginx.conf 添加以下内容 server { listen 80; server_name www.xxx.cn; root /Users/Icecream/Web/xxx; # 文件不存在则重定向到/index.php/xxx(/login.html => /index.php/login.html) if (!-f $request_filename) { rewrite ^(.*)$ /index.php$1 break; } location / { #root html; index index.html index.php; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; # nginx配置pathifo fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; } }
7. 其他
7.1. homebrew 替换国内源参见: https://lug.ustc.edu.cn/wiki/mirrors/help/brew.git
7.2. 使用 unlink&link 切换php
当前php为php56,切换至php70
终端执行:
step 1. brew unlink php56
step 2. brew link php70
7.3. 查看homebrew安装的程序
homebrew list
7.4. 查看homebrew安装的服务
brew services list
7.5. 启动homebrew安装的服务
brew services start|stop|restart xxx
例如:
brew start nginx
brew stop nginx
brew restart nginx
P.s. nginx如使用80端口,则需管理员权限,使用sudo运行命令
sudo brew start nginx
7.6. homebrew卸载程序
brew uninstall xxx
例如:
brew uninstall nginx
相关文章推荐
- MAC使用brew安装nginx+php+mysql环境
- 全新安装Mac OSX 开发者环境 同时使用homebrew搭建 PHP,Nginx ,MySQL,Redis,Memcache ... ... (LNMP开发环境)
- 全新安装Mac OSX 开发者环境 同时使用homebrew搭建 PHP,Nginx ,MySQL,Redis,Memcache ... ... (LNMP开发环境)
- 全新安装Mac OSX 开发者环境 同时使用homebrew搭建 PHP,Nginx ,MySQL,Redis,Memcache ... ... (LNMP开发环境)
- Mac OS X下使用Homebrew安装PNG支持——重新编译PHP
- MAC使用brew安装Nginx+PHP+MySql环境
- 全新安装Mac OSX 开发者环境 同时使用homebrew搭建 PHP,Nginx ,MySQL,Redis,Memcache ... ... (LNMP开发环境)
- 全新安装Mac OSX 开发者环境 同时使用homebrew搭建 PHP,Nginx ,MySQL,Redis,Memcache ... ... (LNMP开发环境)
- 在Mac下使用homebrew安装apache+nginx+多个版本PHP切换
- Mac——homebrew安装PHP环境
- Mac 使用homebrew搭建 PHP 运行环境
- Mac环境下安装PHP及使用xdebug调试
- Mac 使用homebrew搭建 PHP 运行环境
- mac环境中使用brew安装php5.5.15
- [PHP] Mac下homebrew安装及php.mysql.nginx环境安装及配置
- MAC使用brew安装nginx+php+mysql环境
- 全新安装Mac OSX 开发者环境 同时使用homebrew搭建 PHP,Nginx ,MySQL,Redis,Memcache ... ... (LNMP开发环境)
- mac环境中使用brew安装php5.5.15
- Mac OS X下使用Homebrew安装PNG支持——重新编译PHP
- 全新安装Mac OSX 开发者环境 同时使用homebrew搭建 PHP,Nginx ,MySQL,Redis,Memcache ... ... (LNMP开发环境)