简体   繁体   English

从/ etc / images目录而不是/ var / www目录访问映像

[英]Accessing Images from /etc/images directory instead of /var/www directory

The whole PHP application is under this /var/www directory. 整个PHP应用程序位于此/ var / www目录下。 But images folder is in /etc/images. 但图像文件夹位于/ etc / images中。 How to access these images in /etc/images directory using PHP. 如何使用PHP访问/ etc / images目录中的这些图像。

在/ etc / images和/ var / www / images之间添加具有适当权限的符号链接

I would try to keep for using symlinks to outside your www folder, but if your images but be served from that folder then symlink is probably your best bet. 我会尝试继续使用符号链接到你的www文件夹之外,但如果你的图像是从该文件夹提供的,那么符号链接可能是你最好的选择。

You could also use php to create a tmp image based on your image in the folder outside of your www. 你也可以使用php根据你的www之外的文件夹中的图像创建一个tmp图像。 This way your server scripting language (php) would have access to this non-www folder and create an image in a tmp folder within your www folder on demand, segregating your system folders from the web. 这样,您的服务器脚本语言(php)就可以访问这个非www文件夹,并根据需要在www文件夹中的tmp文件夹中创建一个图像,从而将您的系统文件夹与Web隔离。

That depends on what webserver you're using: 这取决于您使用的网络服务器:

Are you using the php-internal development webserver? 你在使用php内部开发网络服务器吗? Just symlink from /var/www/images to /etc/images. 只需从/ var / www / images到/ etc / images的符号链接。

Are you using Apache? 你在使用Apache吗? Then the solution is two-folds: 然后解决方案是双重的:

  1. Enable serving content from /etc/images 启用/ etc / images中的服务内容
  2. Point the URL to the directory 将URL指向目录

     <Directory /etc/images> order allow,deny allow from all </Directory> Alias /images /etc/images/ 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM