简体   繁体   English

使用PHP设置本地服务器

[英]Setting up local server with PHP

I'm trying to setup an Apache/PHP/Postgresql server locally on my machine. 我正在尝试在我的计算机上本地设置Apache / PHP / Postgresql服务器。 I'm using Windows vista business 32bit. 我正在使用Windows Vista Vista 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,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?" 每当我尝试在计算机上运行脚本时,都会收到“您想对* .php文件做什么?”。 dialog. 对话。 The dialog is the browser's open/save dialog 该对话框是浏览器的打开/保存对话框

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. 我已经尝试过弄乱Apache conf文件,但是由于我对自己的工作并不了解,因此我再次重新安装了所有内容,问题仍然存在。 I kinda get the feeling it must have something to do with the PHP thingy isn't correctly installed. 我有点感觉它必须与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文件的浏览器“打开/保存”对话框。

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

You can also have a look at the official page of PHP in the install section . 您也可以在install部分中查看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。

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. 如果您想改用Postgres,只要您将其单独安装,它将可以正常工作。 (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). (使用Wamp可以做的一件很棒的事情是通过GUI实时添加和删除PHP扩展,而pgsql是其中之一)。

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. 对您而言显而易见的事情可能对我们而言尚不清楚,而与您无关的事情可能变得至关重要。

In httpd.conf, make sure the PHP module is being loaded and that that line isn't commented out. 在httpd.conf中,确保已加载PHP模块,并且该行未被注释掉。 (Comments in httpd.conf starts with #.) (httpd.conf中的注释以#开头。)

Also what OS are you running? 您还在运行什么操作系统?

I had the same problem, You need to configure apache and add the php module... eg I compiled the php from source as well as the apache. 我有同样的问题,您需要配置apache并添加php模块...例如,我从源代码以及apache编译了php。 After doing so I then copied the libphp5.so from php/lib dir in to the apache/modules dir. 之后,我将libphp5.so从php / lib目录复制到apache / modules目录中。 Than you have to add php in the http.conf 比您必须在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...。这不是最优雅的解决方案,但它可以工作。

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

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