Heim  >  Artikel  >  Backend-Entwicklung  >  nginx - mac 下搭建php环境出错?

nginx - mac 下搭建php环境出错?

WBOY
WBOYOriginal
2016-06-06 20:15:191081Durchsuche

我的nginx 和php-fpm 都有启动。但是仍然报错,google后仍然无果,万能的社区,求助啊!
查看信息
nginx - mac 下搭建php环境出错?

配置文件如下:
nginx - mac 下搭建php环境出错?

报错信息如下:
nginx - mac 下搭建php环境出错?

回复内容:

我的nginx 和php-fpm 都有启动。但是仍然报错,google后仍然无果,万能的社区,求助啊!
查看信息
nginx - mac 下搭建php环境出错?

配置文件如下:
nginx - mac 下搭建php环境出错?

报错信息如下:
nginx - mac 下搭建php环境出错?

建议你每个项目定一个域名 一个目录

<code>sudo vi /etc/hosts

//添加
127.0.0.1    demo.dev</code>

打开 /usr/local/etc/nginx/servers

然后新建一个配置文件 例如 demo.conf 内容如下:

<code>server {
    listen 80;
    server_name demo.dev; #域名
    root /Users/程序目录; #程序目录
    index index.html index.php;
    
    # 伪静态
    #location / {
    #    try_files $uri $uri/ /index.php$is_args$query_string;
    #}

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}</code>

重启nginx,浏览器访问demo.dev 大功告成

<code>fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;</code>

试试。

<code>server {
    listen 80;
    server_name localhost;

    root /path; #注意这里配置为你的网站根目录
    index index.html index.htm index.php;

    location / {
        #try_files $uri $uri/ /index.php$is_args$args;
    }
    
    location ~ \.php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
    }
}</code>

建议还是vagrant在mac上面架设lnmp环境. 百度下有很多的解决方案

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn