如不知道怎么安装IIS,请看https://blog.csdn.net/YanWenGuang123/article/details/124250544,里面有安装IIS方法。
IIS下载链接:https://pan.baidu.com/s/1qEJe3ESXbf-eoqGnjyFFuQ 提取码:67mp
一、安装laravel
PHP >= 7.1
Laravel 5.5.0 ~ 8.*
开始安装
如果安装过程中出现 composer 下载过慢或安装失败的情况,请运行命令 composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
把 composer 镜像更换为阿里云镜像。
composer create-project --prefer-dist laravel/laravel 项目名称
在IIS管理器中添加并配置站点,配置成功后 public目录下会生成一个web.config文件,该文件相当于Apache中的 .htaccess文件
web.config 中内容如下:
<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>
PS:我这原先环境没有不到php7.1,在php官网中下载php7.4的包,配置php.ini
在当前网站下->处理程序映射,添加php7.4映射
添加成功后,在web.config文件中 rewrite
下面会自动添加
<handlers>
<add name="php7.4" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="D:phpStudy4IISphp-7.4.29-ntsphp-cgi.exe" resourceType="File" />
</handlers>
在访问url过程中,如报500错误,检查IIS中是否有url重写模块。
url重写模块下载链接:https://pan.baidu.com/s/1ZSgG55T4RLyqbJtsVNJizg 提取码:y087
安装后即可访问。
PS:在服务器建站是,少VC运行库,下载安装即可。
链接:http://soft.360.cn/static/baoku/info_7_0/softinfo_104698064.html