Table of Contents
tags: homebrew
1、cakebrew
2、adminer
Home Backend Development PHP Tutorial MAC下用homebrew安装及配置apache、php和mysql

MAC下用homebrew安装及配置apache、php和mysql

Jun 23, 2016 pm 01:38 PM

title: MAC下用homebrew安装及配置apache、php和mysql
date: 2015/03/22 20:07:00

tags: homebrew

我们用到php运行环境的时候总喜欢用集成包,其实在mac下,用homebrew也可以很快的安装这些东西,配置也很简单。

homebrew

homebrew是mac下的一个包安装管理工具,使用非常简单方便。

安装homebrew

在终端中执行:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Copy after login

这样就安装好homebrew了。

安装命令行软件

如安装wget,则执行:

brew install wget
Copy after login

其它具体的使用方法可自行翻阅 官网(中文)。

安装apache php mysql

因为apache和php不在默认的仓库里,所以我们要先添加其所在的仓库。

brew tap homebrew/apachebrew tap homebrew/php
Copy after login

之后就是正常的安装了,安装过程homebrew会为你自行处理各种依赖。

brew install httpd24brew install php53brew install mysql
Copy after login

注意:apache在homebrew中的名字为httpd。
这些都可以指定安装的版本,这里我安装apache2.4,php5.3,mysql是最新版。
以下的路径说明都是以这个为基准,请自行修改为你所下载的版本。

配置apache

配置文件路径为/usr/local/etc/apache2/2.4/httpd.conf,以下的配置都需要在相应的地方修改。

添加php模块
# ====php module====LoadModule php5_module /usr/local/Cellar/php53/5.3.29/libexec/apache2/libphp5.so<IfModule mod_php5.c>    AddType application/x-httpd-php .php    AddType application/x-httpd-php-source .phps    <IfModule mod_dir.c>        DirectoryIndex index.html index.php    </IfModule></IfModule>
Copy after login
修改监听端口
默认的端口为8080,我们改为80:
Listen 80
Copy after login
修改root根目录
DocumentRoot "/Users/lonewolf/Public/dev/php/app"<Directory "/Users/lonewolf/Public/dev/php/app">
Copy after login

请自行修改为你的目录

配置mysql

使用默认的mysql配置启动时,会占用434M的内存,这个占用太多了,所以要修改一下。
配置路径为/usr/local/Cellar/mysql/5.6.23/my.cnf。

# ========skip-external-lockingkey_buffer = 16Mmax_allowed_packet = 1Mtable_open_cache = 64sort_buffer_size = 512Knet_buffer_length = 8Kread_buffer_size = 256Kread_rnd_buffer_size = 512Kmyisam_sort_buffer_size = 8M# ========
Copy after login

这样启动之后就下降到100M以下了。

到这里,我们的安装和配置就完成了,不过有一点很不好,就是启动和停止这些服务都需要在命令行下输入,有没有图形化的管理界面呢?
有的,答案是LaunchRocket,说这个之前我们先来了解一下另一个工具homebrew-cask。

homebrew-cask

homebrew-cask是homebrew的一个扩展,用于安装图形界面mac程序,如google chrome、QQ等等。

安装
brew install caskroom/cask/brew-cask
Copy after login
使用
brew cask install google-chrome
Copy after login

具体的功能请翻阅官网。

LaunchRocket

LaunchRocket是管理homebrew所安装应用的一个管理器,它在系统设置中。
安装命令:

brew cask install launchrocket
Copy after login

界面如下:

不知道为什么,httpd需要选As Root才能真正运行起来。

到此,安装、配置、运行各方面都完成了。

其它工具

最后介绍两个有用的工具:

1、cakebrew

cakebrew是图形化管理homebrew的一个软件,也就是让你不用敲命令即可安装软件。

2、adminer

adminer是用php写的一个数据库管理工具,可以管理 MySQL, PostgreSQL, SQLite, MS SQL, Oracle, MongoDB等类型数据库,而且还是单文件,安装部署非常方便,支持多种语言。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Working with Flash Session Data in Laravel Working with Flash Session Data in Laravel Mar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

cURL in PHP: How to Use the PHP cURL Extension in REST APIs cURL in PHP: How to Use the PHP cURL Extension in REST APIs Mar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Simplified HTTP Response Mocking in Laravel Tests Simplified HTTP Response Mocking in Laravel Tests Mar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

PHP Logging: Best Practices for PHP Log Analysis PHP Logging: Best Practices for PHP Log Analysis Mar 10, 2025 pm 02:32 PM

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

12 Best PHP Chat Scripts on CodeCanyon 12 Best PHP Chat Scripts on CodeCanyon Mar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Explain the concept of late static binding in PHP. Explain the concept of late static binding in PHP. Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Customizing/Extending Frameworks: How to add custom functionality. Customizing/Extending Frameworks: How to add custom functionality. Mar 28, 2025 pm 05:12 PM

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

See all articles