安装环境如下:
mac os 10.10.1 apache 2.4.9 php 5.5.14 mysql 5.6.22 apache配置
在mac os 10.10.1中是自带apache软件的,我们只需要启动对应的服务就好了,以下命令是操作apache时常用的几个命令
// 启动apache服务sudo apachectl start// 重新启动apache服务sudo apachectl restart// 关闭apache服务sudo apachectl stop// 查看apache的版本httpd -v
先启动apache服务吧,然后在浏览器中输入localhost。出现it works字样,说明apache就搞定了。
在macbook pro下,apache的网站服务器根目录在/library/webserver/documents路径下。
php
在mac os中已经自带了php了,我们只需要在apache的配置文件中添加apache对php的支持就好了,步骤如下:
编辑http.conf配置文件,命令如下:
sudo vim /etc/apache2/httpd.conf
去掉以下部分的注释:
loadmodule php5_module libexec/apache2/libphp5.so
重启apache服务吧;写一个简单的测试文件测试一下。
mysql
安装mysql是比较麻烦的,由于在mac os中是直接带有apache和php的,所以安装它们,比较简单,而mysql是不带的,需要我们去官网下载。
下载完成以后,直接安装吧。安装完成以后,从 system preferences 中启动mysql服务,如下图所示:
安装完在命令行运行啥命令都会报一下错误,需要改下密码:
mac mysql error you must reset your password using alter user statement before executing this statement.
step 1: set password = password(‘your new password’);
step 2: alter user ‘root’@’localhost’ password expire never;
step 3: flush privileges;
完成以上三步退出再登,使用新设置的密码就行了,以上除了红色的自己修改成新密码外,其他原样输入即可
参考 1: https://dev.mysql.com/doc/refman/5.6/en/alter-user.html
参考 2: http://dev.mysql.com/doc/refman/5.7/en/password-expiration-policy.html
参考 3: http://stackoverflow.com/questions/33467337/reset-mysql-root-password-using-alter-user-statement-after-install-on-mac
