linux/windows+nginx+laravel

2017-03-29  本文已影响0人  Linux社区

当用惯了apache突然转轨到nginx上,真是有些不习惯,不管怎么说,鉴于现在很多公司都用这款服务器的情况下,我今天把我的坑展现给大家。

1.当配置laravel+nginx的时候一定要注意:root(也就是根目录的值一定要是public所在的位置

2.经过我的试验,暂时在我这台电脑上,windows下root的值用相对路径较好   linux反之,当然这可能也不是硬性要求。

3.nginx虽说也是模块化开发,但不像apache那样将一样面面具到,有一些简单的功能需要自己手写,例如url重写匹配

暂时只给出Centos+nginx+laravel的配置(nginx)的,如果经过大家试验,发现新的规律,也请回复我哟

#user  nobody;

worker_processes  1;

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {

worker_connections  1024;

}

http {

include      mime.types;

default_type  application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

#                  '$status $body_bytes_sent "$http_referer" '

#                  '"$http_user_agent" "$http_x_forwarded_for"';

#access_log  logs/access.log  main;

sendfile        on;

#tcp_nopush    on;

#keepalive_timeout  0;

keepalive_timeout  65;

#gzip  on;

server {

listen      80;

server_name  localhost;

root /usr/local/nginx/html/test/public;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location @rewrite {

#root  html;

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

}

location / {

#root  html;

index  index.php index.html index.htm;

try_files $uri $uri/ /index.php?$query_string;

}

#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$ {

#root          html;

fastcgi_pass  127.0.0.1:9000;

fastcgi_index  index.php;

include /usr/local/nginx/conf/fastcgi_params;

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

fastcgi_param PATH_INFO  $fastcgi_path_info;

fastcgi_param PATH_TRANSLATED  $document_root$fastcgi_path_info;

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

include        fastcgi_params;

}

# deny access to .htaccess files, if Apache's document root

# concurs with nginx's one

#

#location ~ /\.ht {

#    deny  all;

#}

}

# another virtual host using mix of IP-, name-, and port-based configuration

#

#server {

#    listen      8000;

#    listen      somename:8080;

#    server_name  somename  alias  another.alias;

#    location / {

#        root  html;

#        index  index.html index.htm;

#    }

#}

# HTTPS server

#

#server {

#    listen      443 ssl;

#    server_name  localhost;

#    ssl_certificate      cert.pem;

#    ssl_certificate_key  cert.key;

#    ssl_session_cache    shared:SSL:1m;

#    ssl_session_timeout  5m;

#    ssl_ciphers  HIGH:!aNULL:!MD5;

#    ssl_prefer_server_ciphers  on;

#    location / {

#        root  html;

#        index  index.html index.htm;

#    }

#}

}

。。。待续。。。。

上一篇 下一篇

猜你喜欢

热点阅读