LoginSignup
1
0

More than 3 years have passed since last update.

【XAMPP】PHPの制作物を任意のディレクトリで作りたい

Last updated at Posted at 2020-02-09

3行で

  • httpd.conf を開く
  • DocumentRoot のディレクトリを書き換える
  • localhostにアクセス

環境

Mac

なぜ

自分の制作物を /projects とかのディレクトリ(フォルダ)にまとめているなどの理由で /XAMPP/xamppfiles/htdocs の下にPHPの制作物を入れるのがイヤだなぁという場合。

httpd.conf の中身を書き換える

/Application/XAMPP/xamppfiles/etc/httpd.conf を開いて
DocumentRoot と書かれた部分を探す。
230行目あたりにあります。

DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"

ここを任意のディレクトリに書き換える。

DocumentRoot "/Users/antk/projects/"

など。
そしたらすぐ下にある

<Directory "/Applications/XAMPP/xamppfiles/htdocs">

こちらも書き換える。

<Directory "/Users/antk/projects/">

これでOKです。

localhostにアクセスしてみる

/projects の下に /phpapp という名前のディレクトリを作って index.php というページを作った場合
http://localhost/phpapp/index.php
ってアクセスすると表示されます。

もしObjects not found! と出てくる場合はXAMPPでWeb Serverを Restart ってしてあげると出てくるかもです。

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