PHP   发布时间:2022-04-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了php-使用Powershell为Wampserver创建虚拟主机大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

我正在尝试使用Powershell脚本创建虚拟主机.它工作正常,但是我在编码方面遇到麻烦.我已经尝试了所有-encoding开关值,但没有运气.

这是我的剧本

$hostName = $args[0];
if ($args -eq $null -or $args.Length -eq 0)
{
    "No arguments. Supply the virtual host name as the first argument."
    exit
}
if (!(Test-Path -path D:\wamp\$hostName))
{
    $indexText = "<?PHP echo `"<h1>Holder for $hostName</h1>`";"
    New-Item D:\wamp\$hostName -type directory
    New-Item D:\wamp\$hostName\index.PHP -type file
    Out-File -FilePath D:\wamp\$hostName\index.PHP -InputObject $indexText -Encoding UTF8
}
$hosts = Get-Content C:\Windows\System32\drivers\etc\hosts
$hosts = $hosts + "127.0.0.1 $hostName.localhost"
Out-File -FilePath C:\Windows\System32\drivers\etc\hosts -InputObject $hosts
$conf = Get-Content "C:\Program Files (x86)\wamp\bin\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf"
$conf = $conf + "<VirtualHost *:80>"
$conf = $conf + "    DocumentRoot `"D:/wamp/$hostName`""
$conf = $conf + "    ServerName $hostName.localhost"
$conf = $conf + "    ErrorLog `"logs/$hostName.localhost-error.log`""
$conf = $conf + "    CustomLog `"logs/$hostName.localhost-access.log`" common"
$conf = $conf + "</VirtualHost>"
Out-File -FilePath "C:\Program Files (x86)\wamp\bin\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf" -InputObject $conf -Encoding ascii
Write-Host "Restart wamp server to effect changes"

有没有人设法使它可靠地工作,或者我是这里的入门者?我总是可以改用PHP

大佬总结

以上是大佬教程为你收集整理的php-使用Powershell为Wampserver创建虚拟主机全部内容,希望文章能够帮你解决php-使用Powershell为Wampserver创建虚拟主机所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: