0

I am very new to web servers , php, etc. I built a small web server using Apache 2.2.22 on ubuntu 12.04 LTS. The webpage is for local access only and can be viewed by other devices connected to the access point (No thereat of security). The document root directory is /var/www/, I edited the default index.html file to display what I want to see.

Here I am trying to display few images which is in /home/myname/somedir/, but the images are not displayed. I cannot save the images to the web document root as the images are being updated regularly by another program. How do i access the images and display them.

Things I have tried so far:

  1. Symbolic / soft link
  2. Aliasing: added this to the default configuration file /etc/apache2/sites-available/default

    Alias /images/ "/home/myname/somedir/" <Directory "/home/myna-me/somedir/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory>

  3. php script: I used the following code in a php script `cam_images.php'

and I called them in the hmtl file as /cam_images.php?file=myfile.jpg referred from here

None of them have worked so far. I'm not sure where I am going wrong. I have also tried readfile() in php, but the function isn't able to open that file. I even tried moving the DocumentRoot to the same directory as of the images but the webpage was not shown

(you don't have permission to access / of the server)

Any help is appreciated.

Thanks

Community
  • 1
  • 1
spacemanspiff
  • 113
  • 12

1 Answers1

0

Please check the PHP user has an access to /home/myname/somedir/. Usually only user itself has access to /home/user, so most probably that is the reason.

To fix the permissions:

chmod o+rx /home/myname
chmod -R o+rx /gome/myname/somedir
Andriy Berestovskyy
  • 8,059
  • 3
  • 17
  • 33
  • @Andiy:Thank you. I guess this would have worked.. But I enable the used directory and added a public_html dir and got it to work.. Thank you once again. – spacemanspiff May 18 '17 at 23:56