2018-1-1.jpg
MAMP MAMP is meaning Mac Apache MySql Php
一伯病、Apache 的配置(Mac 自帶)
- 常用命令
sudo apachectl start //開啟apache服務(wù),檢查是否真的開啟了桑包,可在瀏覽器輸入localhost, 界面顯示 It works!
sudo apachectl stop //停止apache服務(wù)
sudo apachectl restart //重啟服務(wù)
httpd -v //查看版本
在瀏覽器輸入 localhost 可以看見
2018-2-27
- 更改程序目錄
$ cd /Users/emily/ //Emily是我自己的用戶名鸿染,這里要改成自己的
$ open . //打開這個(gè)目錄钞诡,在這個(gè)目錄下新建一個(gè)文件夾Sites
$ cd /etc/apache2/users/
$ ls //查看該目錄下的文件,有兩個(gè)文件雨膨,有一個(gè)為用戶名.conf
$ sudo vim emily.conf //這里要改成自己的
<Directory "/Users/emily/Sites/">
Options Indexes MultiViews
Require all granted
</Directory>
$ sudo chmod 644 emily.conf //修改這個(gè)文件的權(quán)限為644
- 修改 httpd.conf 文件
$ cd /etc/apache2/
$ open .
$ sudo vim httpd.conf
找到 httpd.conf 文件稼锅,用 Sublime 打開窄赋,找到下面這兩行把前面的#去掉
# LoadModule userdir_module libexec/apache2/mod_userdir.so
# Include /private/etc/apache2/extra/httpd-userdir.conf
找到 httpd-userdir.conf 文件,找到'' # Include /private/etc/apache2/users/*.conf ''這行把#去掉
$ cd /etc/apache2/extra/
$ open .
$ sudo vim httpd-userdir.conf
結(jié)果:
sudo apachectl restart //重啟apache
瀏覽器輸入: loacal/~Emily/
2018-2-27
二、MySql 的配置
$ brew info mysql
$ brew install mysql
$ brew tap homebrew/services
$ brew services start mysql
$ brew services list
$ mysql -V
mysql Ver 14.14 Distrib 5.7.20, for osx10.13 (x86_64) using EditLine wrapper
$ mysqladmin -u root password 'yourpassword'
配置 root 密碼時(shí)遇到的問題
$ mysqladmin -u root password '123456'
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)
$ mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
$ ALTER USER 'rooot'@'localhost' IDENTFIED BY '123456'
-bash: ALTER: command not found
解決方法
mac-mini:~ emily$ mysql
-bash: mysql: command not found
mac-mini:~ emily$ mysql -v
-bash: mysql: command not found
mac-mini:~ emily$ brew uninstall mysql
Uninstalling /usr/local/Cellar/mysql/5.7.21... (323 files, 233.9MB)
mac-mini:~ emily$ brew install mysql
==> Downloading https://homebrew.bintray.com/bottles/mysql-5.7.21.high_sierra.bo
Already downloaded: /Users/emily/Library/Caches/Homebrew/mysql-5.7.21.high_sierra.bottle.tar.gz
==> Pouring mysql-5.7.21.high_sierra.bottle.tar.gz
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
To have launchd start mysql now and restart at login:
brew services start mysql
Or, if you don't want/need a background service you can just run:
mysql.server start
==> Summary
?? /usr/local/Cellar/mysql/5.7.21: 323 files, 233.9MB
mac-mini:~ emily$ mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Using existing password for root.
Estimated strength of the password: 25
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
New password:
Re-enter new password:
Estimated strength of the password: 50
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n
... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
三嫂便、Php配置
$ cd /etc/apache2/
$ open .
用 Sublime 打開文件捞镰,找到下面這一行,去掉#
#LoadModule php7_module libexec/apache2/libphp7.so //把#去掉即可,7不是固定的岸售,看你的版本是多少
$ cd
$ sudo apachectl restart
2018-2-27
四践樱、PhpMyAdmin的配置
- 下載
- 解壓文件夾命名為PhpMyAdmin,并存儲(chǔ)到/Users/emily/Sites/目錄下
$ cd /Users/emily/Sites/PhpMyAdmin
$ mkdir config
$ chmod o+w config
打開瀏覽器凸丸,輸入http://localhost/~emily/phpmyadmin/setup/
2018-2-27
保存配置之后拷邢,刪除 config 文件在瀏覽器輸入http://localhost/~emily/phpmyadmin/
2018-2-27
五、我踩過的那些坑
- phpMyAdmin登錄問題
#2002 - No such file or directory — 服務(wù)器沒有響應(yīng)(或本地服務(wù)器的套接字沒有正確設(shè)置)
解決方法:
cd /Users/emily/Sites/phpmyadmin/ //Emily是我的用戶名
open .
打開之后找到config.inc.php屎慢,這句
i]['host'] = 'localhost';
改成
i]['host'] = '127.0.0.1';
進(jìn)入phpmyadmin下面的libraries文件夾瞭稼,打開config.default.php,
i]['host'] = 'localhost';
改成
i]['host'] = '127.0.0.1';
我裝好了 phpMyAdmin后腻惠,遇見了 MAMP pro环肘。只想說不走過彎路是不會(huì)遇見捷徑的。
mysql 命令行不熟悉的妖枚,可以下載Sequel pro做輔助廷臼。