Home > Article > Backend Development > Apache+MySQL+PHP development environment installation process under Mac apache download apache official website apache distribution
Max comes with its own Apache and PHP servers. No additional installation is required. This article will introduce the relevant configurations.
First: Apache
Enter in the terminal, the following command can start the Apache server:
//启动 sudo apachectl-k start //重新启动 sudo apachectl -k restart
Verification:
Enter in the browser: http://127.0.0.1, it will show It Works! , which proves that the server has been started.
But since the default site is located in the system path, we modify it to a custom path. So you need to make relevant configurations
Modify the site location:
Enter
cd /etc/apache2/ sudo vim httpd.conf // 会提示输入密码,输入后回车即可 英文下输入: /DocumentRoot,查找, 注:1:注意区分大小写;2:要修改两个地方,故要进行两次查找。
in the terminal. After the first search, modify:
After the second search, modify
After modification: wq Save and exit, restart the server, and place the html file in the customized path to access it.
Second: Configure the PHP server:
1: Enter the command in the terminal:
cd /etc/apache2 sudo vim httpd.conf 按 /php,进行搜索,把带有LoadModule php5…..这一行的#(注释符号)去掉即可。 ![](http://images.cnitblog.com/blog2015/589133/201503/231410352395226.png)
2: Enter the command in the terminal:
cd /etc/ sudo cp php.ini.default php.ini
Restart the server, place the php file under the customized site path, and you can access the php content.
Third: MySQ installation:
MySql download: http://dev.mysql.com/downloads/mysql/ MySqlWorkbench download: http://dev.mysql.com/downloads/workbench/
Just install it directly after downloading, just default all the way
MySql Configuration:
Open the terminal and enter:
vim ~/.bash_profile
Enter i to edit, then paste the following content
# mysql alias mysql='/usr/local/mysql/bin/mysql' alias mysqladmin='/usr/local/mysql/bin/mysqladmin' # ls alias ls='ls -G'
Press ESC key and enter: wq
In this way, you can enter mysql by directly typing mysql in the terminal. Enter exit to exit
Change the administrator password of MySql, enter in the terminal:
mysqladmin -u root password "root" 启动Mysql服务 sudo /Library/StartupItems/MySQLCOM/MySQLCOM start 停止Mysql服务 sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop 重启Mysql服务 sudo /Library/StartupItems/MySQLCOM/MySQLCOM restart
At this point, the installation and configuration of Apache+MySQL+PHP is completed.
Attachment: An introduction to the vim editor
vim has two modes:
1: Command mode
shift+v -> 选中一行 y -> 复制一行 yy -> 复制当前行 (yank current line) p -> 在当前行的下一行复制粘贴的内容 x -> 删除一个字符 :wq -> 保存退出 :q! -> 不保存退出 i -> 进入编辑 / -> 按/再输入字符可进行查找
2: Editing mode, you can edit the document directly, press the esc key to exit the editing mode
The above introduces the installation process of Apache+MySQL+PHP development environment under Mac, including the content of Apache and Mysql. I hope it will be helpful to friends who are interested in PHP tutorials.