linux/windows+nginx+laravel

当用惯了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;

#    }

#}

}


。。。待续。。。。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 1.ngnix介绍 ngnix www服务软件 俄罗斯人开发 开源 性能很高 本身是一款静态WWW软件 静态小文件...
    逗比punk阅读 2,292评论 1 6
  • Nginx简介 解决基于进程模型产生的C10K问题,请求时即使无状态连接如web服务都无法达到并发响应量级一万的现...
    魏镇坪阅读 2,272评论 0 9
  • 《老男孩Linux运维》笔记 隐藏Nginx软件版本号 一般来说,软件的漏洞都和版本有关。因此要尽量隐藏对访问用户...
    Zhang21阅读 3,970评论 0 28
  • 你是个好女孩,但你蠢啊 傻瓜是恋人之间偶尔会拿来称呼的爱称,但并不代表你做个可爱的傻白甜就能俘获男神。 我说的傻白...
    三分热血少女阿怪阅读 686评论 0 2
  • 早上好#易效能 # 蒋小园 2017/07/18(243/300) 【不忘初心,坚持始终】 健康:作息《昨晚今早》...
    圆圆jXY阅读 216评论 0 0

友情链接更多精彩内容