パペット/浮浪者:Apache仮想ホストのコンテンツが破損している
質問
私は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>",
}
解決
c2 a0
(エラー メッセージ内の) は、特殊文字「非改行スペース」の Unicode コードです。 ここ.
Apache はそれをまったく好まないようです。したがって、たとえエディタ内で同じように見えても、これらの非改行スペースを削除し、通常のスペースを使用する必要があります。
NotePad++ を使用して、Puppet ファイルを設定ファイルのより安全なエンコードである「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は共有フォルダ内にあります(パスが画像上にあります)
所属していません StackOverflow