Let's create apache virtual host on your local computer.
Open your terminal and run following codes.
First go to your project folder using cd command
/home/shyamali/Projects/CodeIgniter/Login
Now we can create a virtual host.
Step 1 : You have to create a virtual host
This will open an empty file
Then paste following code inside the that file
Step 2 : Enable site
Then it will display following message
Enabling site local.codeigniter.com.
To activate the new configuration, you need to run:
service apache2 reload
Step 3 : Then you have to restart apache
Open your terminal and run following codes.
First go to your project folder using cd command
cd Projects/CodeIgniter/Login/To get file path enter
pwdThis will give you file path of Login folder
/home/shyamali/Projects/CodeIgniter/Login
Now we can create a virtual host.
Step 1 : You have to create a virtual host
sudo vim /etc/apache2/sites-available/local.login.com.conf
This will open an empty file
Then paste following code inside the that file
<virtualHost *:80> # Admin email, Server Name (domain name) and any aliases ServerAdmin webmaster@domain1.com ServerName local.codeigniter.com ServerAlias www.local.codeigniter.com DirectoryIndex index.php DocumentRoot /home/shyamali/Projects/CodeIgniter/Login <Directory /home/shyamali/Projects/CodeIgniter/Login> # Require all granted # Options FollowSymLinks Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Require all granted #Order deny,allow #Allow from all </Directory> ErrorLog /var/log/apache2/error-mydomainname.com.log CustomLog /var/log/apache2/access-mydomainname.com.log combined </VirtualHost>
Make sure to change ServerName, ServerAlias, DocumentRoot, Directory path according to your specifications.
Step 2 : Enable site
sudo a2ensite local.codeigniter.com
Then it will display following message
Enabling site local.codeigniter.com.
To activate the new configuration, you need to run:
service apache2 reload
Step 3 : Then you have to restart apache
sudo service apache2 reload
Step 4 : Then you have to navigate your local site.
open hosts file
sudo vim /etc/hosts
Then enter your site name and local IP address and save it
127.0.0.2 www.local.codeigniter.com
Now you are all set up for your virtual host
type http://www.local.codeigniter.com/ in your browser and you will see codeigniter default page.
Congratulations !
Comments
Post a Comment