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环境, 感谢原作者分享。

MySQLhandlesconcurrencyusingamixofrow-levelandtable-levellocking,primarilythroughInnoDB'srow-levellocking.ComparedtootherRDBMS,MySQL'sapproachisefficientformanyusecasesbutmayfacechallengeswithdeadlocksandlacksadvancedfeatureslikePostgreSQL'sSerializa

MySQLhandlestransactionseffectivelyusingtheInnoDBengine,supportingACIDpropertiessimilartoPostgreSQLandOracle.1)MySQLusesREPEATABLEREADasthedefaultisolationlevel,whichcanbeadjustedtoREADCOMMITTEDforhigh-trafficscenarios.2)Itoptimizesperformancewithabu

MySQLisbetterforspeedandsimplicity,suitableforwebapplications;PostgreSQLexcelsincomplexdatascenarioswithrobustfeatures.MySQLisidealforquickprojectsandread-heavytasks,whilePostgreSQLispreferredforapplicationsrequiringstrictdataintegrityandadvancedSQLf

MySQL processes data replication through three modes: asynchronous, semi-synchronous and group replication. 1) Asynchronous replication performance is high but data may be lost. 2) Semi-synchronous replication improves data security but increases latency. 3) Group replication supports multi-master replication and failover, suitable for high availability requirements.

The EXPLAIN statement can be used to analyze and improve SQL query performance. 1. Execute the EXPLAIN statement to view the query plan. 2. Analyze the output results, pay attention to access type, index usage and JOIN order. 3. Create or adjust indexes based on the analysis results, optimize JOIN operations, and avoid full table scanning to improve query efficiency.

Using mysqldump for logical backup and MySQLEnterpriseBackup for hot backup are effective ways to back up MySQL databases. 1. Use mysqldump to back up the database: mysqldump-uroot-pmydatabase>mydatabase_backup.sql. 2. Use MySQLEnterpriseBackup for hot backup: mysqlbackup--user=root-password=password--backup-dir=/path/to/backupbackup. When recovering, use the corresponding life

The main reasons for slow MySQL query include missing or improper use of indexes, query complexity, excessive data volume and insufficient hardware resources. Optimization suggestions include: 1. Create appropriate indexes; 2. Optimize query statements; 3. Use table partitioning technology; 4. Appropriately upgrade hardware.

MySQL view is a virtual table based on SQL query results and does not store data. 1) Views simplify complex queries, 2) Enhance data security, and 3) Maintain data consistency. Views are stored queries in databases that can be used like tables, but data is generated dynamically.


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

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version
Chinese version, very easy to use

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
