Mac MAMP 開發(fā)環(huán)境

2018-1-1.jpg

MAMP MAMP is meaning Mac Apache MySql Php

一伯病、Apache 的配置(Mac 自帶)

  1. 常用命令
 sudo apachectl start  //開啟apache服務(wù),檢查是否真的開啟了桑包,可在瀏覽器輸入localhost, 界面顯示 It works!
 sudo apachectl stop  //停止apache服務(wù)
 sudo apachectl restart  //重啟服務(wù) 
 httpd -v  //查看版本

在瀏覽器輸入 localhost 可以看見

2018-2-27
  1. 更改程序目錄
$ 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 
  1. 修改 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的配置

  1. 下載
  2. 解壓文件夾命名為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

五、我踩過的那些坑

  1. phpMyAdmin登錄問題
 #2002 - No such file or directory &mdash; 服務(wù)器沒有響應(yīng)(或本地服務(wù)器的套接字沒有正確設(shè)置)

解決方法:

cd /Users/emily/Sites/phpmyadmin/  //Emily是我的用戶名
open .

打開之后找到config.inc.php屎慢,這句
cfg['Servers'][i]['host'] = 'localhost';
改成
cfg['Servers'][i]['host'] = '127.0.0.1';
進(jìn)入phpmyadmin下面的libraries文件夾瞭稼,打開config.default.php,
cfg['Servers'][i]['host'] = 'localhost';
改成
cfg['Servers'][i]['host'] = '127.0.0.1';

  1. 我裝好了 phpMyAdmin后腻惠,遇見了 MAMP pro环肘。只想說不走過彎路是不會(huì)遇見捷徑的。

  2. mysql 命令行不熟悉的妖枚,可以下載Sequel pro做輔助廷臼。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市绝页,隨后出現(xiàn)的幾起案子荠商,更是在濱河造成了極大的恐慌,老刑警劉巖续誉,帶你破解...
    沈念sama閱讀 219,490評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件莱没,死亡現(xiàn)場離奇詭異,居然都是意外死亡酷鸦,警方通過查閱死者的電腦和手機(jī)饰躲,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,581評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來臼隔,“玉大人嘹裂,你說我怎么就攤上這事∷の眨” “怎么了寄狼?”我有些...
    開封第一講書人閱讀 165,830評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長氨淌。 經(jīng)常有香客問我泊愧,道長,這世上最難降的妖魔是什么盛正? 我笑而不...
    開封第一講書人閱讀 58,957評(píng)論 1 295
  • 正文 為了忘掉前任删咱,我火速辦了婚禮,結(jié)果婚禮上豪筝,老公的妹妹穿的比我還像新娘痰滋。我一直安慰自己摘能,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,974評(píng)論 6 393
  • 文/花漫 我一把揭開白布即寡。 她就那樣靜靜地躺著徊哑,像睡著了一般。 火紅的嫁衣襯著肌膚如雪聪富。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,754評(píng)論 1 307
  • 那天著蟹,我揣著相機(jī)與錄音墩蔓,去河邊找鬼。 笑死萧豆,一個(gè)胖子當(dāng)著我的面吹牛奸披,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播涮雷,決...
    沈念sama閱讀 40,464評(píng)論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼阵面,長吁一口氣:“原來是場噩夢(mèng)啊……” “哼!你這毒婦竟也來了洪鸭?” 一聲冷哼從身側(cè)響起样刷,我...
    開封第一講書人閱讀 39,357評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎览爵,沒想到半個(gè)月后置鼻,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,847評(píng)論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡蜓竹,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,995評(píng)論 3 338
  • 正文 我和宋清朗相戀三年箕母,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片俱济。...
    茶點(diǎn)故事閱讀 40,137評(píng)論 1 351
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡嘶是,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出蛛碌,到底是詐尸還是另有隱情聂喇,我是刑警寧澤,帶...
    沈念sama閱讀 35,819評(píng)論 5 346
  • 正文 年R本政府宣布左医,位于F島的核電站授帕,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏浮梢。R本人自食惡果不足惜跛十,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,482評(píng)論 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望秕硝。 院中可真熱鬧芥映,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,023評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至惊来,卻和暖如春丽涩,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背裁蚁。 一陣腳步聲響...
    開封第一講書人閱讀 33,149評(píng)論 1 272
  • 我被黑心中介騙來泰國打工矢渊, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人枉证。 一個(gè)月前我還...
    沈念sama閱讀 48,409評(píng)論 3 373
  • 正文 我出身青樓矮男,卻偏偏與公主長得像,于是被迫代替她去往敵國和親室谚。 傳聞我的和親對(duì)象是個(gè)殘疾皇子毡鉴,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,086評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容