Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Puppet/Vagrant:损坏的apache virtualhost内容_Apache_Puppet_Vagrant - Fatal编程技术网

Puppet/Vagrant:损坏的apache virtualhost内容

Puppet/Vagrant:损坏的apache virtualhost内容,apache,puppet,vagrant,Apache,Puppet,Vagrant,我使用一个vagrant/puppet来配置我的测试机,我使用它来配置apache的virtualhost,但是在启动apache时,我得到了一个错误,显然是因为奇怪的空格或字符之类的原因: /apache2 start * Starting web server apache2

我使用一个vagrant/puppet来配置我的测试机,我使用它来配置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>",
    }
文件{'hostfile4':
path=>'/etc/apache2/sites available/my ssl.localhost.conf',
确保=>存在,
内容=>”
DocumentRoot'/coding/mysite/htdocs/'
ServerName foa-ssl.localhost
ServerAlias foa-ssl.localhost
ErrorLog/var/log/apache2/error.log
CustomLog/var/log/apache2/access.log组合
RewriteLog/var/log/apache2/rewrite.log
重写日志级别0
    
允许超越所有
选项所有-索引
命令允许,拒绝
通融
php\u管理\u值短\u打开\u标记关闭
AddType应用程序/x-httpd-php.css.js
    
    
允许超越所有
选项所有-索引
命令允许,拒绝
通融
php\u管理\u值短\u打开\u标记关闭
AddType应用程序/x-httpd-php.css.js
    
  
选项+执行CGI
  
斯伦金安
SSLCertificateFile/etc/ssl/certs/ssl-cert-snakeoil.pem
",
}
使用以下方法解决了此问题:

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位于共享文件夹中(路径位于图像上)

c2 a0
(在错误消息中)是特殊字符“不间断空格”的unicode代码,参见

看来apache根本不喜欢这样。因此,您必须去掉那些不间断的空格,并使用普通空格,即使它在编辑器中看起来是一样的

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

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