环境要求

  • PHP >= 7.0.0
  • PHP OpenSSL 扩展
  • PHP PDO 扩展
  • PHP Mbstring 扩展
  • PHP Tokenizer 扩展
  • PHP XML 扩展

通过 Laravel 安装器进行安装

首先,使用 Composer 下载 Laravel 安装程序:

composer global require "laravel/installer"

确保 $HOME/.composer/vendor/bin 目录(或你的操作系统的等效目录)已经放在你的环境变量 $PATH 中,以便系统可以找到 laravel 的可执行文件。

安装之后, laravel new 命令会在你指定的目录中创建一个新的 Laravel 项目。例如,laravel new blog 命令会创建一个名为 blog 的目录,其中包含所有已经安装好的 Laravel 的依赖项:

laravel new blog

通过 Composer 进行安装

还可以通过在终端中运行 create-project 命令来安装 Laravel:

composer create-project --prefer-dist laravel/laravel blog "5.5.*"

本地开发服务器

如果你在本地安装了 PHP,并且想使用 PHP 内置的开发服务器来为你的应用程序提供服务,那就使用 Artisan 命令serve。这个命令会在 http://localhost:8000 上启动开发服务器:

php artisan serve

Web 服务器配置

Apache

Laravel 使用 public/.htaccess 文件来为前端控制器提供隐藏了 index.php 的优雅链接。如果你的 Laravel 使用了 Apache 作为服务容器,请务必启用 mod_rewrite模块,让服务器能够支持 .htaccess 文件的解析。

如果 Laravel 附带的 .htaccess 文件不起作用,就尝试用下面的方法代替:

Options +FollowSymLinks
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Nginx

如果你使用的是 Nginx,在你的站点配置中加入以下内容,它将会将所有请求都引导到 index.php 前端控制器:

location / {
try_files $uri $uri/ /index.php?$query_string;
}

可以直接使用以下配置:

server {
listen ;
server_name example.com;
root /example.com/public; add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff"; index index.html index.htm index.php; charset utf-; location / {
try_files $uri $uri/ /index.php?$query_string;
} location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; } error_page /index.php; location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
} location ~ /\.(?!well-known).* {
deny all;
}
}

最新文章

  1. tp5 中 model 的修改器
  2. javascript-抽象工厂模式
  3. ON、WHERE、HAVING的区别
  4. HTML第四天学习笔记
  5. [gradle] is applicable for argument types
  6. ftp 匿名访问设置
  7. 状态开关按钮(ToggleButton)及按钮(Swich)的使用
  8. linux cat命令的<<EOF
  9. 【Java基础】Java类的加载和对象创建流程的详细分析
  10. 《你必须掌握的Entity Framework 6.x与Core 2.0》书籍出版
  11. T5大牛带你解析:如何实现分布式技术
  12. JavaScript Array some() 方法
  13. Webpack与其他打包工具的区别
  14. Struts2学习(五)———— s标签和国际化
  15. ros python 重置位置
  16. Mysql两个time类型计算时间相减
  17. MyEclipse 10、9、8 添加jadClipse反编译插件
  18. rpm 卸载
  19. D3——Updates, Transitions, and Motion
  20. 利用cross-entropy cost代替quadratic cost来获得更好的收敛

热门文章

  1. 报错Connection refused: connect
  2. ORA-39257: Data cannot be remapped for more than 10 columns.
  3. Fetch方法封装、业务实践
  4. JVM类加载机制小结
  5. [POJ3613] Cow Relays(Floyd+矩阵快速幂)
  6. True Liars POJ - 1417
  7. Beautiful Soup 4 方法便捷查询
  8. 机器学习实战基础(九):sklearn中的数据预处理和特征工程(二) 数据预处理 Preprocessing & Impute 之 数据无量纲化
  9. SQLAlchemy(二):SQLAlchemy对数据的增删改查操作、属性常用数据类型详解
  10. python 之 编码