mamp nginx php7,MAMP Pro开发环境中使用Nginx时 访问TP路由提示模块不存在解决方案...

前言

使用Mac进行php开发的时候 使用的最多的集成环境就是Mamp了,但是mamp 这个坑特别多 ,首先实际在使用的时候,如果有钱用mamp pro,mamp完全多余,没钱只能用mamp,而且新版的很不友好,只能开启和停止服务器,连切换php版本以及其他配置都需要手动修改,不太友好。

说说坑一:

mamp 和 mamp pro的配置文件是不一样的,注意,真的不一样,虽然使用同一个apache ,nginx 和mysql ,但是apache配置文件不一样。

mamp 的apache配置文件:/Applications/MAMP/conf/apache/

mamp pro 的apache配置文件:/Library/Application Support/appsolute/MAMP PRO/conf (有apache、nginx、php5、php7的配置文件)

在聊坑二:

对于mamp pro所有的组件配置,修改完apache配置完才发现,手动是无效的,只能从面板中修改配置。具体解释:面板中有一些apache的配置项,这些如果手动修改,抱歉,无效,保存重启服务器时,优先读取面板中的配置,所以手动只能修改其他面板中没有的配置(从File\Edit Templat\ 进行配置文件入口选择),对于这点 ,真是够够的。

quality,Q_100

解决方案(正题)

在此处直接粘贴以下代码

!注意要根据版本的不同进行相应的修改

quality,Q_100

#伪静态

location / {

if (!-e $request_filename) {

rewrite ^(.*)$ /index.php?s=/$1 last;

break;

}

}

#解决后台访问不了的问题

location ~ ^(.+\.php)(.*)$ {

# try_files $uri =404;

#fastcgi_pass unix:/dev/shm/php-cgi.sock; #注意:不同系统,路由不一样

fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI_php5.6.40.sock; #注意:不同系统,路由不一样(留意当前使用的php版本)

fastcgi_index index.php;

include /Applications/MAMP/conf/nginx/fastcgi_params;

fastcgi_split_path_info ^(.+\.php)(\/?.*)$;

fastcgi_param PATH_INFO $fastcgi_path_info;

# 强制将某些非法地址交给 index.php 处理

set $new_fastcgi_script_name $fastcgi_script_name;

if (!-e $document_root$fastcgi_script_name) {

set $new_fastcgi_script_name "/index.php";

}

fastcgi_param SCRIPT_FILENAME $document_root$new_fastcgi_script_name;

fastcgi_param SCRIPT_NAME $new_fastcgi_script_name;

}

#跨域问题处理

add_header 'Access-Control-Allow-Origin' '*' always; #允许来自所有的访问地址

add_header 'Access-Control-Allow-Credentials' 'true' always; #允许来自所有的访问地址

add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, token, platform' always;

add_header 'Access-Control-Allow-Methods' 'GET,POST,PUT,DELETE,HEAD,OPTIONS' always; #允许来自所有的访问地址

if ($request_method = OPTIONS ) {

return 200;

}

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

#伪静态

location/{

if(!-e$request_filename){

rewrite^(.*)$/index.php?s=/$1last;

break;

}

}

#解决后台访问不了的问题

location~^(.+\.php)(.*)${

# try_files $uri =404;

#fastcgi_pass unix:/dev/shm/php-cgi.sock; #注意:不同系统,路由不一样

fastcgi_passunix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI_php5.6.40.sock;#注意:不同系统,路由不一样(留意当前使用的php版本)

fastcgi_indexindex.php;

include/Applications/MAMP/conf/nginx/fastcgi_params;

fastcgi_split_path_info^(.+\.php)(\/?.*)$;

fastcgi_paramPATH_INFO$fastcgi_path_info;

# 强制将某些非法地址交给 index.php 处理

set$new_fastcgi_script_name$fastcgi_script_name;

if(!-e$document_root$fastcgi_script_name){

set$new_fastcgi_script_name"/index.php";

}

fastcgi_paramSCRIPT_FILENAME$document_root$new_fastcgi_script_name;

fastcgi_paramSCRIPT_NAME$new_fastcgi_script_name;

}

#跨域问题处理

add_header'Access-Control-Allow-Origin''*'always;#允许来自所有的访问地址

add_header'Access-Control-Allow-Credentials''true'always;#允许来自所有的访问地址

add_header'Access-Control-Allow-Headers''Origin, X-Requested-With, Content-Type, Accept, token, platform'always;

add_header'Access-Control-Allow-Methods''GET,POST,PUT,DELETE,HEAD,OPTIONS'always;#允许来自所有的访问地址

if($request_method=OPTIONS){

return200;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值