thinkphp学习01-thinkphp6安装

thinkphp官网
thinkphp文档

准备

安装php
安装composer

创建项目

切换到目录下,新建项目,通过composer创建

composer create-project topthink/think tp6

thinkphp学习01-thinkphp6安装_第1张图片
thinkphp学习01-thinkphp6安装_第2张图片
thinkphp学习01-thinkphp6安装_第3张图片

启动

命令行启动

进入到tp6文件夹,执行启动命令

php think run

thinkphp学习01-thinkphp6安装_第4张图片

访问localhost:8000
thinkphp学习01-thinkphp6安装_第5张图片
能启动起来说明thinkphp安装成功

iis启动

参考前面的文档将iis的配置配置好之后需要安装urlrewriter插件,插件下载地址
下载完成之后安装即可,安装完成之后有下面的模块就说明插件安装成功。
thinkphp学习01-thinkphp6安装_第6张图片

新建的网站一定要指定public目录,不要指定上一层
thinkphp学习01-thinkphp6安装_第7张图片

修改web.config


<configuration>
	<system.webServer>
		<handlers>
			
			<add name="php" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="E:\PHP\php-7.4.30-Win32-vc15-x64\php-cgi.exe" resourceType="File" requireAccess="Script" />
		handlers>
		<defaultDocument>
			<files>
				<add value="index.php" />
			files>
		defaultDocument>
		<httpErrors errorMode="Detailed" />
		
		<rewrite>
			<rules>
				<rule name="OrgPage" stopProcessing="true">
					<match url="^(.*)$" />
					<conditions logicalGrouping="MatchAll">
						<add input="{HTTP_HOST}" pattern="^(.*)$" />
						<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
						<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
					conditions>
					<action type="Rewrite" url="index.php/{R:1}" />
				rule>
			rules>
		rewrite>
	system.webServer>
configuration>

web.config也是在public目录下
thinkphp学习01-thinkphp6安装_第8张图片
这样的话通过iis直接访问也是可以的,后面就可以愉快的写代码了

总结

  1. 直接使用命令行启动适合开发模式,使用iis配置适合服务器上线使用

你可能感兴趣的:(php,学习)