Laravel5.0--学习教程之安装配置

 

window下安装composer和laravel

(1)安装composer:

1、在https://getcomposer.org/download/ 中下载 Composer-Setup.exe

具体的安装步骤,这里不再详述,可以点击以下链接查看:https://jingyan.baidu.com/article/4f34706ed04013e386b56d72.html

(2)安装laravel:

安装composer完成后,win+R >> cmd,调出命令行程序,通过cmd命令进入到你要创建laravel框架的目录

如果无法使用用Composer安装,很有可能是仓库访问不了,即被墙了。先更新Composer仓库源:

# 修改 composer 的全局配置文件(推荐方式) # 打开命令行窗口(windows用户)或控制台(Linux、Mac 用户)并执行如下命令:   composer config -g repo.packagist composer https://packagist.phpcomposer.com

接下来正式开始安装吧!

这里以Laravel 5.0 版本为例(PHP 版本 >= 5.4)。

列如,我的安装目录是laravel5,如图所示输入以下命令:

composer create-project laravel/laravel laravel5 5.0.22

 等待安装(需要5分钟左右):

Installing laravel/laravel (v5.0.22)   - Installing laravel/laravel (v5.0.22)     Downloading: 100%  Created project in learnlaravel5 Loading composer repositories with package information Installing dependencies (including require-dev) from lock file   - Installing jakub-onderka/php-console-color (0.1)     Downloading: 100%    - Installing vlucas/phpdotenv (v1.1.0)     Downloading: 100%    - Installing symfony/var-dumper (v2.6.4)     Downloading: 100%    - Installing symfony/translation (v2.6.4)     Downloading: 100%    - Installing symfony/security-core (v2.6.4)     Downloading: 100%    - Installing symfony/routing (v2.6.4)     Downloading: 100%    - Installing symfony/process (v2.6.4)     Downloading: 100%    - Installing symfony/http-foundation (v2.6.4)     Downloading: 100%    - Installing symfony/event-dispatcher (v2.6.4)     Downloading: 100%    - Installing psr/log (1.0.0)     Downloading: 100%  ...  Generating autoload files > php artisan clear-compiled > php artisan optimize Generating optimized class loader Compiling common classes > php -r "copy('.env.example', '.env');" > php artisan key:generate Application key [4FunRLeVWE0jc6QTs3h8vNbDnoa4Qi8Q] set successfully.

即为安装成功;

安装完便可以访问了:

http://localhost/laravel5/public/index.php

若要更改访问端口等,可以运行以下语句:

php -S localhost:8080 -t public

8080就是修改的端口号;

(3)在IIS下的配置

像刚才的步骤都安装完成后,在IIS下不一定能使用

IIS还需要,以下步骤:

<1>  给安装的Laravel5目录绑定IP地址,例如我绑定的127.0.1.6

<2>  在public目录下新建web.config文件,在IIS服务器下用该文件重写URL

代码如下:

<configuration>    <system.webServer>      <rewrite>        <rules>          <rule name="Imported Rule 1" stopProcessing="true">            <match url="^(.*)/$" ignoreCase="false" />            <conditions>              <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />           </conditions>            <action type="Redirect" redirectType="Permanent" url="/{R:1}" />          </rule>          <rule name="Imported Rule 2" stopProcessing="true">            <match url="^" ignoreCase="false" />            <conditions>              <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />             <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />           </conditions>            <action type="Rewrite" url="index.php" />          </rule>        </rules>      </rewrite>    </system.webServer>  </configuration>

最终IIS下就可以访问了

 

 联系我们

  • 邮箱:admin@admincms.top
  • 官方博客:blog.admincms.top
  • 官方微信公众号:huayuejishu
扫描二维码关注Joker.Liu微信公众号
TOP博客官方微信公众号二维码