set domain name for localhost ubuntu 1

set domain name for localhost ubuntu

sudo nano /etc/hosts
# Add your Domain pointed to 127.0.0.1 or 0.0.0.0

127.0.0.1  domain.com

#Ctrl + O save Ctrl + X Exit

Here is what the above code is Doing:
1. We’re creating a new directory called /etc/nginx/sites-available.
2. We’re creating a new file called domain.com in the sites-available directory.
3. We’re adding the following configuration to the file:

server {
listen 80;
server_name domain.com www.domain.com;
root /var/www/domain.com/public_html;
index index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ =404;
}
}

4. We’re creating a new directory called /var/www/domain.com/public_html.
5. We’re creating a new file called index.html in the public_html directory.
6. We’re adding the following content to the file:



Welcome to domain.com!

Success! The domain.com server block is working!


7. We’re creating a symbolic link from the sites-available directory to the sites-enabled directory.
8. We’re removing the default symbolic link in the sites-enabled directory.
9. We’re restarting Nginx.

Similar Posts