一、使用宝塔安装环境:
php7.2
iis10.0
mysql5.5
安装完成后,web站点的目录为:D:/wwwroot
二、也可手动安装
1 安装php7.2
2 安装apache服务器
下载安装文件Welcome! - The Apache HTTP Server Project
解压到D:\BtSoft目录,
打开httpd.conf,本机的安装目录为D:\BtSoft\Apache24\conf
修改php.ini:
;TODO changed extension_dir = "ext"
extension_dir = "D:/BtSoft/php/72/ext"
;
;extension=curl
;extension=gd2
;extension=gettext
;extension=mbstring
;extension=mysqli
;extension=pdo_mysql
;extension=pdo_sqlite
;extension=sockets
配置如下:
Define SRVROOT "D:/BtSoft/Apache24" //当前 apache的安装目录
Listen 8889 //修改端口号
添加如下代码:
#TODO set serverName
ServerName localhost:80
# TODO enabled
Include conf/extra/httpd-vhosts.conf
#TODO AddLine
# php7 support
LoadModule php7_module D:/BtSoft/php/php7234/php7apache2_4.dll
AddType application/x-httpd-php .php .html .htm
#configure the path to php.ini
PHPIniDir D:/BtSoft/php/php7234
Cmd运行C:\Users\lzwjsb>httpd -t 运行结果:Syntax OK //测试配置文件是否合法
安装apache主服务
以管理员身份运行cmd ,
C:\WINDOWS\system32>httpd -k install -n Apache
Installing the 'Apache' service
The 'Apache' service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.
命令行启动net start/stop apache,也可以手动启动.
利用命令启动
httpd -k start: 不会提示详细的错误信息。
httpd -k start -n apache: 会提示详细的错误信息,其中的"apache"修改为你的Apache服务名,可以到计算机服务里找。
httpd -k restart -n apache: 重启。
net start apache: 利用Windows托管服务命令。
检查服务器是否启动正常http://127.0.0.1:8889
查看端口状态:
C:\Users\lzwjsb>netstat -aon | findstr "8889"
TCP 0.0.0.0:8889 0.0.0.0:0 LISTENING 50664
TCP [::]:8889 [::]:0 LISTENING 50664
布署tp5应用,在httpd.conf中修改:
#TODO changed serverWebRoot
#DocumentRoot "${SRVROOT}/htdocs"
#<Directory "${SRVROOT}/htdocs">
DocumentRoot "D:/wwwroot"
<Directory "D:/wwwroot">
3 安装iis服务器
安装略
配置:
控制面板--系统安全---管理工具
宝塔创建的web站点的默认路径为:C:\inetpub\wwwroot
4 安装nginx服务器
直接下载http://nginx.org/en/download.html
解压到指定目录,启动nginx,cmd -----start nginx.exe
nginx.exe -s stop //停止nginx
nginx.exe -s reload //重新加载nginx
nginx.exe -s quit //退出nginx
查看启动的ngixn进程
tasklist /fi "imagename eq nginx.exe"
配置文件,本机目录D:\software\nginx-1.21.3\conf
示例代码如下:
#TODO disable
error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;
location / {
#root html;
root D:/wwwroot;
index index.html index.htm index.php default.php default.htm default.html;
}
location ~ \.php$ {
root D:/wwwroot;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME D:/wwwroot/$fastcgi_script_name;
include fastcgi_params;
}
修改php.ini文件
enable_dl = On
cgi.force_redirect = 1\
fastcgi.impersonate = 1
cgi.rfc2616_headers = 1
date.timezone = Asia/Shanghai
启动php ,cmd到php安装目录,执行如下命令:
php-cgi.exe -b 127.0.0.1:9000 -c php.ini
停止php-cgi和nginx ,可以将如下代码制批处理文件:
@echo off
echo Stopping nginx...
taskkill /F /IM nginx.exe > nul
echo Stopping PHP FastCGI...
taskkill /F /IM php-cgi.exe > nul
Exit
配置完成后,浏览器测试http://localhost/tp5/public/
三 下载安装 thinkPhp框架
安装composer,在D:\BtSoft\composer(自已创建文件夹)
cmd进入该目录,
执行php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
该条命令下载composer-setup.php脚本,
执行 php composer-setup.php //执行安装过程
执行 php -r "unlink('composer-setup.php');" //删除安装角本
全局安装:
进行php 的安装目录D:\BtSoft\php\72,将composer.phar放到该目录,即与php.exe为同一级目录,然后在php安装目录下新建composer.bat文件,添加如下内容:
@php "%~dp0composer.phar" %*
然后进入命令行窗口执行:composer --version查看当前版本号
ThinkPhp的安装,可以通过composer进行安装,
如果是第一次安装composer create-project topthink/think=5.1.* tp5//安装目录
如果安装过,可以执行下面命令更新
也可以通过git进行安装,composer update topthink/framework
git的安装略
thinkPhp分为应有和核心两个库
应用项目:https://github.com/top-think/think
核心框架:https://github.com/top-think/framework
分别下载两个库:本机用的安装目录是D:\BtSoft\php
git clone https://github.com/top-think/think tp5//应用项目
出现如下错误 :
fatal: unable to access 'https://github.com/top-think/think/': OpenSSL SSL_read: Connection was reset, errno 10054
fatal: unable to access 'https://github.com/top-think/think/': OpenSSL SSL_connect: Connection was reset in connection to github.com:443
解决方法 : 在git bash 中执行如下命令
$ git config --global http.sslVerify "false"
也可以将http换成git
切换到tp5目录下,执行如下命令:
git clone https://github.com/top-think/framework thinkphp
============================================================================
四 简单布署应用
在宝塔的目录中使用tp创建一个简单项目,本机的应用目录为D:\wwwroot,uq
将下载好的tp5目录放到该目录下
本机使用的是iis服务器,在iis上创建网站,添加虚拟目录D:\wwwroot\tp5\public
在浏览器中访问http://localhost/public/
出现如下问题 :
1 使用iis配置web应用时,禁用匿名身份验证,开启基本信息验证
访问public目录下的 index.php时出现如下错误
Warning: require(D:\wwwroot\tp5\public/../vendor/autoload.php): failed to open stream: No such file or directory in D:\wwwroot\tp5\public\index.php on line 15
Warning: require(D:\wwwroot\tp5\public/../vendor/autoload.php): failed to open stream: No such file or directory in D:\wwwroot\tp5\public\index.php on line 15
Fatal error: require(): Failed opening required 'D:\wwwroot\tp5\public/../vendor/autoload.php' (include_path='.;C:\php\pear') in D:\wwwroot\tp5\public\index.php on line 15
解决办法:
D:\wwwroot\tp5\public/../vendor/autoload.php该 文件不存在,可使用composer 进行更新
在更新过程中,
[ErrorException]
proc_get_status() has been disabled for security reasons
2 在php的安装目录下,本机的是D:\BtSoft\php\72找到php.ini文件,将禁用的函数取消即可
; http://php.net/disable-functions disable removed putenv, proc_open, proc_get_status,
disable_functions = passthru,system,chroot,chgrp,chown,shell_exec,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,exec
然后执行更新命令:composer update
============================================================================
五 vs code
Vs code 下载安装略
VIM --- 喜欢用VIM操作的小伙伴可以加上这个,不要用amVIM(用得不爽,好多vim功能都没有)
Better Align --- 对齐用的,设置一下快捷键 Ctrl + Alt + =,对块自动等号对齐
Auto Close Tag 自动标签闭合
Auto Rename Tag 自动标签重命名
Code Outline 函数变量列表 (目前有点小问题,显示的函数列表是双份的)
ftp-simple FTP远程同步工具
HTML CSS Support CSS支持工具
HTML Snippets HTML小片段工具
IntelliSense for CSS class names CSS类名工具
JavaScript code snippets
JS-CSS-HTML Formatter
jshint js代码检查工具
MetaGO 类是easymotion ,可以用键盘快速移动的工具
npt Intellisense 其他软件需要这个辅助工具,(具体不是很清楚)
Path Intellisense 路径管理工具
PHP Debug
PHP Extension Pack PHP扩展包
PHP Intellisense PHP自动补全工具
PHP Intellisense -Crane PHP自动补全工具
Project Manager 多个项目之间切换的工具
Typing Installer 不是很清楚,但很有用
vscode-icons 给不同的文件类型添加图标
快捷键
可以通过 File -> Preference -> Settings中 vim.useCtrlKeys 选项设置为 false
Vs code中自定义文件注释和函数注释
Php 语法学习