用 php 更改虚拟主机文件


change the VirtualHost file with php

我已经在 Debian 服务器上安装了 apache,并设置了一些示例站点,但我想制作一个计费系统,并在订单完成后自动更新 Virtualhost 详细信息,如 ServerAdmin、ServerName、ServerAlias。我的问题是:是否可以使用 PHP 更新它们?

站点

可用目录中的示例站点:

<VirtualHost *:80>
ServerAdmin info@example.org
ServerName example.org
ServerAlias www.example.org
DocumentRoot /srv/www/example.org/public_html/
ErrorLog /srv/www/example.org/logs/error.log
CustomLog /srv/www/example.org/logs/access.log combined
</VirtualHost>

有了适当的写入权限,你当然可以做到。在编写新 apache 后重新启动 apache 之前,您似乎确实需要一些严重偏执的验证和测试,因为其中的格式错误的指令可以快速达到 500。

编辑:我不确定我是否建议首先为您的脚本提供"适当的"写入权限。