关于apache无权限访问的问题

PHP 林涛 1248℃ 0评论

最近碰到个非常surprising的事情,如下:

系统:Ubuntu   windows文件夹是Fat32格式。

在ubuntu下,用xampp安装好php环境后,不能访问其下的windows文件夹的软连接,权限已经是777了;但是直接在其目录下的文件夹是可以访问的;

重新安装apache2、php5、mysql、phpmyadmin 之后自己手动配置,情况依旧,提示信息是: Symbolic link not allowed or link target not accessible:;

整整折腾了N天,无奈求助单位高人,在高人的带领下终于在一个外国哥们那里找到了答案:原文如下:

——Hi everybody, im newbie here,
Today i decided to install ubuntu on my laptop (I’ve installed Win XP with xampp 1.70 for windows first). After that, I install Xampp 1.70 for linux.
Go to http://localhost/, it’s work nomally.
But I’m PHP developer, I have all code in C:\xampp\htdocs (xampp for windows), now I want to run it in Linux environment. So I edit the httpd.conf file. change DocumentRoot to /media/WinXP/xampp/htdocs (the Linux’s path of C:\xampp\htdocs).
After restart apache, I go to http://localhost/, it said that “Forbidden” !!!, its look like cannot have permission of /media/WinXP/xampp/htdocs

I’m new to Ubuntu, can anyone helpme

——You have also changed the associated “<Directory>” directive?

——

yes I’ve also changed, but i still get 403 error

OK, but after many hours, I’ve found solution !!!!!!!

—————————– COMPLETE SOLUTION —————————————————
1, First, Install xampp in your system (i use ubuntu 8.1), dont start it !! (if u are running, stop it by sudo -u root /opt/lampp/lampp stop )
2, OK, my Ubuntu account login name is “dungpq”, u must replace it by your login name
apache running with www-data account, not root account, so if u mount the windows’s xampp drive (Eg. <WinXP>C:\ mount to /media/WinXP/), www-data cannot access this dir => U will get 403 error if u change DocumentRoot to htdocs folder in windows’s xampp htdocs
=> U must mount the drive which has windows xampp installed to another folder (which www-data can access)
I will mount it to /home/dungpq/WinXP

Before mount WinXP to /home/dungpq/WinXP, u must unmount this
sudo -u root umount /media/WinXP

ok, now edit fstab
sudo -u root gedit /etc/fstab

place this code in bottom of file
# WInXP drive – DungPQ@informa
/dev/sda6 /home/dungpq/MISC auto rw,exec,auto,user,sync,umask=0000 0 0

now remount this
sudo -u root mount /dev/sda6

Remember !! (sda6 is name of your drive)
ok, now the windows’s xampp drive can be accessed by everyone (including www-data)

now edit the httpd.conf file
sudo -u root gedit /opt/lampp/etc/httpd.conf

Find “/opt/lampp/htdocs” and replace by “/home/dungpq/WinXP/xampp/htdocs”
(u will find 2 line contain it)

save and close this file.
Now start xampp
sudo -u root /opt/lampp/lampp start

go to http://localhost/, u will access the htdocs folder of windows’s xampp !!!!!

But, now, u need use mysql database from windows’s xampp, right ?
First stop xampp
sudo -u root /opt/lampp/lampp stop

now create simple bash file, make link from windows’s xampp mysql data folder to linux’s xampp mysql data folder

#!/bin/bash
# Create link to windows xampp myql data folder
# DungPQ@informa

for i in $( ls “/home/dungpq/WInXP/xampp/mysql/data”);
do
if [ $i != “ibdata1” ]; then
if [ $i != “ib_logfile0” ]; then
if [ $i != “ib_logfile1” ]; then
if [ $i != “mysql” ]; then
if [ $i != “phpmyadmin” ]; then
if [ $i != “test” ]; then
ln -s /home/dungpq/WinXP/xampp/mysql/data/$i /opt/lampp/var/mysql/$i;
fi
fi
fi
fi
fi
fi
done

Run it by root access, and all mysql data from windows’s xampp will be show in mysql data list of linux’s xampp

start xampp again
sudo -u root /opt/lampp/lampp start

OK, now u can use the same htdocs file and database between windows and linux
Thanks

如需转载请注明: 转载自26点的博客

本文链接地址: 关于apache无权限访问的问题

转载请注明:26点的博客 » 关于apache无权限访问的问题

喜欢 (0)
发表我的评论
取消评论

表情