WordPress-Apache 2プロファイルと書き込みモードのオン
5570 ワード
WordPress-Apache 2プロファイルと書き込みモードのオン
WordPrssの試行を開始すると、ブログ記事にアクセスしてエラーが発生します.
The requested URL /hello-world-.html was not found on this server
様々な答えを探してみると、Apache 2の書き換えモードがオンになっていないことによる.
書き換えモードについては、多くのリソースがApache 2 httpdの修正を紹介しています.conf、しかし私は長い間探してhttpdを見つけていません.confファイル
Ubuntu端末検索コマンド:
find / -name httpd.conf
実際、Apache 2にはhttpdはありません.confプロファイル、実際のApache 2プロファイルは/etc/apache 2/apache 2.conf.Apache 2の起動時にデフォルトではファイル内の構成情報が自動的に読み出すが、他の構成情報はIncludeに含まれる.次のようになります.
# Include module configuration:
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/*.conf
# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf
# Include list of ports to listen on
Include ports.conf
1.Apache 2プロファイル
/etc/apache 2/のディレクトリ構造:
python
├── apache2.conf #
├── ports.conf
├── conf-available
└── *.conf
├── conf-enabled
└── *.conf
├── mods-available
├── *.load
└── *.conf
├── mods-enabled
├── *.load
└── *.conf
├── sites-available
├── 000-default.conf
└── default-ssl.conf
├── sites-enabled
└── 000-default.conf
availableとenabledフォルダの違いと役割:-enable/フォルダ内のファイルはapache 2に含まれる.conf内の構成、すなわち有効な構成ファイル.AVailable/フォルダ内のファイルは、使用可能なすべてのプロファイル、すなわち有効でないプロファイルが使用されていない.特定の設定が必要な場合、すなわちavailableフォルダ内から対応するプロファイルをenabledフォルダ内にコピーすればよい.
2.Apache 2書き換えモードをオン
LoadModule rewrite_module
sudo cp /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
chmod -R 775 rewrite.load
sudo vim apache2.conf
# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
Options FollowSymLinks
AllowOverride None
Require all denied
AllowOverride None
Require all granted
var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
#
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
#
変更後:
# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
Options FollowSymLinks
AllowOverride All
Require all denied
AllowOverride All
Require all granted
var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
#
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
#
sudo systemctl restart apache2.service