Onga inc

subtitle

VirtualHostの設定

VirtualHostの設定を解説します。

この例では、
example.com
にアクセスしたら、

/var/www/example.com/
フォルダにアクセスするように設定するように設定します。

.confファイルの追加

`
//confファイルの追加
//conf.d/配下の.confファイルは起動時に必ず読み込まれます。
vim /etc/httpd/conf.d/example.com.conf
`

VirtualHostの設定

以下サンプルの記述になります。

<VirtualHost *:80>
ServerName example.com
DocumentRoot "/var/www/example.com"
DirectoryIndex index.html index.php
ErrorLog /var/log/httpd/example.com_error_log
CustomLog /var/log/httpd/example.com_access_log combined
AddDefaultCharset UTF-8
<Directory "/var/www/example.com">
AllowOverride All
</Directory>
</VirtualHost>

httpd.confの編集

`

//まずはバックアップを作成しましょう。
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf_org

//編集
vim /etc/httpd/conf/httpd.conf

//コメントアウトを外し、VirtualHostの設定の設定を有効にします。
NameVirtualHost *:80
`

httpd.confの書式確認

`
service httpd configtest
`

webサーバーの再起動

`
service httpd restart
`

Onga

A designer, developer and entrepreneur. Spends his time travelling the world with a bag of kites. Likes journalism and publishing platforms.

Comments