简体   繁体   English

Puppet / Vagrant:损坏的apache虚拟主机内容

[英]Puppet/Vagrant: corrupted apache virtualhost content

I am using a vagrant/puppet to configure my testmachine, i am using it to configure the virtualhost for apache, but when starting apache i get an error, apparently for weird spacing or characters or so: 我正在使用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.

the manifest file that i wrote to configure the virtualhost looks like this 我为配置虚拟主机而编写的清单文件如下所示

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 (in the error message) is the unicode code for the special character "non breaking space", cf. c2 a0 (在错误消息中)是特殊字符“non break space”的unicode代码,参见 here . 在这里

It seems that apache doesn't like that at all. 似乎apache根本不喜欢这样。 So you must get rid of those non-breaking spaces and use normal ones, even if it looks the same in your editor. 因此,您必须摆脱那些不间断的空间并使用正常空间,即使它在编辑器中看起来相同。

You can use NotePad++ and ask it to convert your puppet files to "ANSI", which is a safer encoding for config files. 您可以使用NotePad ++并要求它将您的puppet文件转换为“ANSI”,这是一个更安全的配置文件编码。

You must have cleaned that without knowing it while moving the content to an external file, but using an external file is not the solution, even if it worked. 在将内容移动到外部文件时,您必须在不知情的情况下清除它,但使用外部文件不是解决方案,即使它有效。

solved it using this: 用这个解决了它:

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 is in a shared folder (path is on image) /coding/puppetstuff/foa-ssl.localhost.conf位于共享文件夹中(路径在图像上)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM