使用MAMP Pro 搭建FastAdmin踩坑记

FastAdmin踩坑记, 搭建一个简单的后台居然花了我三个多小时!!!

写在前面

本地开发请尽量不用代理!!!

Mac下搭建开发环境,只能访问localhost,找了各种问题,最后发现是翻墙的原因!

MAMP PRO 配置伪静态这个大坑!!!

使用MAMP PRO搭建好FastAdmin后只能访问首页,无法访问别的。

  • Apache

安装后只能访问首页,其它页均报no input file specified

  • Nginx

安装后只能访问首页,其它页均报404 page not found

开始找解决办法

首先找 Nginx(nginx.conf)

  • /Applications/MAMP/conf/nginx/nginx.conf

哗哗的将这段代码复制到nginx.conf中,跑起来,尼玛,为啥还是404!

看了下官网。。。

  • Use Nginx as a Reverse Proxy for Apache

    Check to use Nginx as a reverse proxy for Apache. When this option is checked the following will be added to your /Library/Application Support/appsolute/MAMP PRO/conf/nginx.conf file. Your requests will now be forwarded to your Apache server localhost.

https://documentation.mamp.info/en/MAMP-PRO-Mac/Servers-and-Services/Nginx/

哗哗的将这段代码复制到上面的nginx.conf中,跑起来,尼玛,为啥还是404!

多次尝试无果,在一篇博客上看到

https://documentation.mamp.info/en/MAMP-PRO-Mac/Menu/File/
MAMP PRO uses templates to create the necessary server config files. You can edit these templates from the menu item File > Edit Template. Here, you have access to options which are not accessible from the MAMP PRO user interface.

可怕!

打开File/Edit Template/Nginx(nginx.conf),加入以下代码:

1
2
3
4
5
6
7
8
9
10
location / {
index index.html index.htm index.php;
#主要是这一段一定要确保存在
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
#结束
#autoindex on;
}

这个大坑终于得到解决~

Powered by Hexo and Hexo-theme-hiker

Copyright © 2017 - 2023 Keep It Simple And Stupid All Rights Reserved.

访客数 : | 访问量 :