- Show all Docs ( 243 ) Collapse Docs
- Show all Docs ( 23 ) Collapse Docs
How to host a domain on centos 7
In this article, you will learn how to host a domain on centos 7.
If you wish to host many domains on your server, you must configure the webserver with the appropriate hosts. Thus, your server can send unique content based on the request. This guide will teach you how to setup virtual Apache hosts on CentOS 7.
Beginning with yum update yum update -y
1. Installing Apache
#yum -y install httpd
#systemctl enable httpd.service
#systemctl start httpd
#systemctl status httpd
To see if Apache is already operating, type your IP address in the browser. This is how the page ought to appear:
2. Creating Directory Tree
- Data for websites is stored in a directory structure. First, use the following command to change the working directory to /var/www:
2. All of your virtual hosts should have their own document root.
#mkdir -p microhostdomain.com/public_html
Replace microhostdomain.com with your domain name.
3. Create a path that Apache may use to reach the directory. Execute the chown and chmod commands to make the necessary changes to the ownership and permissions of the entire web directory.
#chown -R apache:apache /var/www/yourdomain.com/public_html
#chmod -R 755 /var/www
Apache now has the necessary rights to add new directories and serve content in response to incoming queries.
3. Creating a Demo Page
If you're using Apache virtual hosts, you should create a demonstration page. You can see if the host is up and running before transferring your website files. The procedure is as follows:
- To make an index.html file for the public html folder at microhostdomain.com, use the vi editor.
#vi microhostdomain.com/public_html/index.html2. Paste the following content to the file: <html> <head> <title>This is a test page</title> </head> <body> <h1>Hello Microhost</h1> </body> </html> 3. To save the file, press escape colon wq
4. Creating the Virtual Host
- Make a fresh virtual host configuration file (.conf) in the Apache installation root:
#vi /etc/httpd/conf.d/microhostdomain.com.conf2. Insert the following content into the .conf file: <VirtualHost *:80> ServerName www.microhostdomain.com ServerAlias microhostdomain.com DocumentRoot /var/www/microhostdomain.com/public_html ErrorLog /var/www/microhostdomain.com/error.log CustomLog /var/www/microhostdomain.com/requests.log combined </VirtualHost> 3. To save the file, press escape colon wq In the preceding example, we tell Apache that we will use port 80 for communication and that the virtual host's name is microhostdomain.com. Furthermore, we specify directories for website files (document root) and error logs. 4. Restart Apache for the changes to take effect:#systemctl restart httpd.serviceThat's all there is to it; you've just created an Apache virtual host for your domain! Now, in your browser, enter your IP address and you should see the "Hello Microhost" text from the demo page we created earlier. Thank You 🙂