MAC自定义域名访问nginx服务器的thinkphp项目

来源:互联网 发布:免费的约会软件 编辑:程序博客网 时间:2024/06/14 02:06

1.首先,我们编辑mac系统的hosts文件:

sudo vim /etc/hosts

在里面增加一个自定义域名,比如:192.168.1.13(本机ubuntu服务器的IP)    www.ubuntublog.com


2.我nginx安装在 /usr/local/nginx . 然后我们修改配置文件:/usr/local/nginx/conf/nginx.conf 。  部分配置文件如下:

这是一个最简单的配置,更多需求配置可以查看nginx官方文档:

 server {        listen       80;        server_name  localhost,www.ubuntublog.com;        #charset koi8-r;        #access_log  logs/host.access.log  main;        root   /usr/local/nginx/html/blogforit/;        location / {                index  index.php;                //我的项目隐藏了index.php,所以下面需要做一个rewrite                if (!-e $request_filename) {                        rewrite ^(.*)$ /index.php?s=$1 last;                }                break;        }        #error_page  404              /404.html;        # redirect server error pages to the static page /50x.html        #        error_page   500 502 503 504  /50x.html;        location = /50x.html {            root   html;        }        # proxy the PHP scripts to Apache listening on 127.0.0.1:80        #        #location ~ \.php$ {        #    proxy_pass   http://127.0.0.1;        #}        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000        location ~ \.php$ {            fastcgi_pass   127.0.0.1:9000;            fastcgi_index  index.php;            fastcgi_split_path_info ^(.+\.php)(/.*)$;            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;            fastcgi_param PATH_INFO $fastcgi_path_info;            include        /usr/local/nginx/conf/fastcgi_params;        }        # deny access to .htaccess files, if Apache's document root        # concurs with nginx's one        #        #location ~ /\.ht {        #    deny  all;        #}    }


原创粉丝点击