web-dev-qa-db-ja.com

異なるルートディレクトリ用にxampp Webサーバーを構成する方法

Webディレクトリは、アプリケーションのすべてのパブリックファイルと静的ファイルのホームです。画像、スタイルシート、JavaScriptファイルを含みます。また、フロントコントローラーが存在する場所でもあります。

だから質問は、xamppをインストールしてセットアップするときの私のウェブディレクトリです:

xampp\htdocs

そして、私はそれを設定したい:

xampp\htdocs\myproject\web

どうやるか?ブラウザに次のアドレスを入力すると、http://localhost/
xampp\htdocsディレクトリを入力します
そしてブラウザにアドレスを入力したい:http://localhost/
xampp\htdocs\myproject\webディレクトリを入力します

56
vardius

(xamppコントロールパネルで)Apache/conf/httpd.confをクリックしてApacheのhttpd.confを変更し、DocumentRootおよび対応するDirectoryエントリのエントリを調整できます。ただ Ctrl+F 「htdocs」の場合、エントリを新しいパスに変更します。

89
blckwngd
  • C:\ xampp\Apache\conf\httpd.confに移動します
  • Httpd.confを開きます
  • タグを検索:DocumentRoot "C:/ xampp/htdocs"
  • タグを編集:DocumentRoot "C:/ xampp/htdocs/myproject/web"
  • タグを見つけて<Directory "C:/ xampp/htdocs/myproject/web"に変更します>

  • Apacheを再起動します

27
LALIT JAMNAL

場合によっては、特にLinux(Ubuntuなど)でより簡単なソリューションを好む場合は、htdocsフォルダー内の目的のフォルダーへのシンボリックリンクを作成するのが非常に簡単な方法です。たとえば、「/ home/some/projects/testserver /」というフォルダーからファイルを提供したい場合、htdocsは「/ opt/lampp/htdocs /」にあります。次のようなシンボリックリンクを作成するだけです。

ln -s /home/some/projects/testserver /opt/lampp/htdocs/testserver

シンボリックリンクのコマンドは次のように機能します。ln -s target sourceここで、

target - The existing file/directory you would like to link TO.
source - The file/folder to be created, copying the contents of the target. The LINK itself.

詳細については、ln --helpソースを参照してください。 buntuでシンボリックリンクを作成

これで完了です。 http:// localhost/testserver / にアクセスするだけです。実際、サーバーを再起動する必要はありません。

10
user1585863

Apache構成ファイル(httpd.conf)を編集せずに、htdocsフォルダーをC:\ xampp\htdocsからD:\ htdocsに移動しました。

ステップ1)C:\xampp\htdocsフォルダーをD:\htdocsに移動しますステップ2)mklinkコマンドを使用して、D:\ htdocsにリンクされたC:\ xampp\htdocsにシンボリックリンクを作成します。

D:\>mklink /J C:\xampp\htdocs D:\htdocs
Junction created for C:\xampp\htdocs <<===>> D:\htdocs

D:\>

ステップ3)完了!

4
akvermaktr
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.Apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks Includes ExecCGI

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
AllowOverride All

#
# Controls who can get stuff from this server.
#
Require all granted

次のタグ内に上記のコードを記述します<ディレクトリ "c:\ projects"> </ディレクトリ> c:(任意のディレクトリd:e:を追加できます)は、プロジェクトフォルダを作成したドライブです。

エイリアス/ projects "c:\ projects"

これで、ブラウザのpr0jectsディレクトリにアクセスできます。

localhost/projects /

3
Homesh Paul

わかりました。信じられないかもしれないので、YouTubeにビデオを置いて[ ここをクリック ]

今、手順:

  1. xamppコントロールパネルを実行します
  2. configというボタンをクリックします
  3. apache(httpd.conf)を選択します
  4. ドキュメントルートを見つける
  5. 取り替える

DocumentRoot "C:/xampp/htdocs" <Directory "C:/xampp/htdocs">

これらの2行|| C:/ xampp/htdocs ==ルートの現在の場所|| C:/ xampp/htdocsを任意の場所に変更します

  1. 保存して完了:Apacheを起動し、localhostに移動してアクションを確認[ ビデオを見るにはここをクリック ]
3
insCode