我已经安装了 XAMPP Apache 服务器并将我的网站放入 htdocs 中。 我已经启动了 Apache 服务器。 在我的网站上,我有扩展名为 PHP 和扩展名为 PHP5 的文件。区别在于,当我在浏览器中输入 localhost/file.php 时,我会看到一个已解析的网站。
但是当我输入 localhost/file.php5 (我在服务器上有这个文件)时,浏览器会询问我是否要下载或打开这个文件。 如果我选择打开,我会看到 file.php5 的 PHP 代码!
我研究了配置,所以:
- 我没有 htaccess 文件
- PHPINFO() 显示 PHP 5
-
c:\xampp\apache\conf\extra\httpd-xampp 包含在配置中,并且开头有这个:
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml .phpt
我也尝试将:
AddHandler php5-script .php5
AddType text/html .php5
放入 httpd.conf 中,但确实如此不适合我(没有变化)。
你能帮我修一下吗? 我想要用 php5 解析器打开 php5 和 php 扩展文件。
I've installed XAMPP Apache server and put my website into htdocs. I've started Apache server. On my website I've got files with extension PHP and with extension PHP5.The difference is that when I type in into browser localhost/file.php - I see a parsed website.
But when I type localhost/file.php5 (i have this file on server), than browser asks me if I want to download or open this file. And if I choose open than I see PHP code of file.php5!
I've looked into configuration, so:
- I dont have htaccess file
- PHPINFO() shows PHP 5
-
c:\xampp\apache\conf\extra\httpd-xampp is included into configuration and has this on the beginning:
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml .phpt
I've tried also to put:
AddHandler php5-script .php5
AddType text/html .php5
Into httpd.conf, but it does not work for me (no changes).
Could you please help me fixing it? I would like to have php5 and php extension files to be opened with php5 parser.
发布评论
评论(4)
添加:
在 OS X 和 Apache 2.2.10 下为我工作,我无法想象它在 XAMPP 上有什么不同。 我会撤消您对 httpd.conf 的所有其他更改/修改,然后只有:
然后重新启动 apache。 去掉 AddHandler、AddType 等。
Adding:
worked for me under OS X and Apache 2.2.10, I cannot imagine it being different on XAMPP. I would undo all of your other changes/modifications to httpd.conf and then only have:
Then restart apache. Get rid of the AddHandler, the AddType, etc.
默认情况下,XAMPP 将具有以下扩展名的文件传递给 PHP: .php .php5 .php4 .php3 .phtml .phpt (这是使用 XAMPP Lite 1.6.8 进行测试的)。
我的建议是从 XAMPP 配置中删除“AddType text/html .php5”行。 或者,使用全新安装的 XAMPP 并查看差异(使用 WinMerge 之类的内容)。
XAMPP passes by default files with the following extensions to PHP: .php .php5 .php4 .php3 .phtml .phpt (this was tested with XAMPP Lite 1.6.8).
My suggestion would be to remove the "AddType text/html .php5" line from the XAMPP configuration. Alternatively, use a clean install of XAMPP and look at the differences (with something like WinMerge).
当我切换到 Ubuntu 操作系统时,我必须弄清楚如何再次执行此操作。 需要修改的文件名为
php5.conf
。我使用突触包管理器(系统>管理>突触包管理器)安装了apache 2、php5、phpmyadmin、mysql-server和rapache,并且没有使用XAMPP。 如果您已经安装了 XAMPP,则
php5.conf
的路径将会不同,可能位于/opt/lampp
文件中的某个位置。在我的安装中,它的路径是
/etc/apache2/mods-avaible/php5.conf
。 在对其进行修改之前,您必须使用终端更改权限以允许您对其进行写入。 要访问它,请打开终端并键入 :,然后键入更改权限的行:
您可以键入以下内容以确保权限已更改:
您应该看到一长串带有权限概念的文件。
php5.conf
的行应如下所示(日期和时间除外):这意味着每个人都具有读写权限。 如果需要,您可以在完成后将权限更改回来。 现在,通过键入以下内容继续进行所需的更改:
这将在一种文本编辑器中打开文件。 您应该看到的是这样的:
将文本更改为如下所示:
将
.php5
添加到第一个AddType
命令之后。按 ctrl+x 退出,按 y 保存更改。 然后重新启动计算机。 然后带有
.php5
扩展名的文件就应该可以工作了!我不敢相信我花了几个小时才弄清楚! 祝你好运!
I had to figure out how to do this again when I switched to an Ubuntu OS. The file that needs to be modified is called
php5.conf
.I installed apache 2, php5, phpmyadmin, mysql-server and rapache with the synaptic package manager (system> administration> synaptic package manager) and did not use XAMPP. If you have already installed XAMPP then the paths to
php5.conf
will be different, likely somewhere in the/opt/lampp
file.With my install, the path to it is
/etc/apache2/mods-avaible/php5.conf
. Before it can be modified you must use the terminal to change the permissions to allow you to write to it. To get to it, open the terminal and type :and then line that changes the permissions:
You can type the following to make sure the permissions have been changed:
You should see a long list of files with the permission notions. The line for
php5.conf
should look like this (with the exception of the date and time):This means everyone has read and write permissions. You can change the permissions back when you get done if you want. For now proceed to make the changes you need by typing:
This opens the file in a kind of text editor. What you should see is this:
Change the text to read as follows:
Adding the
.php5
to after the firstAddType
command.Press ctrl+x to exit and y to save changes. Then restart the computer. And then your files with the
.php5
extensions should work!I can't believe that took me hours to figure out! Good luck!
遵循路径
c:/xampp/apache/conf/extra/httpd-xammp
打开
httpd-xammp
找到与此类似的文本区域:
将代码的顶行替换为以下内容:
因此文本类似于以下内容:
这对我有用。
祝你好运..
Follow the path
c:/xampp/apache/conf/extra/httpd-xammp
Open
httpd-xammp
Find the area of the text that resembles this:
replace the top line of the code with the following:
so the text resembles the following:
That worked for me.
Good luck..