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

Setting Up Virtual Hosts for XAMPP

Running a Web server on your computer is a great way to speed up Web site development. By previewing your Web pages directly through a Web server on your own computer you can test out server-side programming like server-side include files, form processing scripts, or database-driven Web pages. However, there’s one problem associated with running a server on your own computer: by default, you only have a single "domain"–http://localhost/–so if you work on more than one Web site you put them all under "localhost" in different directories. This isn’t very real world and can cause problems when using server-side includes and root-relative links. Fortunately there’s a better way.

Virtual Hosts

Virtual Hosts give you the ability to "host" more than one  domain on your computer. With a virtual host you can have separate domain names for each of your Web sites: for example, http://clientABC/ for one site and http://clientXYZ/ for another. When you type the URL for the Virtual Host in your Web browser, the browser doesn’t go out onto the internet to find the site, but instead asks for the proper file from the Web server running on your computer.
Adding a Virtual Host is a 2-step process:
  1. Add a new entry to your computer’s hosts file. A hosts file can be used to point requests for a domain to a particular IP addressin other words, it lets you re-direct communications to a particular domain. In the case of a virtual host, it can tell the computer to NOT go out on the internet when you type a particular URL like http://clientABC/, but instead look for that particular domain on your own computer.
  2. Edit the Apache configuration file to accept Virtual Hosts and define the particular Virtual Hosts you want to setup on your computer. The first step above, merely redirects requests from a particular domain to your computer, but this step prepares the Web server on your computer for handling those requests. In this step, you not only provide the name of the Virtual Host, but also tell Apache where the files for the site are located on your computer.

Steps in Detail

  1. Launch Notepad and open the hosts file located at C:\windows\system32\drivers\etc\hosts. (You may not be able to see the windows folder–some files are hidden by default under Windows. Here are help to make files visible.) On Vista, you’ll also need to have access to change the hosts file. To do that, launch Notepad by right clicking on Notepad from the Start menu and choosing "Run As Administrator." This will allow you to edit and save the file.
  2. At the end of that file type:
    127.0.0.1      clientABC.local
    127.0.0.1 is how a computer refers to itself—it’s an IP address that points back to the computer, kind of like a computer’s way of saying "ME." The second part (clientABC.local) is the "domain" of the virtual host. To visit this domain in a Web browser you’d type http://clientABC.local. You don’t have to add the .local part to the hosts files—you could just as easily add 127.0.0.1 clientABC and access the site in your Web browser with http://clientABC—but I find it helpful for differentiating between a real Web site out on the Internet like clientABC.com, and the test sites I have running on my own computer.
  3. Save and close the hosts file. That finishes the first part of this process. You’ve prepared your system to handle requests to http://clientABC.local. Now you need to inform the Web server, Apache, how to handle those requests.
  4. In Notepad open the Apache configuration file located at
  5. C:\xampp\apache\conf\extra\httpd-vhosts.conf 
  6. At the bottom of that file add:
    NameVirtualHost *
      <VirtualHost *>
        DocumentRoot "C:\xampp\htdocs"
        ServerName localhost
      </VirtualHost>
      <VirtualHost *>
        DocumentRoot "C:\Documents and Settings\Me\My Documents\clientABC\website"
        ServerName clientABC.local
      <Directory "C:\Documents and Settings\Me\My Documents\clientABC\website">
        Order allow,deny
        Allow from all
      </Directory>
    </VirtualHost>
      
    The first five lines of code turn on the Virtual Host feature on Apache, and set up the C:\xampp\htdocs folder as the default location for http://localhost. That’s important since you need to be able to access the XAMPP web pages at http://localhost/ so that you can use PHPMyAdmin.
    The stuff in yellow represents a single Virtual Host. You’ll add one chunk of code just like this for each Virtual Host (or Web site) on your computer
    You’ll need to modify the stuff highlighted in blue. The first item — DocumentRoot — indicates where the files for this site are located on your computer. The second part–ServerName — is the name you provided in step 2 above: the virtual host name. For example, clientABC.local. The third item — the <Directory> part — is the same path you provided for the DocumentRoot. This is required to let your Web browser have clearance to access these files.
  7. Save and close the Apache configuration file, and restart Apache from the XAMPP control panel.
  8. Start a Web browser and type a URL for the virtual host.
  9. For example: http://clientABC.local/.
    You should now see the  Main page for your site.

Install XAMPP on Windows

Click to Download Xampp

Select the Installer option under the Basic Package. You may be taken to a page that presents you with a bunch of different download locations. Click one of the download buttons, and then save the file to your desktop. After Download, the installer works like most Windows installers.


  • Double-click the .exe file you downloaded.
    A window opens, asking you to select the language you’d like to use.
    If a warning dialog appears click the "Allow" option to install XAMPP.
  • Choose  language from the menu, and click OK.
    A Setup Wizard window appears, ready to step you through the setup process.
    In Vista you may see a message warning you that XAMPP may not work when installed in the
     C:\Program Files directory. The default installation is in C:\XAMPP so you don’t have to 
    worry about this problem.
  • Click Next button.
    The installer suggests putting the application on your main drive at C:\XAMPP. You can  install it anywhere, but with the Vista operating system you may encounter problems if you install  in C:\Program Files.

  • Click the Next button once again.
    The XAMPP Options window appears (see below). In most cases, it’s fine to leave all the window’s checkboxes just as you see; see the note below for details.

    If you plan on doing a lot of development, day in and day out, you might want to turn on the “Install Apache as service” and “Install MySQL as service” checkboxes. A service starts up every time you turn on your computer, so Apache, PHP, and MySQL are always running.  However, if you won’t be building database sites frequently, or you don’t have a lot of RAM in your computer, don’t turn on these boxes (you’ll just have to manually start the servers when you wish to build dynamic pages, using the XAMPP control panel described on the next page).
  • Then Click Install.
    The installer places all the files onto your system. This process takes a while, since a lot of programs and files are being installed.

  • Click the Finish button.
    A window appears “congratulating” you (way to double-click the installer program!), and asking whether you wish to start the XAMPP Control panel.

  • Click Yes, to open the XAMPP Control Panel (see screenshot below).
    The XAMPP Control Panel lets you start and stop the Apache Web server and MySQL database server.

    In this snapshot, both Apache and MySQL are NOT running, as indicated by the word Start to the right of their names. Click the Start buttons to turn the servers on. You can open the Control Panel by clicking the XAMPP Control Panel shortcut on your desktop.
  • If the buttons to the right of Apache and MySQL say Start, click them to start the Web server and the MySQL database server.
    You probably get a Windows security alert about both MySQL and Apache: Click the Unblock button in both cases. This action allows the two servers to run, and tells the Windows firewall protection service that everything is OK.If Apache and MySQL are already running, these buttons say Stop. (Clicking them turns off the Web server and MySQL.) Whenever you start Apache, PHP automatically starts as well. At this point, you should have a complete testing server running on your machine. You just need to make sure it’s working.

  • To do so, launch a Web browser, and, in the Location bar, type http://localhost/.
    You encounter a page that lists a bunch of languages; click the language you prefer, and you’re taken to a kind of Web-based control panel for XAMPP (see screenshot below).
    Once installed, you can view your XAMPP home page from http://localhost/xampp/. From the left-hand list of links, you can access helpful programs and information, such as phpMyAdmin (for working with the MySQL database) and phpinfo() for finding out more about the server setup.

  • Once you’ve installed XAMPP, you’ll see a shortcut called XAMPP Control Panel on Desktop. Double-click this icon to control the servers you’ve just installed—you can turn the servers off and on, as well as turn them into services (which launch each time you start up your computer).

    To Uninstall XAMPP :

    Go to the location where you installed XAMPP (like C:\XAMPP\) and run the program named Uninstall.exe. This action, however, deletes any databases you created, and destroys any Web pages that you placed on the server.

    To prevent this process, just follow these steps:
     First, use phpMyAdmin to export any database you wish to save and then make a copy of your Web pages which are located in the C:\XAMPP\htdocs folder.

    How to Install PHP on Mac


    Enable Apache on OS X
    Before you can enable PHP on a Mac, you first have to enable Apache.This process is extremely easy.
    1. Click the 'System Preferences' icon in the Dock.
    2. Click the 'Sharing' icon in the Internet & Network section of the System Preferences window.
    3. Place a check mark in the ‘Web Sharing’ box.

    That's it! If you want to test if it worked, point your browser to http://localhost/ and you should see the standard Apache test page.

    Enabling the PHP Module on OS X
    For this next part you are going to need a plain text editor that will allow you to open hidden files. TextWrangler because it's free and it gets the job done. These next steps might be slightly different if you are using a different editor, but the principle is still the same.
    1.  We want to open the file located at HD:private:etc:apache2:httpd.conf. In TextWrangler we do this by choosing "Open Hidden" from the File menu.
    2. Since it is a root file, we need to unlock it before we can edit. In TextWrangler this is done by clicking the pencil button in the top left hand corner. You will get a pop-up confirming that you want to do this.
    3. Go to line 114, the line should read # LoadModule php5_module libexec/apache2/libphp5.so
    4.  Delete the #, the line should now read LoadModule php5_module libexec/apache2/libphp5.so
    5.  Save the file. You will be prompted for your password if you are using TextWrangler.

    PHP Config
    The next thing we want to do is make a copy of php.ini.default and save it as php.ini. Once we have done this we can edit our PHP preferences.
    1.  First open up Terminal. It is located inside your Systems folder which is located inside your Applications folder. 
    2. Enter the following lines, one at a time:
      cd /private/etc
      
      sudo cp php.ini.default php.ini 
      
      
    3. You may now open your new php.ini file using TextWrangler or another editing programing and change the default settings if you wish. It will be located in Macintosh HD:private:etc



    Testing PHP
    Finally we need to run a test to make sure that PHP is running.

    1.  First create a simple test file. A good thing to include is phpinfo().Sometimes it is necessary to find out more information about the version of PHP your server is running.
    2. You can find out the PHP version, as well as many specific settings just by running 
      
      a very simple one line program from your browser.
      The phpinfo(); command will bring up a full profile of the PHP you are currently 
      
      running, and display it in categorized tables for you to view.
      
    3. If your PHP is working your test program should display your PHP's information. If it displays your code, you need to restart Apache. 

    You can restart Apache by entering the following line in Terminal:


    sudo apachectl restart


    Restarting will also require your password.
    Congratulations, you have now activated PHP on your Mac, enjoy!

    How to Install Apache, PHP, MySQL and PHPMyAdmin in Ubuntu


     If you are a PHP based web developer, you need all the software running and configured properly. Here I am talking about installing them One by One in your Ubuntu Desktop. We are installing all the applications from terminal

    How to Open Terminal:
    So, to fire up the terminal follow any of these steps:
    1. If you are running Unity Desktop, click on the Ubuntu Logo at top left corner and type Terminal in the search application bar. Then click on the terminal icon.
    2. If you are running GNome Desktop, click on Applications->Accessories->Terminal
    3. For shortcut, you can also press Ctrl+Alt+T at once, to open the terminal.
    How to install Apache:
    1. Make sure you have the internet connection. To install apache execute the following command in the terminal:




    sudo apt-get install apache2


    It takes some time to download and install apache. After the setup completes, type http://localhost/ in your browser window to make sure apache is installed and running properly. If you see the page with It Works!, the setup of apache2 completes successfully.


    How to Install PHP:
    1. To install PHP 5, type following commands in the terminal one by one:





    sudo apt-get install php5 sudo apt-get install libapache2-mod-php5


    The first line installs PHP5 in the computer. The second one provides the PHP5 module for the Apache 2 webserver. If second one is not installed, then Apache cannot parse PHP codes in a web page.
    2. After installing PHP5 and PHP module for apache, restart the apache with following code:




    sudo /etc/init.d/apache2 restart


    3. While restarting the apache server, if you see a warning as “Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName”, then you can fix this by creating a file with the Server name. To do this type the following command in the terminal:






    sudo gedit /etc/apache2/conf.d/fqdn


    When the text editor opens, type “ServerName localhost” inside the file and click Save. Then close it. Now restart again with the above code and you will see that the warning message has gone.
    4. Now, we have successfully installed php and apache web server. However, still we don’t know if PHP is successfully installed. To check this, create a file inside /var/www/ folder named test.php as:




    sudo gedit /var/www/test.php


    and write following code in it

    Save the file and type this in browser: http://localhost/test.php
    If you see the various information about PHP and installed modules there, then we can confirm that Apache is parsing PHP codes. Hence the installation is successful up to this point.

    How to Install MySQL:
    1. To install MySQL Server in ubuntu, type following code in terminal window:



    sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql


    This will install latest mysql server and other necessary PHP modules for recognizing mysql functions from PHP code. While installing MySQL server, you may require to enter the password for MySQL root user.

    How to Install PHPMyAdmin:
    1. To Install PHPMyAdmin, type the following codes in the terminal:



    sudo apt-get install phpmyadmin


    While installing PHPMyAdmin, you may require to select the web server. In such case, tick the Apache2 Server and proceed with the installation. You may also require to input MySQL root user password during installation.

    Once the installation completes, type this in your browser window to confirm the successful installation of PHPMyAdmin: http://localhost/phpmyadmin/index.php.
    Now, you are finished. Your environment is setup and you can enjoy using all these applications. Next, you can install other applications that may be necessary such as Eclipse, GIMP etc.

    install Xampp in ubuntu

    Install Xampp in ubuntu

    Xampp is an application that helps to run local server in your computer.It is a tedious method to install Apache web server add MYSQL, php, perl and other application. There xampp has all the stuff in one package. Therefore xampp make it easy to install all these package from a single application. Xampp is available for all the format including windows , mac and solaris. In compare to windows and mac the installation of xampp is a bit complicated in linux. If you are searching for lampp. you are in right place because xampp is previously called lampp. To begin the installation download xampp from official website. or download via terminal


    wget http://www.apachefriends.org/download.php?xampp-linux-1.7.3a.tar.gz
    

    Also see 4 ways of using wget command in Linux
    After downloading place the file in desktop. Don’t extract the file. Put as you have downloaded it.
    Step1: login into root directory
    To install the xampp you have to log in into the root directory to log into root directory run the following command into terminal one by one
    cd Desktop
    

    (Make sure the initial letter of Desktop is capital)

    sudo -s
    

    xampp ubuntu
    Step2: Installing Xampp in Ubuntu
    1. To install xampp in ubuntu run the following command in terminal which will extract the download file into /opt directory. Run the following Command in terminal

    tar xvfz xampp-linux-1.7.3a.tar.gz -C /opt
    

    (Note: This version will install xampp 1.7.3 version Place the xampp-linux-1.7.3a with the version if you want to install another version).
    This process will install xampp. You will find xampp in /opt/lampp. Directory.
    Step 3: Solve htdocs trouble
    After install xampp when you try to paste anything to htdocs you will get permission denied error. Therefore to fix this you have to run the following code in terminal after running the code you can simply put files and folder into htdocs


    sudo chmod 777 -R /opt/lampp/htdocs/
    
    

    This changes the ownership of the htdocs folder to your user, the -R option makes the command recursive so all permissions of folders and files inside htdocs are changed aswell.
    Step 4: How to operate xampp in ubuntu
    In you can excess xampp with simple graphical interface but in linux you have to user terminal to start xamp. Here are the few guide for ubuntu user to operate xampp
    1. To start Xampp
    Run the following command in terminal to start lampp


    /opt/lampp/lampp start
    


    xampp-ubuntu-start
    2. Stop the Xampp

    /opt/lampp/lampp stop
    

    You can see further documentation on xampp page if you need more guide to operate xampp on linux