有没有办法通过本地网络服务器从批处理文件 运行 一个 PHP 站点?
Is there a way to run a PHP site from a batch file with a local webserver?
我正在尝试从 windows 上的批处理文件 运行 本地网站。
我正在编写一个项目,稍后想通过 xampp 在 USB 记忆棒上开始这个项目,运行 到我想要的任何地方。已经尝试将一些 shell 与 PHP
和 start
命令一起使用。但这不是 运行 以预期的方式进行....
C:\xampp\php\php D:\projects\project_x\index.php
和
start D:\projects\project_x\index.php
我期待我的网站....但是第一个命令只是把它放在我的命令行中......
第二个仅显示我在浏览器中的代码。显然没有 PHP... 那么如何通过 xampp 网络服务器获取 运行ning 然后在我的浏览器中调用它?
让您选择的网络服务器和便携式浏览器在您的闪存驱动器上运行。
批处理文件:
@REM Open php files in a portable browser in a portable web server with a win10 64-bit batch file
@echo off
setlocal enableextensions
%~d0\xampp\xampp_start.exe
rem if an instance of the browser is running the batch will not pause and the web server will be stopped.
taskkill /im GoogleChromePortable.exe> NUL 2>&1
"%~d0\GoogleChromePortable\GoogleChromePortable.exe" http://localhost/applications.html http://localhost/index.php
echo.
%~d0\xampp\xampp_stop.exe
exit
您不应使用任何不在您的闪存驱动器上的软件,但如果您这样做:
如果默认浏览器是IE11你只能打开一个页面/文件/标签。以下命令不会停止批处理文件,必须使用 pause 来防止 Web 服务器停止。
begin will not work
start http://localhost/applications.html http://localhost/index.php
start "" http://localhost/applications.html http://localhost/index.php
start "" /wait http://localhost/applications.html http://localhost/index.php
start "" "%ProgramFiles%\Internet Explorer\iexplore.exe" http://localhost/applications.html http://localhost/index.php
"%ProgramFiles%\Internet Explorer\iexplore.exe" %22http://localhost/index.php%22%20%22http://localhost/applications.html%22
"%ProgramFiles%\Internet Explorer\iexplore.exe" http://localhost/index.php%20http://localhost/applications.html
"%ProgramFiles%\Internet Explorer\iexplore.exe" http://localhost/index.php http://localhost/applications.html
end will not work
多亏了上面那个家伙,我得到了正确的答案 :D 这是他的代码和我已经尝试过的代码的混合体。
而不是尝试通过网络服务器调用它,我只需要通过浏览器调用 url。
表示:
start http://localhost/project_x/index.php
我正在尝试从 windows 上的批处理文件 运行 本地网站。
我正在编写一个项目,稍后想通过 xampp 在 USB 记忆棒上开始这个项目,运行 到我想要的任何地方。已经尝试将一些 shell 与 PHP
和 start
命令一起使用。但这不是 运行 以预期的方式进行....
C:\xampp\php\php D:\projects\project_x\index.php
和
start D:\projects\project_x\index.php
我期待我的网站....但是第一个命令只是把它放在我的命令行中......
第二个仅显示我在浏览器中的代码。显然没有 PHP... 那么如何通过 xampp 网络服务器获取 运行ning 然后在我的浏览器中调用它?
让您选择的网络服务器和便携式浏览器在您的闪存驱动器上运行。
批处理文件:
@REM Open php files in a portable browser in a portable web server with a win10 64-bit batch file
@echo off
setlocal enableextensions
%~d0\xampp\xampp_start.exe
rem if an instance of the browser is running the batch will not pause and the web server will be stopped.
taskkill /im GoogleChromePortable.exe> NUL 2>&1
"%~d0\GoogleChromePortable\GoogleChromePortable.exe" http://localhost/applications.html http://localhost/index.php
echo.
%~d0\xampp\xampp_stop.exe
exit
您不应使用任何不在您的闪存驱动器上的软件,但如果您这样做:
如果默认浏览器是IE11你只能打开一个页面/文件/标签。以下命令不会停止批处理文件,必须使用 pause 来防止 Web 服务器停止。
begin will not work
start http://localhost/applications.html http://localhost/index.php
start "" http://localhost/applications.html http://localhost/index.php
start "" /wait http://localhost/applications.html http://localhost/index.php
start "" "%ProgramFiles%\Internet Explorer\iexplore.exe" http://localhost/applications.html http://localhost/index.php
"%ProgramFiles%\Internet Explorer\iexplore.exe" %22http://localhost/index.php%22%20%22http://localhost/applications.html%22
"%ProgramFiles%\Internet Explorer\iexplore.exe" http://localhost/index.php%20http://localhost/applications.html
"%ProgramFiles%\Internet Explorer\iexplore.exe" http://localhost/index.php http://localhost/applications.html
end will not work
多亏了上面那个家伙,我得到了正确的答案 :D 这是他的代码和我已经尝试过的代码的混合体。
而不是尝试通过网络服务器调用它,我只需要通过浏览器调用 url。
表示:
start http://localhost/project_x/index.php