さくらVPSで開発環境構築 〜男の価値、市場価値〜 2発目
さくらVPSでの開発環境構築 2発目。
引き続き、ドットインストールにそって。
- #11 Webサーバーの設定をしよう
→apacheのインストール
会社ではソースからインストールしていたが、今回はyumでインストール。
httpdを自動起動に。
httpdの設定変更(TODO 意味をちゃんと調べよう。。。週末に。。。)
設定に間違いないか確認
httpd起動
yum install httpd chkconfig httpd on vi /etc/httpd/conf/httpd.conf ServerTokens Prod ServerSignature Off Options -Indexes FollowSymLinks service httpd configtest service httpd start
- #12 Webページを設定してみよう
→ドキュメントルートにファイルを置いてアパッチの起動確認
作業ユーザ権限にして、ファイル作成
ブラウザで確認
chown -R user:group /var/www/html vi /var/www/html/index.html
- #13 VirtualHostの設定をしよう (1)
→virtualhostを設定して、複数ドメインを運用する。
既存とは別のドキュメントルートに設定するディレクトリ作成。作業ユーザに権限つける
/etc/httpd/conf.d/以下にvirtualhostの設定ファイル作成。/etc/httpd/conf.d/以下に設定ファイルを置けば必ず読まれる。
virtualhostを有効にする。
mkdir -p /var/www/dev.example.com/public_html chown -R user:group /var/www/dev.example.com vi /etc/httpd/conf.d/dev.example.com.conf <VirtualHost *:80> ServerName dev.example.com DocumentRoot "/var/www/dev.example.com/public_html" DirectoryIndex index.html index.php ErrorLog /var/log/httpd/dev.example.com_error_log CustomLog /var/log/httpd/dev.example.com_access_log combined AddDefaultCharset UTF-8 <Directory "/var/www/dev.example.com/public_html"> AllowOverride All </Directory> </VirtualHost> vi /etc/httpd/conf/httpd.conf NameVirtualHost *:80
- #14 VirtualHostの設定をしよう (2)
→httpdの設定に間違いないか確認
httpdリスタート
virtualhostで設定したドキュメントルートにファイルをつくる
/etc/hostsを編集し、設定したドメインの際、VPSに向けるよう設定
ブラウザで確認
service httpd configtest service httpd restart vi /var/www/dev.example.com/public_html/index.html vi /etc/hosts IP.ADDRESS dev.example.com
今日はここまで。
会社ではvirtualhostの設定は、includeさせて読ませていたはず。
いろいろやり方あるのですね。。。
感謝致します。