Apache VirtualHost 403 금지
최근에 Apache로 테스트 서버를 설정하려고했습니다. 사이트는 domain에서 실행해야합니다 www.mytest.com
. 나는 항상 403 Forbidden
오류가 발생합니다. 우분투 10.10 서버 에디션에 있습니다. 문서 루트는 dir 아래에 /var/www
있습니다. 다음은 내 설정입니다.
/ var / www의 내용
ls -l /var/www/
total 12
drwxr-xr-x 2 root root 4096 2011-08-04 11:26 mytest.com
-rwxr-xr-x 1 root root 177 2011-07-25 16:10 index.html
서버의 호스트 파일 내용 (IP 192.168.2.5)
cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 americano
192.168.2.5 americano.mytest.com www.mytest.com
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
사이트 구성
<VirtualHost *>
ServerAdmin admin@mytest.com
ServerName www.mytest.com
ServerAlias mytest.com
DocumentRoot "/var/www/mytest.com"
ErrorLog /var/log/apache2/mytest-error_log
CustomLog /var/log/apache2/mytest-access_log combined
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/var/www/mytest.com">
Options -Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
.htaccess
내 문서 루트에 파일 이 없습니다 . 권한이 올바르게 설정되었습니다 (www-data에서 읽을 수 있음).
데스크탑에서 IP 주소를 입력하면 사이트가 올바르게 표시됩니다. 데스크탑의 호스트 파일을 www.mytest.com
서버의 IP 를 가리 키 도록 변경했습니다 . 사용하면을 얻습니다 403
. 이 사이트의 많은 기능이 사이트 이름에 민감하기 때문에 도메인 이름으로 사이트에 액세스 할 수 있어야합니다.
Another funky thing is, even if all log files are created properly, they have no information regarding this error.
I am stuck. Can anybody help?
Apache 2.4.3 (or maybe slightly earlier) added a new security feature that often results in this error. You would also see a log message of the form "client denied by server configuration". The feature is requiring a user identity to access a directory. It is turned on by DEFAULT in the httpd.conf that ships with Apache. You can see the enabling of the feature with the directive
Require all denied
This basically says to deny access to all users. To fix this problem, either remove the denied directive (or much better) add the following directive to the directories you want to grant access to:
Require all granted
as in
<Directory "your directory here">
Order allow,deny
Allow from all
# New directive needed in Apache 2.4.3:
Require all granted
</Directory>
For apache Ubuntu 2.4.7 , I finally found you need to white list your virtual host in apache2.conf
# access here, or in any related virtual host.
<Directory /home/gav/public_html/>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
This may be a permissions problem.
every single parent path to the virtual document root must be Readable, Writable, and Executable by the web server httpd user
according to this page about Apache 403 errors.
Since you're using Allow from all
, your order shouldn't matter, but you might try switching it to Deny,Allow
to set the default behavior to "allowing."
Move the Directory clause out of the virtualhost, and put it before declaring the virtualhost.
Drove me nuts for a long time too. Don't know why. It's a Debian thing.
I was having the same problem with a virtual host on Ubuntu 14.04
For me the following solution worked:
http://ubuntuforums.org/showthread.php?t=2185282
It's just adding a <Directory >
tag to /etc/apache2/apache2.conf
I just spent several hours on this stupid problem
First, change permissions using this in terminal
find htdocs -type f -exec chmod 664 {} + -o -type d -exec chmod 775 {} +
I don't know what the difference is between 664 and 775 I did both 775 like this Also htdocs needs the directory path for instance for me it was
/usr/local/apache2/htdocs
find htdocs -type f -exec chmod 775 {} + -o -type d -exec chmod 775 {} +
This is the other dumb thing too
make sure that your image src link is your domain name for instance
src="http://www.fakedomain.com/images/photo.png"
Be sure to have
EnableSendfile off in httpd.conf file
EnableMMAP off in httpd.conf file
You edit those using pico in terminal
I also created a directory for images specifically so that when you type in the browser address bar domainname.com/images, you will get a list of photos which can be downloaded and need to be downloaded successfully to indicate image files that are working properly
<Directory /usr/local/apache2/htdocs/images>
AddType images/png .png
</Directory>
And those are the solutions I have tried, now I have functioning images... yay!!!
Onto the next problem(s)
If you did everything right, just give the permission home directory like:
sudo chmod o+x $HOME
then
sudo systemctl restart apache2
The problem was that the file access permission was wrong.
I changed the permissions of the directory and it worked.
참고URL : https://stackoverflow.com/questions/6959189/apache-virtualhost-403-forbidden
'development' 카테고리의 다른 글
HTML : 파일 업로드를 이미지만으로 제한하는 방법? (0) | 2020.07.25 |
---|---|
삽입하는 동안 SQLite 오류 '읽기 전용 데이터베이스 쓰기 시도'? (0) | 2020.07.25 |
파이썬에서 여러 목록을 하나의 목록으로 병합하는 방법은 무엇입니까? (0) | 2020.07.25 |
사용자 정의 정렬 순서를 사용하여 객체의 ArrayList 정렬 (0) | 2020.07.25 |
Android : 활동에서 방향 변경을 일시적으로 비활성화 (0) | 2020.07.25 |