Linux の Apache 設定ファイルはどこにありますか?

藏色散人
リリース: 2019-07-03 11:25:01
オリジナル
10433 人が閲覧しました

Linux の Apache 設定ファイルはどこにありますか?

Linux 上の Apache の設定ファイルは /etc/apache2/apache2.conf で、Apache は起動時にこのファイルの設定情報を自動的に読み取ります。 httpd.conf などの他の構成ファイルは、Include ディレクティブによって組み込まれます。

apache2.conf には sites-enabled ディレクトリがあり、/etc/apache2 の下には sites-available ディレクトリがあります。実際、これが実際の設定ファイルであり、sites-enabled ディレクトリにはここにはファイルを指すシンボリック リンクがいくつかあります。ls /etc/apache2/sites-enabled/ でこれを確認できます。

したがって、複数の仮想ホストが Apache 上に構成されており、各仮想ホストの構成ファイルが sites-available の下に配置されている場合、仮想ホストを非アクティブにして有効にすると非常に便利です。 -enabled で仮想ホスト構成ファイルへのリンクが確立されている場合、それは有効になります。仮想ホストをオフにしたい場合は、対応するリンクを削除するだけで済み、構成ファイルを変更する必要はまったくありません。

sudo cp /etc/apache2/sites-avaliable/000-default.conf , 命名为 test.conf
ログイン後にコピー

2. 設定ファイルを変更します: test.conf

<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request&#39;s Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName www.test.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/test/
ErrorLog /var/www/html/test/error.log
CustomLog /var/www/html/test/access.log combined
<Directory "/var/www/html/test">
    Options FollowSymLinks
    DirectoryIndex index.php index.html index.htm
    AllowOverride All #注意这个地方的配置,会影响本地目录下的.htaccess的启用
    Order deny,allow
    Allow from All
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
ログイン後にコピー

リンク ファイルを作成します:

sudo ln -s /etc/apache2/sites-available/test.conf /etc/apache2/sites-enabled/test.conf
ログイン後にコピー

または: sudo a2ensite test.conf

4 . apacheサーバーを再起動

sudo /etc/init.d/apache2 restart
ログイン後にコピー
ログイン後にコピー

ホスト(/etc/hosts)を変更

// 增加一行
127.0.0.1 www.test.com
ログイン後にコピー

基本的にはここで普通にアクセスできます!

添付ファイル: ディレクトリ レベルの URL 書き換えサポートがまだ必要な場合は、以下に進んでください:

ターミナル操作

sudo a2enmod
ログイン後にコピー

プログラムは、アクティベーションに使用できるモジュール名の入力を求めるプロンプトを表示します。次のように入力します。 rewrite

成功するとプロンプトが表示されます

rewrite already load
ログイン後にコピー

/etc/apache2/sites-enabled/test.conf を変更します (このリンクはサイト構成ファイルを指します)

次の変更を加えます「AllowOverride」プロパティを「All」に設定して保存します。 (上記のすべてに設定しました)

Reload apache

sudo /etc/init.d/apache2 restart
ログイン後にコピー
ログイン後にコピー

Apache 関連の知識の詳細については、Apache 使用法チュートリアル 列を参照してください。

以上がLinux の Apache 設定ファイルはどこにありますか?の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

関連ラベル:
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!