Over a year ago I discovered how to set up virtual hosts in Xampp and posted my method in the Ubuntu forum. Today I had to do it again. My memory is not very good and as it is not something I do every day I could not remember the precise details. I had to go searching in the Ubuntu forums to find my instructions again and of course, this took quite a while to find as there is a mass of excellent hints and tips over there and it is very easy to become distracted. Therefore, I have decided to post my method here hoping that the next time I need to install virtual hosts I will be able to find the instructions straight away!
At the moment I am using Ubuntu 10.10 and XAMPP Linux 1.7.3a
1. First of all enable virtual hosts by editing httpd.conf:
sudo gedit /opt/lampp/etc/httpd.conf
Find #Include etc/extra/httpd-vhosts.conf and remove the # so it looks like:
Include etc/extra/httpd-vhosts.conf
Save and close.
2. Now add the virtual host:
sudo gedit /opt/lampp/etc/extra/httpd-vhosts.conf
You will find two virtual hosts set up as examples. Remove or edit these with your own details.
ServerAdmin webmaster@mysite.com
DocumentRoot /opt/lampp/htdocs/myname/mysite
ServerName mysite.com
ErrorLog logs/mysite.com-error_log
CustomLog logs/mysite.com-access_log common
Save and close the file.
3. Now tell Xampp where to find this site:
sudo gedit /etc/hosts
Add this:
127.0.0.1 mysite.com
Save and close the file.
4. Restart xampp server
sudo /opt/lampp/lampp restart
5. Now you can point your browser to http://mysite.com and it should fetch your site.
I hope this method helps you too.
Posted in Linux, PHP, Web Development by Jan on November 16, 2010 at 3:19 pm | 1 Comment »
These last few weeks I have been trying out CodeIgniter and so far I have been very impressed. For those who do not know, CodeIgniter is an open source PHP framework. It is very easy to set up, works with version 4 and 5 of PHP, uses the MVC approach which separates logic from presentation and has a very good user guide and tutorials. I have built several applications while learning CodeIgniter and it does seem to make coding web projects quicker, easier and fun! If you have not used a framework before but are interested in learning how one works, I think CodeIgniter is an ideal first step. I will keep you updated as to how I progress with it.
Posted in CodeIgniter, PHP, Web Development by Jan on November 2, 2010 at 3:09 am | Comments Off
Six PHP Session Tutorials to help when using sessions:
- PHP session tutorial – a clear basic introduction from PHP F1
- Managing Users with PHP Sessions and MySQL - building a logging in system from Sitepoint
- Basic PHP Session – from about.com
- Using Sessions in PHP – building a membership system
- Session Control and Cookies
- Sessions and cookies: Adding state to a stateless protocol – at PHP Freaks
Tags: PHP, sessions
Posted in PHP by Jan on September 10, 2009 at 3:22 pm | Comments Off
To print the date in the following format:
2008-06-27 use:
<?php echo date("Y-m-d"); ?>
This is useful for automatically updating the date in the copyright section of a web page:
Copyright © <?php echo date("Y"); ?> Painted Pixels.
Once this is in place on a web page, the year will be adjusted saving yourself the job of having to do it manually.
For other date formats see the PHP Manual.
Posted in PHP by Jan on June 27, 2008 at 1:26 am | Comments Off