1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

DebianのlocalでVirtualHost使うときのメモ

Posted at

毎回記憶も物理メモも吹き飛んでるので、メモです。

雑に

  1. /etc/apache2/sites-available にconfを書く
  2. a2ensiteする
  3. /etc/hosts にServerName足す
  4. apache restart
  5. ファイルのパーミッション修正

具体的に

http://local.test にアクセスしたとき、
/var/www/test/public_html/index.php が動作することを目標にします。

sites-available conf

/etc/apache2/sites-available/local.test.conf を作成し、以下の通り書き込みます。

<VirtualHost *:80>
    ServerName local.test

    DocumentRoot /var/www/test/public_html/

    <Directory /var/www/test/public_html/>
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
       

a2ensite

次のコマンドを打ち込みます。

sudo a2ensite local.test.conf

/etc/apache2/sites-enabled にlocal.test.confができていることを確認して下さい。

/etc/hosts

/etc/hostsファイルの先頭に次のようにlocal.testを追加します。

127.0.0.1       localhost local.test

これがないとApacheはlocal.testのアドレスを探しにネットの海へ旅立ちます

Apache restart

次のコマンドを打ちます。

sudo /etc/init.d/apache2 restart

パーミッション


mkdir /var/www/test/public_html -p
echo "nya-n!" > /var/www/test/public_html/index.php

sudo chown www-data:www-data /var/www/test/public_html/ -R
sudo chmod 764 /var/www/test/public_html/ -R

おわり

http://local.test にアクセスして"nya-n!"と表示されたら成功です。

1
1
0

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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?