Tag Archives: xampp

Windows 10 and XAMPP: Port 80 in use by “Unable to open process” Tips, Tricks and Tutorials 01 AUG 2015

Originally the plan was to wait for Windows 10 to be a little more established before I took the jump and upgraded my work laptop (Windows 7) to Microsoft’s latest wunderkind (Windows 10). However, I got a little too excited (plus, free is always so attractive, isn’t it?), that I ended up jumping in and doing the upgrade as soon as my notification arrived! (So much for self control in other words).

(For interest’s sake, the upgrade went smoothly, though I had to uninstall a few applications and switch off a few startup apps for the best result. First impression? I really, really like it.)

Anyway, I did immediately hit my first snag when firing up XAMPP – the web server Apache failed to load, with the resulting message appearing in the console: Port 80 in use by “Unable to open process”.

netstat wasn’t much better at identifying the process locking up port 80 (also reporting “unable to identify process owner”), though the PID of 4 it returned did give a clue that it was probably a service currently using the port.

So I fired up the Services control panel (search “Services” using the search button next to the Windows button) and narrowed my search to all automated start services seeing as port 80 seemed to be locked at Windows start up already.

Knowing that port 80 is usually an internet related port, the services listing quickly threw up a likely suspect: W3SVC, otherwise known as World Wide Web Publishing Service.

It’s the service that provides the connectivity for Microsoft’s built in Internet Information Services Manager, but seeing as I want to use Apache for my web server, it’s quite safe to disable it.

Or as I did in my case, simply stop it and switch it’s startup type to manual.

Firing up XAMPP’s control panel confirmed that all was now well as Apache happily and greedily gobbled up port 80 as it started up!

disable World Wide Web Publishing Service Properties service

Related Link: XAMPP

XAMPP and Windows: How to Create a Symbolic Link Tips, Tricks and Tutorials 25 NOV 2014

If you have scripts which need to be run in your local web browser but fall outside of your web root or any other declared vhost directory, there is always the option of simply creating symbolic links to these external locations from within your web root folder.

To do this (and I needed to on my Windows 7 environment to get around some Sencha ajax origin restrictions during debugging) follow the following steps:

1. Click the Start button to bring up the start menu.

2. Type cmd in the universal search box at the bottom of the start menu. (You should see at the top of the search results under Programs cmd.exe highlighted)

3. Press the Ctrl + Shift + Enter to launch the command prompt (cmd.exe) as Administrator. If you don’t do this, you’ll get a error saying that there are insufficient permissions to create the symbolic link later on. (You can also right click and select “Run as Administrator” to achieve the same thing.)

4. A box saying “Windows needs your permission to continue” will pop up. Click Continue.

5. Go to the directory you want to create the link in. For example: cd c:\xampp\htdocs\

6. Use mklink to create your symbolic link (or shortcut):

mklink /D externalfolder "c:\Users\username\Documents\My Folder\"

Note: The /D is there because, in this example, we are linking to a directory. “externalfolder” is the name of the symbolic link (change to whatever you want). Finally, the path is where the symbolic link actually resolves to.

Using the example laid out below, we could now point our browser to http://localhost/externalfolder/hello-world.php which would run just fine, with the browser executing c:\Users\username\Documents\My Folder\hello-world.php in reality.

Useful little trick to be aware of.

xampp logo

XAMPP on Windows 7: Solving “client denied by server configuration” VirtualHost Error CodeUnit 05 FEB 2013

I don’t normally use Windows as my development environment, but after being handed a Windows 7 Fujitsu laptop at work, I set about getting my development environment up and running as fast as possible. XAMPP appears to be a popular way of setting up an Apache, MySQL and PHP stack, so I duly installed and then whipped open the C:\xampp\apache\config\extra\httpd-vhosts.conf file in order to add all my virtual hosts.

Nothing too complicated in there, pretty much only defining a DocumentRoot and ServerName directive, along with a simple Directory block containing an Order and an Allow directive. Next up with the C:\Windows\System32\drivers\etc\hosts file which was edited to allow for my subdomain and that should have been that. I fired up the XAMPP console, started both Apache and MySQL, and pleasingly http://localhost/ worked first time in my browser. Then I attempted to access my virtualhost – and nothing. Or rather a 403 denied access error message courtesy of my browser.

What followed was more than a hour of searching and tinkering with my setup, exploring folder security properties, directory name structures, config file alterations, all to no avail. Instead the “client denied by server configuration” error continued to taunt me at every turn.

I went to bed a frustrated man, and the next morning after an early rise and shine, I pulled out my chair and tackled the problem anew. And success!

The problem lies in the restrictive XAMPP httpd.conf file where it specified the “default” with a very restrictive set of features, the troublemaker here being a Directory block containing “Require all denied” (an authentication feature rolled out with Apache 2.4). What this means is that all incoming requests are denied. So back to our virtualhost specification, where we need to edit our Directory block and add a new rule to override the default setting.

Now we could go for “Require all granted”, but this is a little bit too open and not necessarily a practice that should be encouraged if you don’t need it. Instead, because this is for my local development environment, I’ll open up my vhost for the internal IP of 127.0.0.1, using the “Require ip xxx.xxx.xxx.xxx” directive.

So now my vhosts.conf entry looks like this:

<VirtualHost *:80>
DocumentRoot "C:\vhosts\surveythumb"
ServerName surveythumb
DirectoryIndex index.php
<Directory "C:\vhosts\surveythumb">
AllowOverride none
Require ip 127.0.0.1
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Solved!

PHP: Warning: stream_socket_enable_crypto(): this stream does not support SSL/crypto CodeUnit 30 AUG 2012

“Warning: stream_socket_enable_crypto(): this stream does not support SSL/crypto” is a message you will often come across when doing mail send work in PHP, particularly when your SMTP settings require you to connect using either a SSL or TLS mode.

The reason for the PHP warning message is actually not insidious at all – 99% of the time it refers to the fact that the OpenSSL extension hasn’t been enabled in your PHP configuration file – and under XAMPP this is almost always the case.

So a simple fix is to navigate to your php.ini file (for XAMPP it usually sits under xampp\apache\bin\php.ini), open it up and run a search for “extension=php_openssl.dll”.

Uncomment this line by removing the semi-colon at the front of it, save the file and then restart Apache via the Services panel.

Nifty.

MySQL and XAMPP: Change Your Server’s Max Allowed Packet Limit CodeUnit 01 OCT 2010

Just a quick note on how to permanently change your MySQL server’s configuration to allow for a bigger max_allowed_packet limit, basically the variable that controls how long a SQL statement can technically get.

First, locate your my.cnf file, the config file that MySQL generally uses as a default. If you are using XAMPP as your development stack, you’ll find it under C:xamppmysqlbinmy.cnf. Open it up in any text editor (PSPad always works well for me!) and run a search on max_allowed_packet. You should get a result under the #The MySQL Sever heading that reads max_allowed_packet = 1M.

Now it becomes a simple matter of changing that line to whatever you want (limit is 1 GB), e.g. max_allowed_packet = 16M, saving it and then firing up your Services tab and restarting the MySQL service.

Done.