APACHE
Apache server is the most commonly used web hosting service, mainly the websites developed in php , python etc. We can host your website to a local network so that people in same network can access.
In Linux Apache use split structure for configuring files, in which it will be defining hostname, port ,ssl etc each in different configuration files.
Similarly file sharing can be made possible using apache server.
Now we shall try to create a sample website hosted in apache server.
Step 1:
Install apache2 in to the system$sudo apt-get update
//update the repository for latest version of softwares
$sudo apt-get install apache2
Step2:
create a directory in '/var/www/' folder which is the default folder for storing site datas.(Var folder is known as variable folder since it is used to store growing folder like log files,backups etc)
sudo mkdir -p /var/www/sample.com/public_html
Step 3:
Grant user permission for the folder$sudo chown -R $USER:$USER /var/www/sample.com/public_html
modify permission for folder /var/www
$sudo chmod -R 755 /var/www
Step 4:
Create a base file inside public_html index.html with sample content in it.<html>
<head>
<title>Welcome to Sample.com!</title>
</head>
<body>
<h1>Success! The sample.com virtual host is working!</h1>
</body>
</html>
Step 5:
Create configuration fileEasier way is to copy the default cofiguration file and edit it.
$sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/sample.com.conf
Change the server admin as admin@sample.com
Add server name and server alias
ServerName sample.com
ServerAlias www.sample.com
change DocumentRoot to /var/www/sample.com/public_html
Step 6:
Now enable the newly created configuration filesudo a2ensite sample.com.conf
Step 7:
Now the configuration is completed.We can start apache as a service
$sudo service apache2 restart
Step 8:
Set host name
'sample.com' folder in the folder structure we created above is the part of hostname.
Open file 'hosts' in etc folder.
include ip address and hostname into the file.
eg:192.168.1.56<space>host_name
Host name should be same as folder name you created,since
there can be multiple hosts for a single ip address.
Restart the server!!
Access http://sample.com
Yes its working!!!!!!!
This is just a sample technique to host a website.We can include our server side scripts and static files etc by defining it into the configuration file.
Comments
Post a Comment