一‘、配置与启动 apache
osx自带apache
使用
sudo apachectl start
启动apache服务
apache根目录在
/Library/WebServer/Documents/
下
重启命令为
sudo apachectl restart
关闭服务命令
sudo apachectl stop
然后输入top命令查看进程是否含有http
配置php 环境
1。开启重写模块和php模块
前往文件夹 /etc/apache2/ 然后打开httpd.conf
找到168 169 212行
#LoadModule rewrite_module libexec/apache2/mod_rewrite.so
#LoadModule php5_module libexec/apache2/libphp5.so
#ServerName www.example.com:80
去掉前面的#
2.拷贝php配置文件。
在终端输入
cd /etc
sudo cp php.ini.default php.ini
3.添加默认页面
在httpd.conf 271行 修改成
DirectoryIndex index.php index.html index.htm
然后重启apache
在终端输入
sudo apachectl restart
4。配置虚拟目录
找到第499行
#Include /private/etc/apache2/extra/httpd-vhosts.conf
去掉前面的#
找到181 182行
User _www
Group _www
将User 后面的修改成你的用户名
Group 后面的修改成staff
打开/extra/httpd-vhosts.conf
清空里面的内容
首先添加你的默认的虚拟主机目录
<virtualhost *:80>
ServerName localhost
ServerAlias 127.0.0.1
DocumentRoot "/Users/soul/Desktop/Apache/docs"
<Directory "/Users/soul/Desktop/Apache/docs">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "/Users/soul/Desktop/Apache/logs/error_log"
CustomLog "/Users/soul/Desktop/Apache/logs/access_log" common
</virtualhost>
然后添加虚拟目录
<virtualhost *:80>
ServerName soul.localhost.com
DocumentRoot "/Users/soul/Desktop/Apache/docs/soul.localhost.com/public"
<Directory "/Users/soul/Desktop/Apache/docs/soul.localhost.com/public">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "/Users/soul/Desktop/Apache/docs/soul.localhost.com/logs/error_log"
CustomLog "/Users/soul/Desktop/Apache/docs/soul.localhost.com/logs/access_log" common
</virtualhost>
打开hosts 添加
127.0.0.1 soul.localhost.com
安装mysql
1.http://dev.mysql.com/downloads/下载 msyql安装包 安装。
2.将mysql命令加入环境变量
1.首先启动mysql服务。
2.打开终端,输入: cd ~
会进入~文件夹
3.然后输入:touch .bash_profile
回车执行后,
4.再输入:open -e .bash_profile
会在TextEdit中打开这个文件(如果以前没有配置过环境变量,那么这应该是一个空白文档)。如果有内容,请在结束符前输入,如果没有内容,请直接输入如下语句:
export PATH=${PATH}:/usr/local/mysql/bin
然后,保存,退出TextEdit(一定是退出),关闭终端并退出。
设置mysql帐号密码在终端输入命令:mysqladmin -u root -p password "root"
由于没有密码直接回车即可
ok