2012-10-02 27 views
1

我正在使用vagrant/puppet來配置我的testmachine,我使用它來爲apache配置虛擬主機,但是當啓動apache時,我得到一個錯誤,顯然對於奇怪的間距或字符或所以:Puppet/Vagrant:損壞的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. 

清單文件,我寫來配置虛擬主機看起來像這樣

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>", 
    } 

回答

2

c2 a0(錯誤消息)是特殊字符「不換行空格」 Unicode碼,參見here

看來,Apache不喜歡這一點。所以你必須擺脫那些不間斷的空間並使用普通的空間,即使它在你的編輯器中看起來一樣。

您可以使用NotePad ++,並要求它將您的木偶文件轉換爲「ANSI」,這是對配置文件的更安全的編碼。

將內容移動到外部文件時,您必須清除該內容,但即使該內容正常工作,使用外部文件也不是解決方案。

0

解決它使用這樣的:

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是在共享文件夾(路徑是使圖像)