我的/var/www folder
中有以下php文件(try.php)。我正在操作一台Mac。
$html = "testing print";
$handle = printer_open();
printer_set_option($handle, PRINTER_MODE, "RAW");
printer_write($handle, $html);
printer_close($handle);
我安装了apache和php。如果我执行命令。
apachectl -version
我得到了
Server version: Apache/2.2.26 (Unix)
Server built: Dec 10 2013 22:09:38
同样执行php版本我
PHP 5.4.30 (cli) (built: Jul 29 2014 23:43:29)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
我使用以下命令重新启动服务器。
sudo apachectl restart
该命令在控制台上返回而不打印任何内容。之后我点击了网址。
http://localhost/try.php
这给了我404错误。
在此服务器上找不到请求的URL /try.php。
我还为/var/www
文件夹提供了读,写和执行权限。
任何想法我得到了这个错误。
http.conf文件中的文档根配置如下。
<Directory />
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order deny,allow
Allow from all
</Directory>
答案 0 :(得分:1)
将文件放入/ var / www / html 文件夹
答案 1 :(得分:1)
首先,您应该找到文档根目录。
通过在shell中运行以下命令,您应该获得apache配置文件的路径:
/usr/sbin/apache2 -V | grep SERVER_CONFIG_FILE
然后选择您喜欢的编辑器,并在其中搜索DocumentRoot
参数。
默认情况下,DocumentRoot
定义公共数据的路径。无论该文件夹内部是什么,其他人都可以在服务器外看到。
有关详情,建议您阅读apache documentation