Wordpress에서 예쁜 퍼멀링크 활성화 - Apache 구성이 작동하지 않음
아마 이 오류는 꽤 쉬운 해결책일 것입니다만, 저는 오랫동안 이 오류를 찾아봤지만 여전히 오류를 알 수 없습니다.내가 할 수 있는 건 다 한 것 같아.
문제: 워드프레스 설치에서 매우 영구적인 링크를 활성화하면(따라서 /%postname%/를 사용하고 있음) 동작하지 않습니다.홈페이지를 제외한 모든 페이지에서 404점을 받습니다.
이 페이지 http://codex.wordpress.org/Permalinks에는 permalinks가 동작하기 위한 요건이 나와 있습니다.
- mod_rewrite 모듈이 설치된 Apache 웹 서버
- 워드프레스 홈디렉토리에서
- FollowSymLinks 옵션이 활성화됨
- FileInfo 명령 허용(예: AllowOverride FileInfo 또는 AllowOverride All)
- .htaccess 파일(이 파일이 없는 경우 WordPress는 "예쁜" 퍼멀링크를 활성화하면 파일을 생성하려고 시도합니다)
- WordPress에서 .htaccess 파일을 자동으로 업데이트하려면 WordPress에서 파일에 대한 쓰기 권한이 필요합니다.
Apache Web 서버가 설치되고 mod_rewrite 모듈이 a2enmod rewrite 명령어로 로드되었습니다(그 후 서버가 여러 번 재시작되었습니다).따라서 /etc/apache2/mods-enabled 아래에 rewrite.load에 대한 심볼링크가 있습니다.또한 phpinfo 명령어를 실행하면 mod_rewrite 모듈이 로드되어 있는 것을 알 수 있습니다.이것도 http://namorti.com/phpinfo.php 에서 확인할 수 있습니다.
그 후 /etc/apache2/sites 지원에는 "기본값"이 없습니다.000-default.conf를 기본값으로 복사하고 나중에 기본값을 편집했습니다.다음 내용이 포함됩니다.DocumentRoot /var/www
<Directory />
Options FollowSymLinks Indexes
AllowOverride FileInfo
</Directory>
제 생각에는 FollowSymLinks가 활성화되어 있고 FileInfo 디렉티브가 허용되어 있습니다.
마지막 두 포인트에 대해서는 워드프레스 홈디렉토리(/var/www)에 .htaccess가 존재하며 Wordpress에 의해 쓰기 가능합니다(permalink 구조를 여러 번 업데이트하면 그에 따라 .htaccess 파일이 업데이트됩니다).현재 이 파일에는 다음이 포함됩니다.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
제가 아는 한, 효과가 있을 겁니다.서버를 몇 번 재기동했습니다(service apache2 restart).내가 뭘 놓쳤는지 모르겠어여기 단서 있는 사람?
잘 부탁드립니다!
* 편집 *
그래서, 난 칼시네가 시키는 대로 했어/etc/apache2/sites-enabled/default 파일(vhost 포함)을 편집했습니다.현재는 다음과 같습니다.
<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'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.example.com
ServerAdmin www.namorti.com
DocumentRoot /var/www
<Directory /var/www>
Options MultiViews
AllowOverride None
Order allow,deny
allow from all
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</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
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# 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>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
아파치를 다시 시작했는데, 안타깝게도 여전히 작동하지 않습니다.솔직히 놀랐을 것 같아요.htaccess 파일에서 vhost로 디렉티브를 이동하면 htaccess 자체가 동작할 수 있기 때문입니다.다른 모든 것이 충분히 올바른 것 같기 때문입니다.
다른 조언은 없나요?수고하셨습니다!
하세요.AllowOverrides는 「Directive」로 되어 있습니다.allvhost - apache가 찾을 수 있도록 지시하는 것입니다..htaccess파일을 표시합니다.
더 나은 솔루션은 파일에 대한 쓰기 액세스 권한이 분명히 있으므로 다시 쓰기 지침을 vhost에 넣는 것입니다.AllowOverrides를 켜면 apache는 모든 요청에서 디렉토리와 모든 상위 디렉토리에서 .htaccess 파일을 검색하므로 성능이 크게 저하될 수 있습니다.
Wordpress의 경우 vhost는 다음과 같습니다.
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/site
<Directory /var/www/site>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</Directory>
</VirtualHost>
내가 직접 해결했다.
이 파일은 "000-default.conf" 파일과 관련이 있습니다.이 파일은 이미 질문에서 언급했듯이 "default"로 복사하고 "default"를 편집했습니다.
서비스 자체에서 "000-default.conf" 파일을 사용하고 있는 것 같습니다."default" 파일을 "000-default.conf"로 다시 복사하고 Apache 서비스를 재시작하면 모든 것이 작동합니다.
주의사항: calcinai의 제안은 효과가 있을 것 같지만 올바른 "000-default.conf" 파일의 vhost에서 그의 제안을 받았기 때문에 403 Forbidden 오류가 발생했습니다.내가 그의 콘텐츠를 원래 콘텐츠로 대체했을 때
DocumentRoot /var/www
<Directory />
Options FollowSymLinks Indexes
AllowOverride FileInfo
</Directory>
그리고 아파치 서비스를 다시 시작하니 모든 것이 작동했습니다.
도와주려고 노력해주신 calcinai씨께 감사드립니다:)
Permalink 문제
이 파일 안에서 우리는 모든 것을 바꾸고 싶다.
sudo nano /etc/apache2/sites-available/000-default.conf
000-default.conf
- 다음과 같이 됩니다.
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
이렇게 표시되지 않으면 위의 코드를 가상 호스트 내에 붙여넣습니다.
완료되면 파일을 저장하고 닫습니다.
다음으로 URL을 변경할 수 있는 rewrite 모듈을 활성화해야 합니다.다음과 같이 입력할 수 있습니다.
sudo a2enmod rewrite
다음을 변경한 후 Apache를 재시작하십시오.
sudo service apache2 restart
이것은 이 문제를 해결하는 데 도움이 될 수 있습니다.
sudo chown -R www-data:www-data /var/www
오랜 시간을 들여 Linux 머신의 LAMP 서버에서 정상적으로 동작한 것을 소개합니다.완벽하게 작동하기 위해서는 다음과 같은 변화가 필요합니다.
이 항목을 에 추가합니다.
/etc/hosts파일.127.0.0.1 sitename.com경로에 다음과 같이 호스트 항목 추가
/etc/apache2/sites-available/sitename.com.conf<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName sitename.com DocumentRoot /var/www/sitename.com/public_html <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/sitename.com/public_html> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>사이트 사용 가능에 대한 심볼 링크를 생성합니다.
sudo ln -s /etc/apache2/sites-available/sitename.com.conf /etc/apache2/sites-enabled/sitename.com.conf명령어를 사용하여 Apache를 재시작합니다.
sudo service apache2 restart
이건 나한테 딱 맞아.https://www.digitalocean.com/community/questions/wordpress-permalinks-not-working-on-ubuntu-14-04 에서 가져온 호스트 엔트리를 추가하는 순서
언급URL : https://stackoverflow.com/questions/18774784/enabling-pretty-permalinks-on-wordpress-apache-configuration-does-not-work
'programing' 카테고리의 다른 글
| Woocommerce: 오더 상태를 프로그래밍 방식으로 업데이트 (0) | 2023.04.04 |
|---|---|
| Wordpress: mysql DATE_FORMAT 사용 시 $wpdb 준비에 실패함 (0) | 2023.04.04 |
| "최상위 레벨 JSON 어레이"란 무엇이며, 이러한 어레이가 보안상의 리스크가 되는 이유는 무엇입니까? (0) | 2023.04.04 |
| 맵 또는 속성 개체로 모든 환경 속성에 액세스 (0) | 2023.04.04 |
| 큰 파일에서 줄 구분된 JSON을 읽는 방법(한 줄씩) (0) | 2023.04.04 |