且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

读取/使用服务器/home/文件夹中的文件

更新时间:2023-09-19 23:41:34

这是两个问题.

1.如何使PHP包含这些文件. ?

1 . How can I make PHP include these files. ?

确保网络服务器用户例如ubuntu上的www数据具有访问这些文件的适当权限. 我会建议不同于/home/..(如果您问我的话)

Make sure the webserver user e.g. www-data on ubuntu has proper permissions to access those files. I would suggest something different from /home/.. (if you ask me)

2.如何从网络访问那些图像文件?

2 . How to access those image files from web?

如果您使用的是Apache,则必须创建一个别名,以使该图像可通过Web服务器访问.

If you are using apache you'll have to create an alias that makes that images accesible via the web server.

以下是apache2的示例

Here comes an example for apache2

Alias /img /home/path/to/images
<Directory "/home/path/to/images">
    Order allow,deny
    Allow from all
</Directory>

将此配置代码段放置在apache安装的正确位置,例如httpd.conf的末尾或一个单独的文件.不要忘记重启您的网络服务器.

Place this configuration snippet in the proper place of your apache installation e.g. end of httpd.conf or a separate file. Don't forget to restart your webserver.

现在,您应该可以访问以下图像了:

Now you should be able to access the images like:

<img style="vertical-align:bottom" src="http://www.myserver.com/img/buy_button.png"border="0" />