【キーワード】
apache2,マルチドメイン,Virtual Host
【目的】
Apach2で独自ドメインを運用する。
mod_rewirteモジュールの有効化を実施する。
【ドメイン】
hogehoge.com(便宜上ドメインは各自の環境で読み替える)
【アプローチ】
1:Apache2の設定ファイルを新規作成(hogehoge.com.confの作成)
┣【ファイルの作成】を参照
┗ <修正前データ(元データ)>を参照し<修正後データ>に
2:公開用のディレクトリを作成する
$ sudo mkdir -p /var/www/vhost/sesiri.club/html
$ sudo chown -R www-data:www-data /var/www/vhost/
3:a2ensiteコマンドで、設定を登録する
$ sudo a2ensite hogehoge.com.conf
4:Apache2、再読込処理
$ sudo service apache2 reload
<ここからmod_rewriteの設定>
5:mod_rewriteが利用可能になっているかを確認する
$ cat /etc/apache2/mods-available/rewrite.load
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
6:a2enmodコマンドでmod_rewriteを実行する
$ sudo a2enmod rewrite
7:Apache2の再起動を実行
$ sudo service apache2 restart
【バージョンの確認】
<Apach2のバージョン>
$ apachectl -v
Server version: Apache/2.4.18 (Ubuntu)
Server built: 2016-07-14T12:32:26
【ファイルの作成】
$ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/hogehoge.com.conf
<修正前データ(元データ)>
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
<修正後データ>
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin info@hogehoge.com
ServerName hogehoge.com
DocumentRoot /var/www/vhost/hogehoge.com/html
Options -Indexes +FollowSymLinks
<Directory "/var/www/vhost/hogehoge.com/html">
AllowOverride All
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
※設定したconfファイルの文法をチェックするコマンド
$ apachectl configtest
このブログを検索
ラベル
- Apache2 (1)
- bitFlyer (1)
- BTC (1)
- BTCFX (1)
- CakePHP3 (1)
- CCXT (1)
- CentOS (1)
- C言語 (1)
- iPad (1)
- Javaのイロハ (9)
- Java言語 (1)
- Linux (8)
- mailman (1)
- Mecab (1)
- MySQL (1)
- Perl (1)
- PHP (2)
- Redmine (1)
- Shell Script (1)
- Ubuntu (2)
- VB.NET (5)
- Windows (1)
- yum update (1)
- yum使い方 (1)
- エディタ・ページャ (1)
- 開発環境 (1)
- 資格 (1)
- 自動売買 (1)
- 上流工程 (1)
-
マニュアル更新しました 2011年5月6日 => マニュアルダウンロード: 「 ここ 」 なにかあればコメントください。 <この記事と他のWebサイトの比較> 検証日:2011年4月29日 A . Windows上(Cygwin上)でiPh...
-
AWSのインスタンスとELBを利用した際に発生するToo Many Redirectが発生するときの対策↓ https://aws.amazon.com/jp/premiumsupport/knowledge-center/redirect-http-https-elb/ ...