我正在使用一个Vagrant / Puppet来配置我的TestMachine,我正在使用它来为Apache配置VirtualHost,但是当启动Apache时,我会出错,显然是奇怪的间隔或字符左右:

/apache2 start
 * Starting web server apache2                                                                                                                                                                                                                                            
Syntax error on line 4 of /etc/apache2/sites-enabled/my-ssl.localhost.conf:
Invalid command '\xc2\xa0\xc2\xa0ServerName', perhaps misspelled or defined by a module not included in the server configuration
Action 'start' failed.
.

我编写的清单文件要配置Virtualhost看起来像这个

file {'hostfile4':
      path    => '/etc/apache2/sites-available/my-ssl.localhost.conf',
      ensure  => present,
      content => "
<VirtualHost *:443>
  DocumentRoot '/coding/mysite/htdocs/'
  ServerName foa-ssl.localhost
  ServerAlias foa-ssl.localhost
  ErrorLog /var/log/apache2/error.log
  CustomLog /var/log/apache2/access.log combined
  RewriteLog /var/log/apache2/rewrite.log
  RewriteLogLevel 0
    <Directory '/coding/mysite/checkout/htdocs'>
        AllowOverride All
        Options All -Indexes
        Order allow,deny
        Allow from all
        php_admin_value short_open_tag Off
        AddType application/x-httpd-php .css .js
    </Directory>
    <Directory '/coding/mysite/app_new/htdocs'>
        AllowOverride All
        Options All -Indexes
        Order allow,deny
        Allow from all
        php_admin_value short_open_tag Off
        AddType application/x-httpd-php .css .js
    </Directory>
  <Directory '/coding/mysite/cgi-bin'>
    Options +ExecCGI
  </Directory>
  SSLEngine on
  SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
</VirtualHost>",
    }
.

有帮助吗?

解决方案

c2 a0(在错误消息中)是特殊字符“非破坏空间”,CF的Unicode代码。在这里

似乎Apache根本不喜欢。所以你必须摆脱那些不破坏的空间并使用普通的空格,即使它在编辑器中看起来也是如此。

您可以使用Notepad ++并要求它将傀儡文件转换为“ANSI”,这是一个更安全的编码,用于配置文件。

您必须在不知道的情况下将内容移动到外部文件时已清理,但使用外部文件不是解决方案,即使它运行。

其他提示

使用这个解决:

file { "/etc/apache2/sites-available/my-ssl.localhost.conf":
    mode => 440,
    owner => root,
    group => root,
    source => "/coding/puppetstuff/my-ssl.localhost.conf"
}
.

/coding/puppetstuff/foa -ssl.localhost.conf在共享文件夹中(路径在图像上)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top