Selasa, 22 Januari 2019

Set Up Apache

      How to Set Up Apache Virtual Host Ubuntu 14.04

*The first step
The first step is to create a directory structure that will store site data that we create to
serve visitors.

In document root (the top-level directory that looks Apache to find content to serve)
will be assigned to the individual directory under / var / www. I will create a directory
for virtual hosts.

IN this directory I created a public_html file that will store the actual files.
 By typing the command
# sudo mkdir -p /var/www/example.com/public_html




*Second step

Now we have a directory structure for our files, but they are owned by our root user.
 If we want a normal user to be able to modify files in a web directory, 
we can change ownership by doing this:
#sudo chown -R $ USER: $ USER /var/www/example.com/public_html
 
 
We also have to modify the permissions to ensure that read access is allowed for public
 web directories and all the files and folders in them so that pages 
can beserved correctly:
#sudo chmod -R / var / www
 
*Step three: Create a Demo Page for the Virtual 
Host
 
We can open an index.html file in the editor by typing:
 #nano /var/www/example.com/public_html/index.htm
In this file, we create a simple HTML document that shows the site it is connected to. 
My file looks like this:
 
save and close the file when it's finished (ctrl + x, y, enter)
 
*Step four: Create a New Virtual Host File
 
 Create a Virtual Host File
Start by copying files for the domain
#sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf



Open a new file in the editor with root access rights:
#sudo nano /etc/apache2/sites-available/example.com.conf
 
then the display will appear as below. then change a little
 
*Step five: Activate the Virtual File Host
 
Now that we have created our virtual host file, we must activate it.
# sudo a2ensite example.com.conf
 
When you are finished, you must restart Apache to make this change take effect: 
#sudo service Apache2 restarts
 
 
*Step six: Set Up Host Local File (optional)
 
If you are on a Mac or Linux computer, edit your local file with administrative
 privileges by typing:
#sudo nano / etc / hosts
 
 
A display will appear like this, add a script like the picture
 
*Step seven: Test your results
 
Open your web browser: 

#http://example.com

Good luck and sorry if there is an error

Tidak ada komentar:

Posting Komentar