在Mac OS里配置Apache+PHP+Mysql环境
Apache+PHP+Mysql是PHP开发的标配,Windows系统可以安装EasyPHP集成包。Mac系统也有相应的集成包MAMP。但是考虑到Mac OS已经自带了Apache和PHP环境,重复安装Apache和PHP有些冗余,所有本文介绍如何使用homebrew安装Mysql并且集成原有的Apache和PHP环境。 启
Apache+PHP+Mysql是PHP开发的标配,Windows系统可以安装EasyPHP集成包。Mac系统也有相应的集成包MAMP。但是考虑到Mac OS已经自带了Apache和PHP环境,重复安装Apache和PHP有些冗余,所有本文介绍如何使用homebrew安装Mysql并且集成原有的Apache和PHP环境。
启动Apache
打开Terminal,然后运行
sudo apachectl start
查看Mac OS X的Apache版本
sudo apachectl -v
Mac OS X 10.9的返回结果是
Server version: Apache/2.2.24 (Unix)
Server built: Aug 24 2013 21:10:43
如此在浏览器中输入http://localhost
,就可以看到一个内容为“It works!”的页面,其位于/Library(资源库)/WebServer/Documents/
下,这就是Apache的默认根目录。
另外,用户可以通过http://[本地IP]/~[用户名]
来访问/Users/[用户名]/Sites/
目录
开启PHP支持
- 在终端中运行
sudo vi /etc/apache2/httpd.conf
,打开Apache的配置文件。 - 找到
#LoadModule php5_module libexec/apache2/libphp5.so
,把前面的#号去掉,保存(在命令行输入:w)并退出vi(在命令行输入:q)。 -
运行
sudo cp /etc/php.ini.default /etc/php.ini
,这样就可以运行sudo vi /etc/php.ini
来编辑php.ini配置各种功能了。比如:;通过下面两项来调整PHP提交文件的最大值,如phpMyAdmin中导入数据的最大值 upload_max_filesize = 2M post_max_size = 8M ;通过display_errors来控制是否显示PHP程序的报错信息,这在调试PHP程序时非常有用 display_errors = Off
- 运行“sudo apachectl restart”,重启Apache,这样PHP就可以用了。
安装Xdebug
- 在终端执行
php -i | pbcopy
,php的输出信息会被拷贝的剪切板。 - 打开xdebug安装在线向导,在文本框内Command+V,将剪切板内的内容拷贝到文本框,然后点击“Analyse my phpinfo() output”按钮。
- 根据生成的步骤安装即可。
安装Mysql
这一步最简单了,前提是已安装了HomeBrew。 在命令行执行
brew install mysql
安装完成以后,启动mysql服务
mysql.server start
参考阅读
- 在Mac OS X中配置Apache + PHP + MySQL
原文地址:在Mac OS里配置Apache+PHP+Mysql环境, 感谢原作者分享。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Many Mac users tend to keep the default name of their device and may never consider changing it. Many people choose to stick with the name from the initial setup, such as "Johnny's MacBook Air" or simply "iMac." Learning how to change the name of your Mac is a very useful skill, especially when you have multiple devices, as it can help you quickly distinguish and manage them. Next, we will teach you step by step how to change the computer name, host name and Bonjour name (local host name) in macOS system. Why should you change your Mac name? Changing the name of your Mac can not only show your personality, but also help improve the user experience: Personalize your Mac: The default name may not be to your taste, change it to a name you like.

Title: The working principle and configuration method of GDM in Linux systems In Linux operating systems, GDM (GNOMEDisplayManager) is a common display manager used to control graphical user interface (GUI) login and user session management. This article will introduce the working principle and configuration method of GDM, as well as provide specific code examples. 1. Working principle of GDM GDM is the display manager in the GNOME desktop environment. It is responsible for starting the X server and providing the login interface. The user enters

Recently, some friends have consulted the editor about how to set up WeChat Mac to automatically convert voice messages into text. The following is a method for setting up WeChat Mac to automatically convert voice messages into text. Friends in need can come and learn more. Step 1: First, open the Mac version of WeChat. As shown in the picture: Step 2: Next, click "Settings". As shown in the picture: Step 3: Then, click "General". As shown in the picture: Step 4: Then check the option "Automatically convert voice messages in chat to text". As shown in the picture: Step 5: Finally, close the window. As shown in the picture:

Understanding Linux Bashrc: Function, Configuration and Usage In Linux systems, Bashrc (BourneAgainShellruncommands) is a very important configuration file, which contains various commands and settings that are automatically run when the system starts. The Bashrc file is usually located in the user's home directory and is a hidden file. Its function is to customize the Bashshell environment for the user. 1. Bashrc function setting environment

By default, iPhone takes photos from the camera in HEIC format. HEIC stands for High Efficiency Image Container and can hold more pixel data than PNG or JPG files, taking up significantly less space on iPhone storage compared to other formats. These files work best on iPhones but are not widely accepted on the internet because they often result in blurry/grainy pictures when you share them with non-Apple devices. To ensure that HEIC images are compatible on other devices, you may need to convert them to JPG format. This article will introduce how to convert HEIC images to JPG on Mac. How to Convert HEIC Photos to JPG on Mac [3 Methods] Method

Title: How to configure and install FTPS in Linux system, specific code examples are required. In Linux system, FTPS is a secure file transfer protocol. Compared with FTP, FTPS encrypts the transmitted data through TLS/SSL protocol, which improves Security of data transmission. In this article, we will introduce how to configure and install FTPS in a Linux system and provide specific code examples. Step 1: Install vsftpd Open the terminal and enter the following command to install vsftpd: sudo

Formatting the drive of your Mac system is crucial for proper functioning. It helps prevent various system problems and makes your Mac more stable overall. While naturally Mac supports various partitioning schemes, GUID offers more modern and versatile features compared to other options. Also essential for newer Macs and supports larger drives, giving you the best compatibility and stability. This guide will take an in-depth look at how to format a drive using a GUID on macOS. That said, let's get started. Why GUID is important for macOS installation A GUID (full form of Globally Unique Identifier) is a partitioning scheme that helps install and run the macOS operating system. It is better than traditional MBR (main lead

Ever since the Apple M4-powered OLED iPad Prolineuparrived, Apple Silicon aficionados have been eagerly awaiting the arrival of the M4 SoC on the Mac lineup. The M4 was undeniably a major leap forward in both compute and graphics performance - leapfr
