Solved

PHP in Apache server

Posted on 2016-08-12
20
117 Views
Last Modified: 2016-08-16
Hi,
I want to configure PHP with Apache server, on Windows 2008 server. Is there a demonstration with details to this?
0
Comment
Question by:HuaMinChen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
20 Comments
 
LVL 36

Expert Comment

by:Kimputer
ID: 41753562
It's all explained nicely here: http://php.net/manual/en/install.windows.legacy.index.php#install.windows.legacy.apache2
Don't skip the note on that page (which has another link there, not here):
Note:
You should read the manual installation steps first!
0
 
LVL 58

Assisted Solution

by:Julian Hansen
Julian Hansen earned 500 total points
ID: 41753575
This describes installation of PHP 5.6.24 on Apache 2.4 (Windows Thread safe version)

This is the process I followed

1. Install PHP (thread safe) version - this will extract to a folder

2. Modify your httpd.conf
Add the following reference to the php5apache2_4.dll
LoadModule php5_module "C:\Program Files (x86)\PHP 5.6.24\php5apache2_4.dll"

Open in new window

This goes after the last LoadModule line in the conf file. Modify path to match your environment

3. Modify the default file values - add index.php (on or around line 280 - might vary depending on your installation)

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

Open in new window


4. Add php handler and set path to PHP ini file
<IfModule php5_module>
  AddHandler application/x-httpd-php .php
  PHPIniDir "C:\Program Files (x86)\PHP 5.6.24"
</IfModule>

Open in new window

Change the path to your PHP INI file
I added this at the bottom after the following
<IfModule mime_module>
...
</ifModule>

Open in new window


Save and restart the httpd service.

The above assumes you have already configured your PHP ini file.
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 41753614
Depending on your exact needs, you may find that a virtual machine can save you a lot of time.  I've had good experiences with the prepackaged Bitnami stacks.
https://bitnami.com/stacks
0
Database Solutions Engineer FAQs

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller single-server environments.

 
LVL 11

Author Comment

by:HuaMinChen
ID: 41755923
Many thanks all.
Julian,

What should I put, right after

<IfModule mime_module>
...
</ifModule>

Open in new window


And I've created relevant Inbound rule on port 8080, but I've got

C:\setup\Apache httpd-2.4.23-x86-vc14\Apache24\bin>httpd
(OS 10048)Only one usage of each socket address (protocol/network address/port)
is normally permitted.  : AH00072: make_sock: could not bind to address [::]:808
0
(OS 10048)Only one usage of each socket address (protocol/network address/port)
is normally permitted.  : AH00072: make_sock: could not bind to address 0.0.0.0:
8080
AH00451: no listening sockets available, shutting down
AH00015: Unable to open logs

Open in new window

0
 
LVL 58

Assisted Solution

by:Julian Hansen
Julian Hansen earned 500 total points
ID: 41755966
What should I put, right after
This - I was trying to say I put the following code directly after the <IfModule mime_module>...</ifModule>
<IfModule php5_module>
  AddHandler application/x-httpd-php .php
  PHPIniDir "C:\Program Files (x86)\PHP 5.6.24"
</IfModule>

Open in new window


The error is telling you you have another service listening on 8080 - try a different port for Apache.

It sounds like the server you are setting this up on already has a web server running on it - IIS most likely. What is the reason for installing Apache as well?
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 41755980
I choose port 8081 and get
C:\setup\Apache httpd-2.4.23-x86-vc14\Apache24\bin>httpd
(OS 10048)Only one usage of each socket address (protocol/network address/port)
is normally permitted.  : AH00072: make_sock: could not bind to address [::]:443

(OS 10048)Only one usage of each socket address (protocol/network address/port)
is normally permitted.  : AH00072: make_sock: could not bind to address 0.0.0.0:
443
AH00451: no listening sockets available, shutting down
AH00015: Unable to open logs

Open in new window

Yes, IIS is running on this server
0
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 41756019
443 is the SSL port - this means that something (probably IIS) is using that port as well.

You should still be able to browse to

http://yourservername:8081

As Apache appears to be successfully listening on that port.

Again I ask why you need Apache on the same server as one running IIS?
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 41756026
To your last question, I do 're-use' the same server, for further deploying PHP pages by Apache. What to adjust, due to current 443 port conflict?
0
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 41756035
Why not load PHP on IIS - why set them both up on the server when it is just going to result in conflict.

What to adjust, due to current 443 port conflict?
This is not the right question - you can either ignore the error - if you are not going to use SSL - if you are and you are also using SSL on the IIS server then you don't have a solution - hence my original question about why you want to run two HTTP servers on a single box.

Why can you not use IIS to do what you want to?
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 41756130
I now use one Win 2012 server instead, which is not running any Web server. I get no response to this

C:\setup\Apache httpd-2.4.23-x86-vc14\Apache24\bin>httpd

why?
0
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 41756146
Are we starting from the begining now?

I have no idea why you are getting no response on Win2012 - you have not provided enough information to say what you have done.

You can Google the process I did and found this link
http://lifeofageekadmin.com/how-to-install-apache-2-4-mysql-and-php-on-windows-server-2012/

But if that does not go anywhere I am certain that there are other similar resources online that can take you through the process.

Maybe follow that and post back any specific issues you come across - the more information you provide the more we will be able to assist.

Given the parameters of the question have changed somewhat - you might want to consider closing this question off (if you don't succeed with the above) and opening another to get access to more experts. This thread has become TLDR which means your new issue will not be seen by anyone new to this thread.
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 41757304
Yes, I'm re-doing the same within Win 2012.

I've un-zipped these
Apache httpd-2.4.23-x86-vc14
php-5.6.24-Win32-VC11-x86

Open in new window

into c:\setup and then run

cd C:\setup\Apache httpd-2.4.23-x86-vc14\Apache24\bin
httpd

Open in new window

and have got no response.
0
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 41757411
Is there anything in the logs?

Did you follow the steps in the link I posted?
0
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 41757413
When you say there is nothing - do you mean
a) The command prompt returns immediately with nothing displayed on the screen

OR

b) The command prompt does NOT return and there is nothing on the screen.

If there are no errors then Apache will start and you won't see anything displayed on the screen. See screenshot below
 Screenshothttpd is running - no output but the prompt has not returned - this is because httpd is successfully running in the foreground.

After running httpd - can you browse to the server from the server - on the SAME port you have configured in your httpd.conf
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 41757445
Within Windows, how to ensure relevant folder is pathed, and files can be picked up by server, when I call the relevant PHP file like

http://localhostname/PHPfile
0
 
LVL 58

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 41757476
The PHP file needs to be in the ServerRoot
OR
You can setup an alias to another folder

For example - if you want to setup a project
http://localhostname/myproject/index.php
Then in your httpd.conf you create an alias entry like so
<IfModule alias_module>
...
  Alias /myproject "C:/projects/myproject"
...
  <Directory "C:/projects">
    Options Indexes FollowSymLinks MultiViews ExecCGI
    AllowOverride All
	Require all granted
  </Directory>  
...
</ifModule>

Open in new window

0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 41757619
Many thanks.
I've created the relevant alias for the folder inside which the .php file resides. But I cannot go to

http://win-q1a2sh6377h:8080/proj0/info5.php

while win-q1a2sh6377h is the server name. Here is what I've got
6p.png
0
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 41757653
Need to see your httpd.conf file.
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 41758078
Hi Julian,
I sent you the file already.
0
 
LVL 58

Assisted Solution

by:Julian Hansen
Julian Hansen earned 500 total points
ID: 41758119
I took your httpd.conf - changed the servername and paths and it works fine here so the configuration is correct.

Have you configured your PHP.ini file for your server.

What happens when you browse to

http://localhost:8080/proj0

Can you create the following file
pi.php
<?php
phpinfo();

Open in new window

And save this to
c:\setup\proj0\pi.php

Open in new window

And then attempt to go to
http://localhost:8080/proj0/pi.php

Open in new window

What do you see.
0

Featured Post

How To Install Bash on Windows 10

Windows’ budding partnership with Canonical has certainly led to some great improvements. One of them being the ability to use Bash on your Windows machine without third party applications! This might be one of the greatest things a cloud engineer in a Windows environment can do!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For anyone that has accidentally used newSID with Server 2008 R2 (like I did) and hasn't been able to get the server running again because you were unlucky (as I was) and had no backups - I was able to get things working by doing a Registry Hive rec…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question