LoginSignup
0
1

More than 5 years have passed since last update.

VPS 借りたので② Web サーバー設定などメモ

Posted at

前回の続きです。

今回もドットインストール見ながら調べたメモ。

  • apache インストール&設定

  • サーバーにファイルを置く

    • ファイルを置く場所
      /etc/httpd/conf/httpd.conf
      の DocumentRoot に書いてある。
      デフォだと /var/www/html
    • DocumentRoot の権限設定
      # chown -R hoge:hoge /var/www/html
      chown はファイルやディレクトリの所有者を変更するコマンド。所属グループの変更もできる。変更を行えるのは、そのファイルの所有者または管理者だけ。
      chown [-cfhvR] [ユーザー]:[グループ] ファイル
      -R はディレクトリとその中のファイルを再帰的に変更する。
    • FTPクライアント設定
      クライアント次第だけれども、色々パラメータ入れる。
      ちなみに自分は transmitでSFTPで接続してます。
  • VirtualHost の設定

    • ディレクトリを作る(dev.example.com っていうサブドメイン想定)
      # mkdir -p /var/www/dev.example.com/public_html
      -p (parents) は、サブディレクトリを含んだディレクトリまで一気に作成する。
    • ディレクトリの権限設定
      # chown -R hoge:hoge /var/www/dev.example.com
    • VirtuwlHost の設定ファイル作成
      # vim /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>

※2015/03/22 追記

virtualhost の設定ファイル名は、特にドメイン名と一致させる必要がないので、サブドメを複数運営する場合などは、virtualhost.conf みたいなファイル名にして、全部この中に書いちゃった方が楽ということが判明。

ちなみに、メインのドメインの設定もちゃんとやっとかなくてはいけない。

この場合はexample.com

  • Apache の設定変更

    # vim /etc/httpd/conf/httpd.conf

    ファイル内の "NameVirtualHost *:80" のところのコメントアウトを外す。

  • あとはDNSサーバーでドメインとIP登録。

以上!

0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1