1

vagrant/puppet を使用してテストマシンを構成しています。これを使用して apache の仮想ホストを構成していますが、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>",
    }
4

2 に答える 2

3

c2 a0(エラーメッセージ内)は、特殊文字「ノーブレークスペース」のUnicodeコードです。ここ

apacheはそれをまったく好まないようです。したがって、エディタで同じように見える場合でも、これらの改行しないスペースを取り除き、通常のスペースを使用する必要があります。

NotePad ++を使用して、パペットファイルを「ANSI」に変換するように依頼できます。これは、構成ファイルのより安全なエンコーディングです。

コンテンツを外部ファイルに移動するときに、知らないうちにそれをクリーンアップしたはずですが、外部ファイルを使用することは、たとえそれが機能したとしても、解決策ではありません。

于 2012-10-10T14:52:47.143 に答える
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は共有フォルダーにあります(パスはイメージ上にあります)

于 2012-10-02T12:44:48.660 に答える