installing PHP on Apache 2.2 on Windows 7 - php

I had my Apache 2.2 installed on windows. Now I just finished installing PHP on the Apache server. As the instruction says, I need to edit the httpd.conf of my Apache and add:
#
LoadModule php5_module "G:\Program Files\PHP\php5apache2_2.dll"
AddHandler application/x-httpd-php .php
PHPIniDir "G:\Program Files\PHP"
I made sure the directory is correct. Then I restart my server again. I have a hello.php file in my htdocs. And I navigate to localhost:8080/hello.php and it says server not found, however when I do index.html. It display's the html correctly on the htdocs folder.
What am I doing wrong here? I tried to debug this by trying to execute hello.php from the command line by executing G:\Program Files\PHP\php-cgi hello.php, but then it says:
'G:\Program is not recognized as internal or external command.....

You can use some this like XAMPP its easy to configuration.

Related

windows could not start the apache http server on local computer

In order to download PHPMyAdmin, I have to download its Prerequisites i.e apache & for apache Microsoft Visual Studio C++ 2019 than MySQL than PHP, and right after installing apache I run 'httpd' in cmd, http.exe file couldn't be opened but when I tried to open a browser and type localhost on address bar I received msg "it works!" and then when I start installing PHP I edit below lines in httpd.conf
index.php right after index.html &
LoadModule php7_module C:/php/php7apache2_4.dll
<IfModule php7_module>
AddHandler application/x-httpd-php .php
PHPIniDir "C:/php"
</IfModule>
and than i tried to start apache HTTP server from windows service but its showing the below error and then to resolve it I somehow got to know about XAMPP further I download XAMPP too with a little changes in ports it also starts apache 2.4 and MySQL but still not the APACHE HTTP SERVER

Apache/PHP on Windows 8

I'm having trouble with Apache/PHP on Windows 8. I have previously been using them on XP (along with MySQL) with no problems. I never used Windows 7.
Apache installs without issues. Everything works OK, including all my virtual servers.
PHP installs OK, the installation puts entries into httpd.conf without giving errors.
However, when I try to load Apache after installing PHP, Apache won't load.
I'm confused by the error that Apache returns when the PHP entries are included in httpd.conf:
Syntax error on line 1029 of C:/Program Files/Apache Group/Apache2/conf/httpd.conf:
Cannot load C:/Program Files/PHP/php5apache2_2.dll into server: The specified module could not be found.
The lines are:
#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
PHPIniDir "C:\Program Files\PHP\"
LoadModule php5_module "C:\Program Files\PHP\php5apache2_2.dll"
#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
(line 1029 is the LoadModule line).
That location for the dll is definitely correct. The syntax of the line is as inserted by PHP. I have compared the syntax to previous versions of httpd.conf that I have and it appears correct. I think the syntax error is a red herring.
I have tried:
Switching backslashes to slashes in the dll location.
Adding PHP to the path.
Installing Apache and PHP in both sequences.
Checking the permissions to the PHP folder and the individual files
to ensure that SYSTEM has read/execute.
Comment out the PHP lines and Apache loads fine. If I comment out the LoadModule line and and just leave the PHPIniDir line, it still fails. Apache seems to be behaving as though it can't see the PHP directory, but I can't work out why.
There is nothing on the Windows event log. Latest versions of PHP and Apache. I'm at a bit of a loss what to try next. Any suggestions please?
Download and follow instructions from this link:
http://www.apachelounge.com/download/
The latest download (2.4) works on Windows 8 and Server 2012.
I downloaded and tested with the following on Windows 8:
Each zip has a readme.txt or install.txt with instructions.
Apache 2.4
http://www.apachelounge.com/download/win32/binaries/httpd-2.4.3-win32.zip
PHP 5.4.8
http://windows.php.net/downloads/releases/php-5.4.8-Win32-VC9-x86.zip
PHP 5.4.8 handler for Apache
http://www.apachelounge.com/download/win32/modules-2.4/php5apache2_4.dll-php-5.4-win32.zip
My httpd.conf lines that were added/modified were:
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php5_module "C:/Apache24/php-5.4.8/php5apache2_4.dll"
LoadFile "C:/Apache24/php-5.4.8/php5ts.dll"
PHPIniDir "C:/Apache24/php-5.4.8"
<IfModule php5_module>
<Location />
AddType text/html .php
AddHandler application/x-httpd-php .php
#AddHandler application/x-httpd-php-source .phps
</Location>
</IfModule>
Its mentioned in the Readme.txt file packed with the dll's at ApacheLounge, but not anywhere else on the download page or in the filename (as all other versions):
"Runs with PHP 5.4 Thread Safe (TS), and only with Apache 2.4 Win32 VC9 or VC10"
The dlls are only for the TS version, so if you've downloaded the other one, you are basically screwed. TS php binaries fixed it for me.
GL.
Presuming this is your development, not deployment environment, why don't you just download xampp from apache friends? It should come preconfigured, and you will deploy in other setup anyway.
I ran into the similar issue when reinstalling Apache and PHP on Win 8 (I am more Linux user though). And similar to the original post, no matter what I tried to do in httpd.conf and php.ini Apache simply either did not start or did not see the PHP. After spending unreasonable amount of time, I decided to download the PHP 5.3 (5.3.27)-VC9 x86 Thread Safe (2013-Jul-10 21:56:58) Installer [45.86MB] instead of the non-tread safe version which I have been using before. There is a difference in the .msi installers. The one for the thread-safe version actually contains the required files and if you follow the installer prompts it will actually asks you if the php installation should be "linked" to Apache server. Then you just provide the hhtpd.conf directory and all works fine. Thats my 2c on this :)
I think the problem is in the blank "Program Files".

configuring apache 2.2 for php5.2/5.3 module on Win Server 2008

I'm trying to configure apache 2.2 for php 5.2 (or preferably 5.3, but php.net seems to say not to) on Windows Server 2008.
C:\Apache2.2\
C:\php\v5.2\
Apache is running fine before I add this to httpd.conf
LoadModule php5_module "C:/php/v5.2/php5apache2_2.dll"
AddHandler application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/php/v5.2/"
Then apache spits out this error when I try to restart it from cmd:
httpd.exe: Syntax error on line 129 of httpd.conf: Cannot load C:/php/v5.2/php5apache2_2.dll into server: The specified module could not be found.
It's definitely there!
I googled the error and found a lot of people complaining of it, but they're all for mistakes like referencing php5apache2.dll instead of php5apache2_2.dll.
EDIT: btw, when I use the installer, and it modifies httpd.conf for me, I still get the cannot find error during start up. wtf…
turns out the LoadModule […] has to go at the very end of httpd.conf. dunno why, but i moved it, and apache stopped complaining.

Trouble adding PHP modules to Apache 2.2 Server

I run a Windows 7 x64 machine with apache 2.2 and PHP 5.2.17
Whenever I try to add the PHP dll to the httpd.conf file, apache will not start.
this is how it is being put into httpd.conf
LoadModule php5_module "C:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/php"
I have successfully managed to setup and run a Apache server with PHP before, so I'm not new to this, but I'm fairly certain that this is right.
If everything that's being output on launch is the DNS error, Apache is launching just fine. FQDN resolution is a warning, not an error.

How to force php to work in my browser?

I just installed PHP on my computer (Ubuntu). If I create a test.php file with simple code and then run "php test.php", it works fine (I get what I expect).
However, when I open this file (test.php) with my browser (Mozilla) it asks me how to open this file. Not a problem. I click "open with" and then I select "/usr/bin/php" and... nothing happens. Browser does not display anything.
Can anybody help me with that? Why does my browser cannot display a local php-file using a local php server?
You need to install a web server (apache, lighttpd, ngnix etc.) on your machine, then make sure the server is setup to process php files through the php interpreter. After you have done all that, copy the php files to your server web root directory and access them through the browser.
XAMPP is probably the easiest way to get a development environment up and running.
Here is forum article on getting it running on Ubuntu.
Do you have a web server installed also?
This will install a full LAMP stack on Ubuntu.
sudo tasksel install lamp-server
But keep in mind this will launch Apache and MySQL daemons in the background.
To disable when you are not developing:
sudo /etc/init.d/apache stop; sudo /etc/init.d/mysql stop
When you are:
sudo /etc/init.d/apache start; sudo /etc/init.d/mysql start
You can make a macro in your favorite IDE to do this automatically.
Removing it is as easy as:
sudo tasksel remove lamp-server
Vertex
PHP through a browser will only work if you have php running as a webserver module (cgi, fcgi)
If you are on a regular linux distro you can probably apt-get emerge or zypper apache2 and the mod_php module from a repository. If you want to build from source, here is an small howto:
apache2php
If you're on *nix, try
locate httpd.conf
to find the apache configuration file. It should be somewhere like /etc/apache2/httpd.conf.
In the httpd.conf file, you need to do two things. First load the PHP module eg.
LoadModule php5_module libexec/apache2/libphp5.so
Then you also need a PHP file handler eg.
# PHP file handlers.
<IfModule php5_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
To test it's running OK, start apache with the .conf file as a parameter and load up a .php file that contains:
<?php
phpinfo();
?>
If PHP is running ok under apache, you should see a purple/white/black page listing all the settings currently in use.
See http://php.net/manual/en/configuration.changes.php for details of the myriad settings you can use.
Make sure you restart apache each and every time you change the .conf file!!!!

Categories