Showing posts with label apache. Show all posts

How to Set Up Virtual Host in Ubuntu 14.04


Today I came up with new topic that is How to Set Up Virtual Host in Ubuntu.

About Virtual Host

Virtual host is used to set many hosts on the same IP address. Their is no limit on the number to hosts to be added in Virtual Host. Using this we can display different information to user depends on different Host.

I am taking 'example.com' as Virtual Host name. You can customize it.
You need Apache should be installed on system. Here is the guide to install Apache in Ubuntu.

Steps To Set Up Virtual Host 

1. Open Terminal (Shortcut ctrl+alt+t).
2. Create directory  ' sudo mkdir /var/www/example.com '.
3. Create index.html file ' sudo nano /var/www/example.com/index.html '.
4. Paste below code into index.html

<html>
  <head>
    <title>www.example.com</title>
  </head>
  <body>
    <h1>Congrats! You Have Set Up a Virtual Host Successfully.</h1>
  </body>
</html>

5. Now copy the default configuration file.
       sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf 

6. Now edit this duplicate file 'example.com.conf'
    sudo nano /etc/apache2/sites-availble/example.com.conf   

7. Set ServerName, ServerAlias, DocumentRoot
             ServerName example.com
             ServerAlias www.example.com
             DocumentRoot /var/www/example.com
    Make the changes and save the file.

8. Now enable the new configuration file i.e. example.com
               sudo a2ensite example.com

9. Restart Apache
              sudo service apache2 restart

10. Now set Up the local host file
             sudo nano /etc/hosts

11. Add virtual host
             # Host DatabaseNow DIY. Like & share
             #
             # localhost is used to configure the loopback interface
            # when the system is booting.  Do not change this entry.
            ##
            127.0.0.1       localhost
            127.0.0.2       example.com
            127.0.0.1       example.com
     Add host and save the file.

12. Now its done you can check using browser.
Add comment below if you got stuck in any step. We will sort out. Have a good day. Please like and share to appreciate my work.


How to enable mod_rewrite in Ubuntu 14.04 and 12.04 LTS


Here I am back to guide you how to enable mod_rewrite in ubuntu 14.04 & 12.04 LTS. A little note this is the basic steps to enable mod_rewrite but not the best way. Best way is to setup virtual host first and make changes in that config.
Read my previous blog to learn How to install & configure apache in ubuntu.

Ubuntu 14.04 comes with apache 2.4 & ubuntu 12.04 comes with apache 2.2.
This new version introduced different default config file names and in general some differences.

So here are the steps to enable mod_rewrite

1. Open terminal (Shortcut ctrl+alt+t).
2. Activate mod_rewrite.

    sudo a2enmod rewrite    

3.  Restart apache.

    service apache2 restart   

4.  To use mod_rewrite from .htaccess file make some changes in virtual host config file.

if you are using ubuntu 12.04 then run

    sudo nano /etc/apache2/sites-available/default

change the line says AllowOverride from None to all. And comment ' Order allow,deny ' line with hashtag(#).

<Directory /var/www/>
       Options Indexes FollowSymLinks MultiViews
       AllowOverride All
       #Order allow,deny
       allow from all
</Directory>

Now if you are using ubuntu 14.04

sudo nano /etc/apache2/sites-available/000-default.conf

And add this line within virtual host config tag.


<Directory /var/www/>
       Options Indexes FollowSymLinks MultiViews
       AllowOverride All
       #Order allow,deny
       allow from all
</Directory>

5.  Restart apache.

    service apache2 restart  

Now you have enabled mod_rewrite successfully. Great job. :)

If you feel this is useful please keep share to your colleagues. Be social.  

 


How to Install PHP in Ubuntu


Hello readers, Welcome back to my blog.

Today we will learn how to install PHP in Ubuntu. PHP is open source server side scripting language using worldwide in many web application like facebook, wordpress, etc.

PHP is an acronym for "PHP Hypertext Preprocessor".

Install PHP in ubuntu

Open terminal to run below command.

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

After you answer yes to the prompt, PHP will install itself.

Install PHP Extensions

PHP have lots of extensions that you can install. You can see the available extensions list by the below command.

   apt-cache search php5-

 Terminal will show list like the below:

php5-cgi - server-side, HTML-embedded scripting language (CGI binary)
php5-cli - command-line interpreter for the php5 scripting language
php5-common - Common files for packages built from the php5 source
php5-curl - CURL module for php5
php5-dbg - Debug symbols for PHP5
php5-dev - Files for PHP5 module development
php5-gd - GD module for php5
php5-gmp - GMP module for php5
php5-json - JSON module for php5
php5-ldap - LDAP module for php5
php5-mysql - MySQL module for php5
php5-odbc - ODBC module for php5
php5-pgsql - PostgreSQL module for php5
php5-pspell - pspell module for php5
php5-readline - Readline module for php5
php5-recode - recode module for php5
php5-snmp - SNMP module for php5
php5-sqlite - SQLite module for php5
php5-tidy - tidy module for php5
php5-xmlrpc - XML-RPC module for php5Above command
php5-xsl - XSL module for php5
libphp5-embed - HTML-embedded scripting language (Embedded SAPI library)
php5-adodb - Extension optimising the ADOdb database abstraction library
php5-apcu - APC User Cache for PHP 5
php5-enchant - Enchant module for php5
php5-exactimage - fast image manipulation library (PHP bindings)
php5-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
php5-gdcm - Grassroots DICOM PHP5 bindings
php5-gearman - PHP wrapper to libgearman
php5-geoip - GeoIP module for php5
php5-gnupg - wrapper around the gpgme library
php5-imagick - ImageMagick module for php5
php5-imap - IMAP module for php5
php5-interbase - interbase/firebird module for php5
php5-intl - internationalisation module for php5
php5-lasso - Library for Liberty Alliance and SAML protocols - PHP 5 bindings
php5-librdf - PHP5 language bindings for the Redland RDF library
php5-mapscript - php5-cgi module for MapServer
php5-mcrypt - MCrypt module for php5
php5-memcache - memcache extension module for PHP5
php5-memcached - memcached extension module for PHP5, uses libmemcached
php5-midgard2 - Midgard2 Content Repository - PHP5 language bindings and module
php5-ming - Ming module for php5
php5-mongo - MongoDB database driver
php5-msgpack - PHP extension for interfacing with MessagePack
php5-mysqlnd - MySQL module for php5 (Native Driver)
php5-mysqlnd-ms - MySQL replication and load balancing module for PHP
php5-oauth - OAuth 1.0 consumer and provider extension
php5-pinba - Pinba module for PHP 5
php5-ps - ps module for PHP 5
php5-radius - PECL radius module for PHP 5
php5-redis - PHP extension for interfacing with Redis
php5-remctl - PECL module for Kerberos-authenticated command execution
php5-rrd - PHP bindings to rrd tool system
php5-sasl - Cyrus SASL Extension
php5-stomp - Streaming Text Oriented Messaging Protocol (STOMP) client module for PHP 5
php5-svn - PHP Bindings for the Subversion Revision control system
php5-sybase - Sybase / MS SQL Server module for php5
php5-tokyo-tyrant - PHP interface to Tokyo Cabinet's network interface, Tokyo Tyrant
php5-vtkgdcm - Grassroots DICOM VTK PHP bindings
php5-xcache - Fast, stable PHP opcode cacher
php5-xdebug - Xdebug Module for PHP 5
php5-xhprof - Hierarchical Profiler for PHP5
 Now just decide to which extension you want to install & use below command to install this

    sudo apt-get install name of the module


You can install multiple extensions at once by separating the name of each module with a space.

For any queries leave comment below. :)

How to install and configure Apache in Ubuntu



Install Apache

Installing apache in Ubuntu is very easy.
Here are the steps.
1. Open terminal. Use ctrl+Alt+t.
2. sudo apt-get install apache2
3. exit

Congrats! You have installed apache successfully.
Now open http://localhost in your browser. You will see "It Works!".
Configure Apache
If you want to start,stop & restart apache use this commands.
1. to start " sudo service apache2 start ".
2. To stop " sudo service apache2 stop ".
3. To restart " sudo service apache2 restart ".
 Please comment below if you face any issue.