How can I change the port for localhost in PHP (Apache, Xamp

Problems with the Windows version of XAMPP, questions, comments, and anything related.

How can I change the port for localhost in PHP (Apache, Xamp

Postby chayacooper » 18. March 2015 00:46

I updated my version of PHP (by installing a newer version of XAMPP), but I'm having trouble getting the server to use the necessary port with PHP so that it will run the correct version of PHP.

Due to the well-documented conflicts for machines running Windows, I changed the Apache ports to 81 (from 80) in the httpd.conf file for: Listen and ServerName localhost. It appears to be running correctly. Both Apache and MySQL are running in the XAMPP Control Panel: Apache - Port: 81, 443; MySQL - Port: 3306 PHP ini was set to 3306, and I therefore left it as is.

http://localhost:81
shows that I'm running the correct version of PHP (Version 5.6.3)., however when I try navigating to it a through localhost:81 I receive the following error message:
Object not found! The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again. If you think this is a server error, please contact the webmaster. Error 404 localhost Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.6.3


The only way that it's allowing me to access the files is at http://localhost:2556, which is running an old version of PHP.

Any suggestions how I can get my PHP documents to access the proper port and version of PHP?
Last edited by chayacooper on 18. March 2015 21:11, edited 3 times in total.
chayacooper
 
Posts: 9
Joined: 18. March 2015 00:39
Location: NYC
Operating System: Windows 8.1

Re: How can I change the port for localhost in PHP (Apache,

Postby Altrea » 18. March 2015 01:19

What is the DocumentRoot path of your old Apache/PHP installation and what of your new XAMPP Apache?
PHP don't know any port differences
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8299
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: How can I change the port for localhost in PHP (Apache,

Postby chayacooper » 18. March 2015 16:41

@Altrea, I have 2 folders in the C: Drive ('Xampp', and 'Xampp2'), and each one has the folders 'Apache' and 'PHP'.
Altrea wrote:What is the DocumentRoot path of your old Apache/PHP installation and what of your new XAMPP Apache?
Last edited by chayacooper on 18. March 2015 21:26, edited 1 time in total.
chayacooper
 
Posts: 9
Joined: 18. March 2015 00:39
Location: NYC
Operating System: Windows 8.1

Re: How can I change the port for localhost in PHP (Apache,

Postby mark.mcdonald » 18. March 2015 16:54

After installing the new version, did you copy the documents over from assuming Xampp2 (aka old xampp) to Xampp (aka New Xampp version)? If you did not then this is why you are getting this error because they do not exist "Object not found!".
Did you reference the document via hardcode but the url to the document changed? Ex: <a href="http://localhost:81/Picture.png"></a> but is actually <a href="http://localhost:81/FolderName/Picture.png"></a>
Did you move the document in your site and forget to update any references to it (see previous line)?
mark.mcdonald
 
Posts: 160
Joined: 13. March 2015 15:48
Location: Edmonton
Operating System: Windows Server 2012 R2

Re: How can I change the port for localhost in PHP (Apache,

Postby chayacooper » 18. March 2015 17:57

@mark.mcdonald, Can you explain what you mean by copying the documents over from assuming the old Xampp version to assuming the new one? The documents are in a completely different folder (different ones for different web projects), so I'm not sure what/where exactly I would be copying them :-(
mark.mcdonald wrote:After installing the new version, did you copy the documents over from assuming Xampp2 (aka old xampp) to Xampp (aka New Xampp version)? If you did not then this is why you are getting this error because they do not exist "Object not found!".
Last edited by chayacooper on 18. March 2015 21:25, edited 1 time in total.
chayacooper
 
Posts: 9
Joined: 18. March 2015 00:39
Location: NYC
Operating System: Windows 8.1

Re: How can I change the port for localhost in PHP (Apache,

Postby Nobbie » 18. March 2015 18:42

chayacooper wrote:@mark.mcdonald, Can you explain what you mean by copying the documents over from assuming the old Xampp version to assuming the new one?


Copy from Xampp to Xampp2 or vice verse.
Nobbie
 
Posts: 8780
Joined: 09. March 2008 13:04

Re: How can I change the port for localhost in PHP (Apache,

Postby Altrea » 18. March 2015 19:04

Files you placed in \xampp\htdocs\ will not be requestable by default from xampp2 and vice versa.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8299
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: How can I change the port for localhost in PHP (Apache,

Postby chayacooper » 18. March 2015 19:22

I haven't placed any files in that subfolder (the only ones that are there are the ones that Xampp includes) :-( I'm simply trying to run PHP on my computer
Altrea wrote:Files you placed in \xampp\htdocs\ will not be requestable by default from xampp2 and vice versa.
Last edited by chayacooper on 18. March 2015 21:23, edited 1 time in total.
chayacooper
 
Posts: 9
Joined: 18. March 2015 00:39
Location: NYC
Operating System: Windows 8.1

Re: How can I change the port for localhost in PHP (Apache,

Postby mark.mcdonald » 18. March 2015 19:40

chayacooper wrote:http://localhost:81[/u] shows that I'm running the correct version of PHP (Version 5.6.3)., however when I try opening a file at localhost:81 I receive the following error message:
The only way it's allowing me to access the files is at http://localhost:2556, which is running an old version of PHP.

Apache uses port 80 so you can access your site through localhost / other.
MySQL hosts your database so you can store information.
PHP is called to execute functions from Apache or set limits for your site like not uploading more than 128mb at a time (PHP doesn't run like Apache and Mysql do. PHP doesn't run)
Joomla, Drupal, Wordpress take great advantage of what Xampp offers. Why are you trying to open PHP files through your localhost? If you need to open them, use wordpad or Notepad++ to modify the PHP files.
mark.mcdonald
 
Posts: 160
Joined: 13. March 2015 15:48
Location: Edmonton
Operating System: Windows Server 2012 R2

Re: How can I change the port for localhost in PHP (Apache,

Postby Nobbie » 18. March 2015 20:01

chayacooper wrote:I'm simply trying to run PHP on my computer


You cannot run PHP files via localhost if you do not put them into htdocs folder. It is very very hard to understand what you are doing there.
Nobbie
 
Posts: 8780
Joined: 09. March 2008 13:04

Re: How can I change the port for localhost in PHP (Apache,

Postby chayacooper » 18. March 2015 21:03

I'm assuming we may be using the terms slightly differently since I have been running PHP docs via Xampp for quite some time - I simply launch them in my browser :-(

The issue is that they're launching at http://localhost:2556, which is still running an old version of PHP (For example: http://localhost:2556/PHPPage7.php)

Nobbie wrote:You cannot run PHP files via localhost if you do not put them into htdocs folder. It is very very hard to understand what you are doing there.
chayacooper
 
Posts: 9
Joined: 18. March 2015 00:39
Location: NYC
Operating System: Windows 8.1

Re: How can I change the port for localhost in PHP (Apache,

Postby chayacooper » 18. March 2015 21:21

We may be using the terms slightly differently, so let me try and clarify things a bit -
I am trying to launch PHP files in my browser, using the version of PHP that comes with Xampp (in this case, Version 5.6.3). The issue is that version of PHP is running localhost:81 (I changed it because there are problems with port 80 not being available on machines running Windows), but the files don't seem to be able to reference it there :-( They're instead referencing an old version of PHP (at localhost:2556).

Is there something else that I need to do to tell it to run the new version of PHP?
mark.mcdonald wrote:Apache uses port 80 so you can access your site through localhost / other.
MySQL hosts your database so you can store information.
PHP is called to execute functions from Apache or set limits for your site like not uploading more than 128mb at a time (PHP doesn't run like Apache and Mysql do. PHP doesn't run)
Joomla, Drupal, Wordpress take great advantage of what Xampp offers. Why are you trying to open PHP files through your localhost? If you need to open them, use wordpad or Notepad++ to modify the PHP files.
chayacooper
 
Posts: 9
Joined: 18. March 2015 00:39
Location: NYC
Operating System: Windows 8.1

Re: How can I change the port for localhost in PHP (Apache,

Postby Altrea » 18. March 2015 21:55

Let me clearify too:
Ports are irrelevant. Each port is occupied by one specific process (here Apache).

Assuming
localhost:2556 is the started Apache from C:\xampp\ with DocumentRoot C:\xampp\htdocs\
and
localhost:81 is the started Apache from C:\xampp2\ with DocumentRoot C:\xampp2\htdocs\

Both DocumentRoot are independend from each other. Simply replacing the port in your URL doesn't result in requestable files from the other XAMPP installation. Each Apache only serves its own ressources.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8299
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: How can I change the port for localhost in PHP (Apache,

Postby chayacooper » 18. March 2015 23:09

That's what I would have assumed, however Apache in both Xampp and Xampp2 are set to use port 81 :-(

(As soon as I can get everything working properly I intend to remove the older Xampp folder.)
Altrea wrote:Let me clearify too:
Ports are irrelevant. Each port is occupied by one specific process (here Apache).

Assuming
localhost:2556 is the started Apache from C:\xampp\ with DocumentRoot C:\xampp\htdocs\
and
localhost:81 is the started Apache from C:\xampp2\ with DocumentRoot C:\xampp2\htdocs\

Both DocumentRoot are independend from each other. Simply replacing the port in your URL doesn't result in requestable files from the other XAMPP installation. Each Apache only serves its own ressources.
chayacooper
 
Posts: 9
Joined: 18. March 2015 00:39
Location: NYC
Operating System: Windows 8.1

Re: How can I change the port for localhost in PHP (Apache,

Postby Altrea » 18. March 2015 23:36

Ok, but some webserver is using Port 2556 and did have its own resources which are not automatically accessible by any other webserver you are running on port 81
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8299
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Next

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 64 guests