So you have decided to build websites with PHP but where do you start? To start building websites in PHP you need In at least web server (such as Apache or IIS), PHP and a MySQL database. You can install these separately which can be tiresomely long so in this post I will show you how to achieve this quickly so can focus on building websites and learning PHP.
We are going to use an all-in-one solution called XAMPP which makes it so easy to install Apache, MySQL, PHP and Perl. I will also cover setting up Virtual Hosts with XAMPP so you can access the files from a local folder without the need to ftp.
* Ubuntu – ubuntu.com
Although these instructions are for Ubuntu, the same procedure applies for Windows or Mac OS X.
1) Download XAMPP
2) Install XAMPP
In terminal >
CD to the directory where you have downloaded the xampp
tar xvfz xampp-linux-1.7.7.tar.gz -C /opt
3) Configure Virtual Hosts
sudo gedit /opt/lampp/etc/httpd.conf
Look for Virtual hosts
# Virtual hosts
# Virtual hosts
sudo gedit /opt/lampp/etc/extra/httpd-vhosts.conf
Add the following entries to the httpd-vhosts.conf file
DocumentRoot /opt/lampp/htdocs ServerName localhost <Directory " /opt/lampp/htdocs"> AllowOverride All DocumentRoot /home/username/Desktop/website.localhost ServerName website.localhost <Directory "/home/username/Desktop/website.localhost"> AllowOverride All
The first entry is for xampp page so you can access the xampp web pages using http://localhost in your web browser for security or phpmyadmin etc. The second entry points to a folder on the Desktop named “website.localhost”, this is the folder that will contain your new website.
DocumentRoot is the path to your website folder. Server name is what you will type in your web browser to access this website. We also addtag that is also path to your website folder and give override all permission, this will enable you to use .htaccess file within your website.
Next we need to edit the hosts file to map the server to local IP so it can be resolved. There is already a localhost entry so we just add an entry for website.localhost
sudo gedit /etc/hosts
add the following line
Now create the folder “website.localhost” on your Desktop or according to your DocumentRoot and create an index.php file.
4) Start XAMPP
sudo su /opt/lampp/lampp start
Finally, point your browser to http://localhost and you will see XAMPP for Linux webpage. Similarly, you should see your test page if you point your browser to http://website.localhost
Thats it! Your PHP development environment is now set up and you are ready to start developing PHP web applications.