The Apache web server is used in Ubuntu to build HTTP server. Follow the below commands,
Stage 1] Execute the below command to install Apache web server from internet.
After installation the root configuration files and web resource director are
/etc/apache2 and /var/www respectively.
Stage 2] The main configuration file is /etc/apache2/apache2.conf.
Stage 3] If Domain Name Server (DNS) is not installed then modify the hosts file to configure Domain Name.
susanta@admin:~$ sudo gedit /etc/hostname
Here, admin.home.com is a fully qualified domain name.
Stage 4] Modify the /etc/apache2/sites-available/default file to select the domain name and the document path which will be opened in the browser.
susanta@admin:~$ sudo gedit /etc/apache2/sites-available/default
<VirtualHost admin.home.com:80>
ServerAdmin susanta@admin.home.com
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
Here, /var/www/ is the document directory and inside the director there is file called index.html which will be opened in browser.
Stage 5] Now start or reload the apache server to get affect change.
susanta@admin:~$ service apache2 reload
Stage 6] Open a browser and write the domain name admin.home.com.
Stage 7] Apache can configure number of different virtual domain name(s) by using same IP address. To do this, we need to copy /etc/apache2/sites-available/default to /etc/apache2/sites-enabled/default in deferent name.
susanta@admin:~$ sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-enabled/mysite
Stage 8] Now edit the mysite file to create a virtual site.
susanta@admin:~$ sudo gedit /etc/apache2/sites-enabled/mysite
<VirtualHost mysite.home.com:80>
ServerAdmin susanta@mysite.home.com
DocumentRoot /var/redhat
<Directory /var/redhat>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Stage 9] Add the vertual domain name in /etc/hosts file.
susanta@admin:~$ sudo gedit /etc/hosts
127.0.0.1 localhost
127.0.1.1 admin.home.com
127.0.1.1 mysite.home.com
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
Stage 10] Now again reload the apache server to get affect change.
susanta@admin:~$ service apache2 reload
Stage 11] Open a browser and write the virtual domain name mysite.home.com
Stage 1] Execute the below command to install Apache web server from internet.
susanta@admin:~$ sudo apt-get install apache2
After installation the root configuration files and web resource director are
/etc/apache2 and /var/www respectively.
Stage 2] The main configuration file is /etc/apache2/apache2.conf.
susanta@admin:~$ sudo gedit /etc/apache2/apache2.conf
susanta@admin:~$ sudo gedit /etc/hostname
Here, admin.home.com is a fully qualified domain name.
susanta@admin:~$ sudo gedit /etc/hosts
Stage 4] Modify the /etc/apache2/sites-available/default file to select the domain name and the document path which will be opened in the browser.
susanta@admin:~$ sudo gedit /etc/apache2/sites-available/default
<VirtualHost admin.home.com:80>
ServerAdmin susanta@admin.home.com
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
Here, /var/www/ is the document directory and inside the director there is file called index.html which will be opened in browser.
Stage 5] Now start or reload the apache server to get affect change.
susanta@admin:~$ service apache2 start
orsusanta@admin:~$ service apache2 reload
Stage 6] Open a browser and write the domain name admin.home.com.
Stage 7] Apache can configure number of different virtual domain name(s) by using same IP address. To do this, we need to copy /etc/apache2/sites-available/default to /etc/apache2/sites-enabled/default in deferent name.
susanta@admin:~$ sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-enabled/mysite
Stage 8] Now edit the mysite file to create a virtual site.
susanta@admin:~$ sudo gedit /etc/apache2/sites-enabled/mysite
<VirtualHost mysite.home.com:80>
ServerAdmin susanta@mysite.home.com
DocumentRoot /var/redhat
<Directory /var/redhat>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Stage 9] Add the vertual domain name in /etc/hosts file.
susanta@admin:~$ sudo gedit /etc/hosts
127.0.0.1 localhost
127.0.1.1 admin.home.com
127.0.1.1 mysite.home.com
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
Stage 10] Now again reload the apache server to get affect change.
susanta@admin:~$ service apache2 reload
Stage 11] Open a browser and write the virtual domain name mysite.home.com
Good
ReplyDelete