我创建了一个 python(我使用 2.4)脚本来自动在 httpd.conf 中创建一个虚拟主机。但是当我运行它时,它给出了以下错误:
Traceback (most recent call last):
File "ApaPy2.py", line 2, in ?
from io import open
ImportError: No module named io
这是我的脚本
import os
from io import open
project = raw_input(u'Enter the name of project ')
domain = raw_input (u'Enter the domain ')
docroot = raw_input(u'Enter root folder ')
virtualhost=u"""
<VirtualHost *:80>
ServerAdmin abhishek.verma@laitkor.com
DocumentRoot /""" +docroot+ u"""/""" +project+ u"""
ServerName """ +project+ u""".""" +domain+ u""".com
ErrorLog logs/""" +project+ u""".com-error_log
CustomLog logs/""" +project+ u""".com-access_log common
</VirtualHost>"""
f = open(u'/etc/httpd/conf/httpd.conf', u'a')
f.write(virtualhost)
f.close()