2
0

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 1 year has passed since last update.

xamppを使用してlocal環境に自分の好きなサブドメインでアクセスする

Last updated at Posted at 2024-04-02

はじめに

こんにちは、エンジニアのkeitaMaxです。

今回はxamppの設定についてです。

xamppインストール

まずxamppを以下のサイトでwindows版をダウンロードします。

インストール出来たら、[xampp]を右クリック ⇒ [XAMPP control Panel]を右クリック ⇒ [管理者として実行]をクリックします。

管理パネルが立ち上がったら、ApacheとMySQLをインストールします。
ApacheとMySQLと書いてある右のバツボタンをクリックするとインストールすることができます。

インストールが完了したら、ApacheとMySQLを起動させます。

ApacheとMySQLの右横にある[Start]と書いてあるボタンを押せば起動できます。[Start]が[Stop]に変われば起動できています。

インストールが完了したら、C:\xampp\htdocs\フォルダ配下にkeitamaxフォルダを作成し、その配下にindex.htmlファイルを作成してみます。

index.html
<!DOCTYPE html>
<html>
    <body>
        <p>こんにちは</p>
    </body>
</html>

この状態で、http://localhost/keitamax/index.htmlにChromeなどのブラウザでアクセスすると「こんにちは」と表示されるようになります。

localhostでなく自分の好きなサブドメイン(keitamax.localhost)でアクセスする

次にlocalhostではなく、自分の好きなドメインでアクセスできるようにします。

まず、以下のファイルを修正します。
普通に選択してもファイルの中身を修正できないのでメモ帳をつかって修正してください。
C:\Windows\System32\drivers\etc\hosts

以下を追記してください。

127.0.0.1 keitamax.localhost

次に、C:\xampp\apache\conf\extra\httpd-vhosts.confファイルを修正します。
httpd-vhosts.confを開いて、ファイルの一番下に以下のように記述してください。

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/keitamax"
    ServerName keitamax.localhost
</VirtualHost>

最後に、[XAMPP control Panel]にもどりApacheとMySQLを再起動させ、以下のURLでアクセスをします。

http://keitamax.localhost/index.html

すると、こんにちはという画面が見れると思います。

おわりに

この記事での質問や、間違っている、もっといい方法があるといったご意見などありましたらご指摘していただけると幸いです。

最後まで読んでいただきありがとうございました!

2
0
3

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?