Showing posts with label Xampp. Show all posts
Showing posts with label Xampp. Show all posts

Sunday, January 31, 2010

Multiple MySQL Service conflict

Hi there,

At beginning of programming life, I installed MySQL 5 by downloading it directly from their website. I was using it with IIS (installed PHP) and it worked fine.

Later, I decided to not use IIS because my office programming interface was using Xampp and I was given no option because I need the Xampp to run Apache. I disabled my IIS and installed Xampp. All worked fine.

Until one fine day, I accidentally "Stop" and "Start" the MySQL service provided in Xampp Control Panel. As result of it, all my database went missing (no such DB anymore). I went panic until I understood that Xampp has its own MySQL Service offered in the bundle. In this case, when I clicked "Stop", it had actually stop my original MySQL service. And when I clicked "Start", it started the Xampp's bundled MySQL service. They both are 2 different service and has 2 different data folder.

Basically, the original MySQL service name would be "MySQL" and the Xampp bundled service name would be "mysql" (only the letter case are different).

The problem is, once the "mysql" service has been started (and stopped), the "MySQL" service cannot be started. It would show "Service unable to start. Error 0".

Googling further helped me to solve this issue with little trick of commenting out (disabling) a single line in the my.ini (MySQL's configuration file).
Reference: http://www.experts-exchange.com/Database/MySQL/Q_24356864.html

I comment out this line,
default-storage-engine=INNODB    (add # at beginning of line to comment out)
in the configuration file stored at this path,
C:\Program Files\MySQL\MySQL Server 5.0\my.ini   (your config file may be different depend on where you installed the original MySQL)

And then, start the "MySQL" service like this,
Run "SERVICES.MSC", look for "MySQL", right-click on it and select "Start".


Done, the service runs again like charm and I can access my databases again without crashing them ;)

Have fun guys!

Sunday, December 27, 2009

Internal Error 500 on Xampp if htaccess exist

Hi,

I was being irritated about the '.htaccess' which is being used widely nowdays to rewrite the URL or in another word; they use it to fake the URL.

In Xampp or any PHP service, the rewrite module is disabled by default. The internal server error 500 will display if you try to execute a directory which has the htaccess and requires rewrite_module. So, you must enable the rewrite module or delete your htaccess file in order to execute any script from that directory.

Deleting the htaccess could be only temporary solution. Enabling the rewrite module would be the real right solution.

I googled for it and found good advise from: http://blogulate.com/content/fix-500-internal-server-error-on-htaccess/ which the blog was written by 'thinkdj'. Credit goes to him.

Here is his original text:
Firstly, make sure LoadModule rewrite_module modules/mod_rewrite.so is enabled in httpd.conf (Remove # before the line to enable)
Then, edit httpd.conf .. Find out the foll lines and mod -
<directory> #replace this with your dir name
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
AllowOverride All #Added
</directory>
<directory>
Options FollowSymLinks
# AllowOverride Limit #Old Value
AllowOverride All #Added
Order deny,allow
Deny from all
Satisfy all
</directory>


After doing the changes I had restart the php service and it works fine now.

Hope that solved your problem too!

Have fun scripting!

Tuesday, December 22, 2009

How to add subdomains.localhost if using XAMPP?

Hi,

After a long gap (nearly 2 years) of no blogging, finally I got my time to blog again. Mainly because I am back active being freelance programmer and interested to share some stuffs that I found with you guys.

I always used XAMPP to run PHP and recently I badly needed to have subdomains under localhost for one of my client's web to work. So I kick my ass and searched for "how to", many was there but missing the important pinch. Therefore I thought maybe sharing my own way would be helpful for someone else out there!

I found http://www.offshootinc.com/blog/2007/12/21/setting-up-a-subdomain-on-localhost/ but not worked because missing double quotes and NameVirtualHost. I continue googling and found this: http://www.ardamis.com/2005/08/11/xampp-apache-namevirtualhost/

That one worked like charm!

To cut the crap short; just add like this in C:\xampp\apache\conf\extra\httpd-vhosts.conf;

NameVirtualHost *:80
<virtualhost>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</virtualhost>
<virtualhost>
DocumentRoot "C:/xampp/htdocs/sub"
ServerName sub.localhost
</virtualhost>

And add this in the C:\Windows\System32\drivers\etc\hosts
127.0.0.1 localhost
127.0.0.1 sub.localhost

I am using "XAMPP for Windows Version 1.6.6a" and it worked fine!

Have fun! But if the above method did not work for your version of XAMPP then continue googling and good luck! Don't ever get disappointed when you can't figure it out. Because I understand that messing with server is the most irritating task (after messing with scripts). And there is definitely a way to do it out there. Keep googling and keep on googling!

Take care ya!

=========== Updates on 26th March 2010 ===========
If you are running Windows 7, then you cannot simply edit the host file. Instead, you must right-click on Notepad and select "Run as Administrator". This would open the notepad.exe application with Administrator permission. Then, open the"C:\Windows\System32\drivers\etc\hosts" inside the Notepad through File > Open. Remember you must view the file-type with "All files" instead of "Text File". After opening the host file, you can edit and save it.

In xampp apache config ("C:\xampp\apache\conf\extra\httpd-vhosts.conf"), you must write like this
NameVirtualHost 127.0.0.1:80
<virtualhost 127.0.0.1>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</virtualhost>
<virtualhost 127.0.0.1>
DocumentRoot "C:/xampp/htdocs/sub"
ServerName sub.localhost
</virtualhost>

That's it! Your Windows 7 can run Xampp with sub domains too.


=========== Updates on 31st October 2014 ===========
The setting above only allows to run single subdomain. To have multiple subdomains, in the httpd-vhosts.conf, set it to be like this:

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/folderX"
ServerName domainX.localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/folderY"
ServerName domainY.localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
ServerAlias www.localhost
</VirtualHost>

Also remember to update your C:\Windows\System32\drivers\etc\hosts to include the new subdomain like this:
127.0.0.1 localhost
127.0.0.1 domainX.localhost
127.0.0.1 domainY.localhost