[EVERYTHING WORKS NOW!]
MY SOLUTION:
The first mistake i made, was simply, that i had some random 32bit version of PHP installed, and some random 64bit version of Apache! After that, i just downloaded the latest version of PHP, and put it in my c:\php folder, THEN downloaded the LATEST version of the VC14 version of Apache, from the apachelounge website (VC14 category on the left side on the website). And the last mistake was, that i had the W3SVC from IIS still running, so i stopped that one under services (search in windows for services.msc)! And yeah, thats it, all solved now!
So, i have a problem, i installed Apache recently, and set up a working webserver!
This all worked fine, my whole website works flawlessly, and its fully usable!
BUT, all of my php scripts did NOT work, when loading one on the website, apache just show the entire source code of the .php file, instead of displaying it like an html page!
So, i noticed, i do not have PHP configured with my apache server!
What i then did, was download php, put it in c:\php, configure the php.ini, and all of that works, i know because in IIS 10, my website worked perfectly fine with PHP!
so i installed php, for apache 2.4, the VS11 version, the same goes for apache, (i did that because the latest versions of both did not work for me, i had the same problem)!
and as soon as i do the last step,
add these lines to my httpd.conf (inside my apache folder):
LoadModule php5_module "c:/php/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
PHPIniDir " C:/php"
, when i want to start the apache server, it just tells me this:
"The requested operation has failed."
(this happens when i select the service of my server in the Apache-Monitor, and click on "start)
(NO error log is beeing created from apache, nothing inside the error nor log folder (both configure in the httpd.conf))
only CMD gives me the following erro:
httpd: Syntax error on line 533 of C:/Apache24/conf/httpd.conf: Cannot
load c:/php/php5apache2_4.dll into server: %1 is not a valid Win32
application.
Now, as soon as i remove these 3 lines from my httpd.conf, the server works perfectly fine again, can be started, and the website is usable, except, all php pages do not work(of course).
i heard something about a "libphp5.so", i do not know if it has anything to do with neither my apache server, nor my whole problem, but i don't know, atleast i have no such thing in my "C:\Apache24" folder!
SOME INFORMATION THAT MIGHT BE IMPORTANT:
All this is hosted from a normal PC (Windows 10) (64 Bit), 32GB RAM, 8x4GHz processor etc..!
yes, i have added c:\php to my Path environment variable! (as said before, all is working if i do not add these lines, which according to google results, are necessary to get php to work with apache)!
If anyone knows what to do, id be so glad, because i do not want to keep using IIS (its good but..), as i could do definitely more with Apache!
Read the manual carefully. Reinstall apache and use PHP 5.6. unless you are ready to fix issues that come with PHP 7.1. Notice Do NOT use VC11+ versions of PHP with the apache.org binaries. This is taken from PHP.net
Apache:
Please use the Apache builds provided by Apache Lounge. They
provide VC11, VC14 and VC15 builds of Apache for x86 and x64. We use
their binaries to build the Apache SAPIs.
If you are using PHP as module with Apache builds from apache.org (not
recommended) you need to use the older VC6 versions of PHP compiled
with the legacy Visual Studio 6 compiler. Do NOT use VC11+ versions of
PHP with the apache.org binaries.
With Apache you have to use the Thread Safe (TS) versions of PHP.
VC11, VC14 & VC15 More recent versions of PHP are built with VC11,
VC14 or VC15 (Visual Studio 2012, 2015 or 2017 compiler respectively)
and include improvements in performance and stability.
The VC11 builds require to have the Visual C++ Redistributable for Visual Studio 2012 x86 or x64 installed
The VC14 builds require to have the Visual C++ Redistributable for Visual Studio 2015 x86 or x64 installed
The VC15 builds require to have the Visual C++ Redistributable for Visual Studio 2017 x64 or x86 installed
TS and NTS TS refers to multithread capable builds. NTS refers to
single thread only builds. Use case for TS binaries involves
interaction with a multithreaded SAPI and PHP loaded as a module into
a web server. For NTS binaries the widespread use case is interaction
with a web server through the FastCGI protocol, utilizing no
multithreading (but also for example CLI).
Source: PHP.NET Manual
Make sure Apache2 and PHP binaries have the same:
Visual Studio C++ binary compatibility version
(Visual Studio C++ 2015 = VC14, Visual Studio C++ 2017 = VC15)
system architecture: 32bit(win32) / 64bit(win64)
for example:
php-7.3.15RC1-Win32-VC15-x86
be sure u have:
httpd-2.4.41-win32-VC15
best place to download Apache 2 binaries for Windows is Apache Lounge
(on Top Left corner you control the VC version):
https://www.apachelounge.com/download/VC15/
and to download PHP binaries also mind that with Apache you have to use the Thread Safe (TS) versions of PHP. go here:
https://windows.php.net/qa/
do not forget to add (System Variables) PATH for php,
open cmd As Administrator and type:
setx path "%PATH%, C:\php73" /M
Related
I just upgraded my OS to Windows 10 and I have an atypical problem.
I use WAMP server and PHP doesn't work, although no error is displayed anywhere.
I tried to update vcredist or to change ports, but the problem persists.
Windows 10 does not come with all the older MSVC Runtimes installed.
You will also have to install any of these that are missing.
Microsoft Visual C/C++ Redistributable 2008 (VC9)
32bit /
64bit
Microsoft Visual C/C++ Redistributable 2010 (VC10)
32bit /
64bit
Microsoft Visual C/C++ Redistributable 2012 (VC11)
32bit & 64bit selectable on this page
Microsoft Visual C/C++ Redistributable 2013 (VC13)
32bit & 64bit selectable on this page
Microsoft Visual C/C++ Redistributable 2015 Update 1 (VC14)
32bit & 64bit selectable on this page
VC15 Redistribuable (Visual C++ 2017)
Visual C++ Redistributable Packages for Visual Studio 2017 x86
Visual C++ Redistributable Packages for Visual Studio 2017 x64
VC2017 (VC15) is backward compatible to VC2015 (VC14). That means, a VC14 module can be used inside a VC15 binary. Because this compatibility the version number of the Redistributable is 14.1x.xx and after you install the Redistributable VC2017, VC2015 is removed but you can still use VC14.
UPDATE April 2017
Most of the MSVC runtimes are now available from this microsoft page
Which versions of the above you actually need to run WAMPServer, or rather Aapche, will depend upon the version of WAMPServer you are running, but installing all of them can do no harm as they are used by any software that has been compiled with the Microsoft compilers.
If you are using WAMPServer 64bit on Windows 10 64bit, you will need to install BOTH the 32 and 64bit versions of these libraries.
After you have checked you have all the runtime libraries, you may also need to re-install the Apache and MYSQL services as the upgrade to Windows 10 unfortunately sometimes (pretty much always) misses the fact that you have 2 services running that should be replaced after the upgrade i.e. wampapache and wampmysqld
All you need to do is, using the wampmanager menus system do this :
left click wampmanager -> Apache -> Services -> Install Service
left click wampmanager -> MySQL -> Services -> Install Service
Then
left click wampmanager -> Start All Services
Additional info
Also remember that for PHP to be interpreted, the code must exist in a file with a .php extension. If you are using notepad as an editor, that will add a .txt to a filename, so if you save tst.php it will actually get saved as tst.php.txt and therefore will not run. Get a decent editor notepad++ will do a great job and is free.
Also files with the .html or .htm that contain php code will not execute the php code as these files are not passed to the PHP interpreter, because they dont have the .php extension.
Using Explorer
Dont double click on the script file name in Windows Explorer. This works to test pure HTML pages, or HTML + Javascript pages, but it does not work if the page has PHP code in it However doing this does not go via Apache, and it is Apache that see's the <?php tags and therefore know to pass this code to the PHP interpreter.
You must enter the script file name into the browser address bar, as if it were a real web site, because of course it is
For example localhost/project1/test.php
I faced the problem and solved it by installing
Microsoft Visual C/C++ Redistributable 2010 (VC10), both 32bit / 64bit as 2008 and 2012 were already installed.
My configuration: windows 10 64 bit, wampserver 64 bit.
One of the problem could be Skype running at the time you want to start your server, so you can
Stop SKYPE because SKYPE utilize port 80 and server wants to use same port.
Go to httpd.conf file and change the Port number from 80 to 8000/8080.
-Left click Apache icon,
-Go to Apache and open httpd.conf file,
-Search and replace port 80 to 8000 / 8080
-Save & close,
-Restart the server again.
Update: Wamp working with Windows 10 in 2020
You can try this, I done the following things.
Install msvcp140.dll
Install Microsoft Visual C/C++ Redistributable
Install wamp server
Close Skype (Chat App) if it is running
But wamp icon did not change its color to orange to green. (turning wamp icon orange to green means it start working). I installed wamp multiple time to make it color orange to green but it still show orange color. But actually, behind the scene it was working I checked it in browser by URL: http://localhost/phpmyadmin/
I am using magic library to change the resolution of the images. But I am getting following error when I am running the Wamp.
I am also sharing links of the website I have followed.
Link
http://www.zoharbabin.com/5-steps-to-get-imagemagick-on-xampp-1-7-3/
These are step by step instructions on how to get ImageMagick running under PHP in a Windows environment. Apache does not provide binaries for Windows and relies upon several sources to do so:
XAMPP
WampServer
Apache Lounge
Bitnami
Apache Haus
It is recommended to download either the XAMPP or WampServer distributions as they are complete packages that contain Apache HTTP server, PHP and MySql known and tested to work together.
Making ImageMagick work was not easy for me. It took two days of trial and error to get this to work. Hopefully this will help you get up and running faster. I have this running on the following:
Windows 7 Home Edition 64-bit
XAMPP 5.6.3
Apache HTTP 2.4.10 (Win32), VC 11
PHP 5.6.3 x86 VC 11, Thread safe
Thus, a 32-bit web framework compiled with VC 11 and thread safety enabled all running on 64-bit Windows 7. You must choose a 32-bit ImageMagick DLL distribution along with a 32-bit VC11 thread safe DLL wrapper to match.
The instructions below should work equally well with WampServer as there is no dependency on the Windows web framework.
The important thing to understand here is that you must know your web server environment and what components are installed and built with. you must match bitness, Visual C runtime, and thread safety configurations together.
Step #1: Install imageMagick to C:\ImageMagick
Go to Link and download the latest release. Use the 32 bit DLL version (ImageMagick-6.9.0.0-Q16-x86-dll.exe)
Install it into C:\ImageMagick directory
Step #2: Get the PHP wrapper from the Windows PECL repository
Go to http://pecl.php.net/package/imagick
Get the latest stable version, 3.1.2. You want the 32-bit, VC 11, thread safe version
php_imagick-3.1.2-5.6-ts-vc11-x86.zip
Step #3: Create distribution directory
Create a /php/ext/imagemagick directory
Copy the ZIP into it and unzip it
Step #4: Make backup copy of DLLs
Make a C:\ImageMagick\Backup directory
Copy DLLs in the C:\ImageMagick directory to the C:\ImageMagick\Backup directory
Step #5: Overwrite DLLs
This is the most important step that if you don't do, will result in the PHP wrapper not loading correctly:
Take all the DLL files in \php\ext\ImageMagick and overwrite those in C:\ImageMagick
If you do a SET on the DOS command line you will see that the ImageMagick installer had created a entry into the system variable environment path (i.e. to C:\ImageMagick). Supporting DLLs will be picked up from there and they will be the Pecl Windows repository DLLs, not the distribution.
Step #6: Set module extension in PHP.INI
First, copy the php extension wrapper php_imagick.dll into the /php/ext directory. Then modify the PHP.INI to do this:
extension=php_imagick.dll
Step #7: Reboot Apache
Reboot Apache
Go to phpinfo and see that imagick is installed as a module.
Here's where you can learn more about your environment.
Pay attention to stuff in phpinfo like:
Compiler: MSVC11 (Visual C++ 2012)
Architecture: x86 (32 bit; as opposed to x64 which is 64 bit)
Thread safety: enabled (TS)
Apache Environment Configuration (PATH should have C:\ImageMagick included)
More gory details: Installing ImageMagick with PHP and Windows
I wanted to install Apache and PHP without using xampp. Apache is working fine. When i type localhost in my browser it shows "It works!" but when i try to install PHP, i get always this error:
"apache 2.2.4 cannot load php5apache2_4.dll into server: %1 is not a Win32-executable" (or something like this. Ive got a german version of the error)
I have windows 7 64bit. I re and installed multiple times but nothing changed.
In my config i have this.
LoadModule php5_module "c:/php-5/php5apache2_4.dll"
Got anyone an idea?
Apache Version is 2.2.4 and Php5.6
I used to have the same probleme so I switch to a Virtual Machine on Unix. My Probleme was here :
http://windows.php.net/download/
Apache Please use the Apache builds provided by Apache Lounge. They
also provide VC11 builds of Apache for x86 and x64. We use their
binaries to build the Apache SAPIs.
If you are using PHP with Apache 1 or Apache2 from apache.org (not
recommended) you need to use the older VC6 versions of PHP compiled
with the legacy Visual Studio 6 compiler. Do NOT use VC9+ versions of
PHP with the apache.org binaries.
With Apache you have to use the Thread Safe (TS) versions of PHP.
I wanted to post this as a comment but it was to long.
I'm trying to integrate php on Apache. Following is the versions I'm using
Apache 2.4 (httpd-2.0.64-win32-x86-openssl-0.9.8o)
PHP (php-5.5.0-Win32-VC11-x64.zip)
I'm setting this on a 64 bit windows 7 machine. I have made the configurations as per this, but I'm getting the following error even though I have place the dll in the specified folder.
Cannot load C:/php/php5apache2_4.dll into server: The specified
module could not be found.
The httpd.conf line entry is this
LoadModule php5_module "C:/php/php5apache2_4.dll"
Is there any version compatible issues?
The only way I've been able to get PHP (5.5) to work with Apache (2.4) on Windows (7 and 8) is to make sure Apache and PHP are both either 32-bit (x86) or 64-bit (x64) and that Apache and PHP are both Thread Safe (TS). Using Non-Thread Safe (NTS) did not work for me (or others), and the Thread Safe build comes bundled with the needed Apache Module for PHP "php5apache2_4.dll". Once all my bit-depths and thread safety was matched up, Apache 2.4 and PHP 5.5 work well together on my Windows systems.
Both products must also have been compiled using the same major versions of Microsoft Visual Studio/C++, such as VC6 (the legacy VC++ compiler), VC9=Studio 2008, or VC11=Studio 2012. For the above Apache versions, only VC9 or VC11 are commonly used.
Links:
Get Windows Apache binaries here:
http://www.apachelounge.com/download/
Get Windows PHP binaries here:
http://windows.php.net/download/
Install the Visual C++ Redistributable compiler runtime library for the specific Visual Studio version used to prepare both Apache and PHP for Windows:
2012: http://www.microsoft.com/en-us/download/details.aspx?id=30679
2008: http://www.microsoft.com/en-us/download/details.aspx?id=5582
You are right Marty, they work only if both are either 32bit or 64 bit. I used XAMPP- Apache's distributed installation to resolve this issue.
Apache win 32 with 64 bits its the problem, you need Apache64
I am trying to install PHP 5 on a Windows Server 2003 environment with IIS 6
After installing PHP, and making the necessary changes in IIS, I get the following error
%1 is not a valid Win32 application.
The server is not 64bit, it is 32bit. I have added the FastCGI
handler in Web Service Extensions,
I have added the PHP handler in
Web Service Extensions, I have also gone to "Web Sites Properties"
and clicked on Configuration: and set the appropriate mappings,
I've installed the reditrubition files as required by Microsoft...
I cannot for the life of me work out why it is not working.
Can someone please help?!
Finally got my installation working by installing the correct corresponding versions and dependencies. I hope this helps.
On IIS 6
PHP 5.4
VC9 x86 or x64
WinCache 1.3 for PHP 5.4
On IIS 7
PHP 5.5
VC11 x86 or x64
WinCache 1.3 for PHP 5.5
Try running PHP directly from command line to see if you receive the same error. If it is, the issue may be that a dependency cannot be found. PHP has a dependency on the Visual C++ Redistributable - from http://windows.php.net/download/ :
The VC9 builds require you to have the Visual C++ Redistributable for Visual Studio 2008 SP1 x86 or x64 installed.
The VC11 builds require to have the Visual C++ Redistributable for Visual Studio 2012 x86 or x64 installed.
if this doesn't help, run the Microsoft utility Depends.exe from http://www.dependencywalker.com/ to find out what might be the issue.
in System Properties > Environment Variables click on new in variable name = path and variable value = C:\wamp\bin\php\php5.3.13; and click on ok > ok > ok
click on run type cmd
in cmd type php
if you get up error in cmd type cd c:\ and enter now type php
I have faced the same issue on standalone Apache+PHP setup on Windows 10. Definitely the problem was in two different PHPs in the environment variable PATH (IIS distro and standalone distro). Removing the PHP for IIS from the PATH resolved the problem.
Unfortunately PHP only goes as far as 5.4 on Windows 2003. They officially dropped support for Windows XP and 2003 starting PHP 5.5.0.
http://windows.php.net
Here you can find PHP for older Windows systems: PHP 5.5.7, 5.4.23, 5.3.28 (x86/x64) available
Following binaries are available:
php-5.5.7-nts-Win32-VC11-x86.zip
php-5.5.7-Win32-VC11-x86.zip
php-5.5.7-nts-Win32-VC11-x64.zip
php-5.5.7-Win32-VC11-x64.zip
php-5.4.23-nts-Win32-VC9-x86.zip
php-5.4.23-Win32-VC9-x86.zip
php-5.4.23-nts-Win32-VC9-x64.zip
php-5.4.23-Win32-VC9-x64.zip
php-5.3.28-nts-Win32-VC9-x86.zip
php-5.3.28-Win32-VC9-x86.zip
php-5.3.28-nts-Win32-VC9-x64.zip
php-5.3.28-Win32-VC9-x64.zip
For "FastCGI" on Windows Server 2003, you should choose php-5.4.23-nts-Win32-VC9-x86.zip.