Adding a domain name to a web server involves several steps, including registering the domain, setting up DNS, and configuring the web server. Here’s a general guide on how to do this:
1. Register Your Domain Name
- Purchase your domain from a domain registrar (e.g., GoDaddy, Namecheap).
- After purchase, you’ll have access to the domain management dashboard.
2. Set Up DNS
- Name Servers: Set the domain’s name servers to point to your DNS provider (this might be your web hosting provider).
- DNS Records:
- A Record: Points your domain (e.g.,
example.com
) to the IP address of your web server. - CNAME Record: Can be used to point subdomains (e.g.,
www.example.com
) to your domain or another domain.
- A Record: Points your domain (e.g.,
3. Configure the Web Server
- Depending on your server’s software (e.g., Apache, Nginx), you’ll need to create a configuration file for your domain.
For Apache:
- Locate the configuration file, typically in
/etc/httpd/conf/httpd.conf
or/etc/apache2/sites-available/
. - Add a
VirtualHost
block: - ServerAdmin admin@example.com ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/html/example ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined
- Enable the site:
- sudo a2ensite example.com.conf
- sudo systemctl restart apache2
- For Nginx:
- Navigate to
/etc/nginx/sites-available/
and create a configuration file: - server {
listen 80;
server_name example.com www.example.com;root /var/www/html/example; index index.html; location / { try_files $uri $uri/ =404; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; }
} - Enable the site:
- sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
- sudo systemctl restart nginx
- SSL/TLS (Optional but Recommended)
- Use Let’s Encrypt to obtain a free SSL certificate:
- sudo certbot –apache -d example.com -d www.example.com
- For Nginx:
- sudo certbot –nginx -d example.com -d www.example.com
- Test the Configuration
- Visit your domain in a web browser to verify everything is working correctly.
This process links your domain name to your web server, making your website accessible via the domain.
वेब सर्वर में डोमेन नाम जोड़ना
किसी वेब सर्वर में डोमेन नाम जोड़ने के लिए कुछ चरणों का पालन करना पड़ता है, जिसमें डोमेन पंजीकरण, DNS सेटअप और वेब सर्वर को कॉन्फ़िगर करना शामिल है। यहां इसका एक सामान्य मार्गदर्शन दिया गया है:
1. डोमेन नाम पंजीकरण करें
- अपने डोमेन को किसी डोमेन रजिस्ट्रार (जैसे GoDaddy, Namecheap) से खरीदें।
- खरीदारी के बाद, आपको डोमेन प्रबंधन डैशबोर्ड तक पहुंच प्राप्त होगी।
2. DNS सेटअप करें
- नेम सर्वर: अपने डोमेन के नेम सर्वर को DNS प्रदाता (यह आपका वेब होस्टिंग प्रदाता हो सकता है) की ओर इंगित करें।
- DNS रिकॉर्ड्स:
- A रिकॉर्ड: आपके डोमेन (जैसे
example.com
) को वेब सर्वर के IP पते पर इंगित करता है। - CNAME रिकॉर्ड: सबडोमेन (जैसे
www.example.com
) को आपके डोमेन या किसी अन्य डोमेन पर इंगित करने के लिए उपयोग किया जाता है।
- A रिकॉर्ड: आपके डोमेन (जैसे
3. वेब सर्वर को कॉन्फ़िगर करें
- आपके सर्वर के सॉफ़्टवेयर (जैसे Apache, Nginx) के आधार पर, आपको अपने डोमेन के लिए एक कॉन्फ़िगरेशन फ़ाइल बनानी होगी।
Apache के लिए:
- कॉन्फ़िगरेशन फ़ाइल ढूंढें, आमतौर पर
/etc/httpd/conf/httpd.conf
या/etc/apache2/sites-available/
में। - एक
VirtualHost
ब्लॉक जोड़ें: - ServerAdmin admin@example.com ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/html/example ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined
- साइट को सक्षम करें:
- sudo a2ensite example.com.conf
- sudo systemctl restart apache2
- Nginx के लिए:
/etc/nginx/sites-available/
पर जाएं और एक कॉन्फ़िगरेशन फ़ाइल बनाएं:- server {
listen 80;
server_name example.com www.example.com;root /var/www/html/example; index index.html; location / { try_files $uri $uri/ =404; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; }
} - साइट को सक्षम करें:
- sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
- sudo systemctl restart nginx
- SSL/TLS (वैकल्पिक लेकिन अनुशंसित)
- **Let’s Encrypt
- Let’s Encrypt का उपयोग करके एक निःशुल्क SSL प्रमाणपत्र प्राप्त करें:
- Apache के लिए:
- sudo certbot –apache -d example.com -d www.example.com
- Nginx के लिए:
- sudo certbot –nginx -d example.com -d www.example.com
- कॉन्फ़िगरेशन का परीक्षण करें
- यह सुनिश्चित करने के लिए कि सब कुछ सही ढंग से काम कर रहा है, अपने ब्राउज़र में अपने डोमेन पर जाएं।
इस प्रक्रिया के बाद, आपका डोमेन नाम आपके वेब सर्वर से लिंक हो जाएगा, जिससे आपकी वेबसाइट उस डोमेन के माध्यम से सुलभ हो जाएगी।