使用PHP设置本地服务器

时间:2021-03-10 23:34:02

I'm trying to setup an Apache/PHP/Postgresql server locally on my machine. I'm using Windows vista business 32bit. I tried to install everything manually (one thing at a time, apache, postgresql and php (all the latest stable releases)) and after I get everything up and running.

我正在尝试在我的机器上本地设置Apache / PHP / Postgresql服务器。我正在使用Windows Vista业务32位。我尝试手动安装所有东西(一次一件事,apache,postgresql和php(所有最新的稳定版本))并且在我完成所有操作之后。

Whenever I try to run a script on my machine, I get a "What do you want to do with the *.php file?" dialog. The dialog is the browser's open/save dialog

每当我尝试在我的机器上运行脚本时,我会得到一个“你想用* .php文件做什么?”对话。该对话框是浏览器的打开/保存对话框

I'm just trying to get the output of phpinfo() to make sure everything is up and running...

我只是想获取phpinfo()的输出,以确保一切正常运行......

I already tried to mess around a bit with the Apache conf file, but since I don't know much about what I'm doing, I reinstalled everything again and the problem is still there. I kinda get the feeling it must have something to do with the PHP thingy isn't correctly installed.

我已经尝试用Apache conf文件搞砸了一下,但由于我不知道我在做什么,我重新安装了所有内容,问题仍然存在。我有点觉得它必须与PHP东西有关,没有正确安装。

When i try to get the output of phpinfo as in:

当我尝试获取phpinfo的输出时,如:

<pre><?php
   phpinfo();
?></pre>

I get the browser's "Open/Save" dialog for the *.php file.

我得到浏览器的* .php文件的“打开/保存”对话框。

6 个解决方案

#1


4  

You should have something like this in your httpd.conf file:

你应该在你的httpd.conf文件中有这样的东西:

LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "c:/php"

Make sure that's in place, and don't forget to restart apache!

确保它已到位,不要忘记重启apache!

In Windows, the default location for your conf file is C:\Program Files\Apache Group\Apache2\conf\httpd.conf

在Windows中,conf文件的默认位置是C:\ Program Files \ Apache Group \ Apache2 \ conf \ httpd.conf

#2


1  

You can also have a look at the official page of PHP in the install section.

您还可以在安装部分查看PHP的官方页面。

There is a closer link if you are on Windows.

如果你在Windows上,有一个更密切的链接。

And you can also use some precompiled installer for this like XAMMP and install Postgres after all is set up and running with the web server and php.

你也可以像XAMMP一样使用一些预编译的安装程序,并在设置并运行web服务器和php之后安装Postgres。

#3


0  

are you on Windows?

你在Windows上吗?

I use Wamp server, which is an excellent way of getting Apache, MySQL and PHP installed and configured without any hassle on Windows.

我使用Wamp服务器,这是在Windows上安装和配置Apache,MySQL和PHP的一种很好的方式,没有任何麻烦。

If you want to use Postgres instead, provided that you've got it installed separately it will work fine. (one great thing you can do with Wamp is add and remove PHP extensions via a GUI pretty much on-the-fly, and pgsql is one of them).

如果你想使用Postgres,只要你已经单独安装它就可以正常工作。 (你可以用Wamp做的一件好事就是通过GUI添加和删除PHP扩展,而且pgsql就是其中之一)。

#4


0  

Maybe somebody can help, but you'd be much better off if you'd provide some relevant details.

也许有人可以提供帮助,但如果你提供一些相关的细节,你会好得多。

What sort of system are you using? Be specific.

你使用什么样的系统?请明确点。

What do you mean by "everything up and running"?

“一切正常运行”是什么意思?

What are you doing when you "try to run a script"?

当你“尝试运行脚本”时你在做什么?

What installation procedures did you use? (If you were following them off a script or how-to, we at least need to know where to find the script or how-to.)

你使用了什么安装程序? (如果您关注脚本或操作方法,我们至少需要知道在哪里找到脚本或操作方法。)

We don't automatically know these things. What seems obvious to you may not be clear to us, and what seems irrelevant to you may turn out to be crucial.

我们不会自动了解这些事情。对你来说似乎显而易见的可能对我们来说并不清楚,与你无关的东西可能变得至关重要。

#5


0  

In httpd.conf, make sure the PHP module is being loaded and that that line isn't commented out. (Comments in httpd.conf starts with #.)

在httpd.conf中,确保正在加载PHP模块,并且该行未被注释掉。 (httpd.conf中的注释以#开头。)

Also what OS are you running?

你还运行什么操作系统?

#6


0  

I had the same problem, You need to configure apache and add the php module... e.g I compiled the php from source as well as the apache. After doing so I then copied the libphp5.so from php/lib dir in to the apache/modules dir. Than you have to add php in the http.conf

我有同样的问题,你需要配置apache并添加php模块...例如我从源代码和apache编译php。在这之后我将libphp5.so从php / lib目录复制到apache / modules目录。比你必须在http.conf中添加php

LoadModule php5_module modules/libphp5.so

LoadModule php5_module modules / libphp5.so

AddHandler php5-script php

AddHandler php5脚本php

you can then restart apache....it's not the most elegant of solutions but it works.

然后你可以重新启动apache ....它不是最优雅的解决方案,但它的工作原理。

#1


4  

You should have something like this in your httpd.conf file:

你应该在你的httpd.conf文件中有这样的东西:

LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "c:/php"

Make sure that's in place, and don't forget to restart apache!

确保它已到位,不要忘记重启apache!

In Windows, the default location for your conf file is C:\Program Files\Apache Group\Apache2\conf\httpd.conf

在Windows中,conf文件的默认位置是C:\ Program Files \ Apache Group \ Apache2 \ conf \ httpd.conf

#2


1  

You can also have a look at the official page of PHP in the install section.

您还可以在安装部分查看PHP的官方页面。

There is a closer link if you are on Windows.

如果你在Windows上,有一个更密切的链接。

And you can also use some precompiled installer for this like XAMMP and install Postgres after all is set up and running with the web server and php.

你也可以像XAMMP一样使用一些预编译的安装程序,并在设置并运行web服务器和php之后安装Postgres。

#3


0  

are you on Windows?

你在Windows上吗?

I use Wamp server, which is an excellent way of getting Apache, MySQL and PHP installed and configured without any hassle on Windows.

我使用Wamp服务器,这是在Windows上安装和配置Apache,MySQL和PHP的一种很好的方式,没有任何麻烦。

If you want to use Postgres instead, provided that you've got it installed separately it will work fine. (one great thing you can do with Wamp is add and remove PHP extensions via a GUI pretty much on-the-fly, and pgsql is one of them).

如果你想使用Postgres,只要你已经单独安装它就可以正常工作。 (你可以用Wamp做的一件好事就是通过GUI添加和删除PHP扩展,而且pgsql就是其中之一)。

#4


0  

Maybe somebody can help, but you'd be much better off if you'd provide some relevant details.

也许有人可以提供帮助,但如果你提供一些相关的细节,你会好得多。

What sort of system are you using? Be specific.

你使用什么样的系统?请明确点。

What do you mean by "everything up and running"?

“一切正常运行”是什么意思?

What are you doing when you "try to run a script"?

当你“尝试运行脚本”时你在做什么?

What installation procedures did you use? (If you were following them off a script or how-to, we at least need to know where to find the script or how-to.)

你使用了什么安装程序? (如果您关注脚本或操作方法,我们至少需要知道在哪里找到脚本或操作方法。)

We don't automatically know these things. What seems obvious to you may not be clear to us, and what seems irrelevant to you may turn out to be crucial.

我们不会自动了解这些事情。对你来说似乎显而易见的可能对我们来说并不清楚,与你无关的东西可能变得至关重要。

#5


0  

In httpd.conf, make sure the PHP module is being loaded and that that line isn't commented out. (Comments in httpd.conf starts with #.)

在httpd.conf中,确保正在加载PHP模块,并且该行未被注释掉。 (httpd.conf中的注释以#开头。)

Also what OS are you running?

你还运行什么操作系统?

#6


0  

I had the same problem, You need to configure apache and add the php module... e.g I compiled the php from source as well as the apache. After doing so I then copied the libphp5.so from php/lib dir in to the apache/modules dir. Than you have to add php in the http.conf

我有同样的问题,你需要配置apache并添加php模块...例如我从源代码和apache编译php。在这之后我将libphp5.so从php / lib目录复制到apache / modules目录。比你必须在http.conf中添加php

LoadModule php5_module modules/libphp5.so

LoadModule php5_module modules / libphp5.so

AddHandler php5-script php

AddHandler php5脚本php

you can then restart apache....it's not the most elegant of solutions but it works.

然后你可以重新启动apache ....它不是最优雅的解决方案,但它的工作原理。