W3Ask











How Linux works
#ad
Linux Basics for Hackers
#ad
Linux command line
#ad
Linux pocket guide
#ad
Linux programming
#ad
Linux administration
#ad
Linux Bible
#ad


HOME  >  SOFTWARE  >  LINUX

How to add a domain name in Apache2



Adding a domain name in the server will allow us to redirect this one to the folder that contains the files of the respective site. This is a tricky operation in some cases (https), but is usually quite simple if you only use the http protocol.

Above all, you need to create an A record that points to the server's IP address in the interface of its domain name provider.

Nowadays, it takes about 30 minutes for the recording to be effective. Previously, it could take 2-3 days, then later 24 hours.

Then we will create a configuration file in our Apache server:

cd /etc/apache2/sites-available
cp 000-default.conf yourdomain.com.conf
nano yourdomain.com.conf

Example of a configuration file:

<VirtualHost *:80>
ServerAdmin youremail@gmail.com
ServerName www.example.com
ServerAlias example.com

DocumentRoot /var/www/www.example.com/public_html
ErrorLog ${APACHE_LOG_DIR}/www.example.com-error.log
CustomLog ${APACHE_LOG_DIR}/www.example.com-access.log combined
</VirtualHost>

We create a shortcut in sites-enabled that returns to the configuration file:

cd ../sites-enabled
ln -s ../sites-available/example.com.conf example.com.conf

We activate the domain name and we restart Apache:

a2ensite yourdomain.com
service apache2 restart


Note: Commissions may be earned from the links above.


This page contains references to products from one or more of our advertisers. We may receive compensation when you click on links to those products. For an explanation of our advertising policy, please visit this page.









Related posts:


Point a domain name to a server IP address
https://w3ask.com/point-domain-name-server-ip-address/
On Godaddy, for example, you can point a domain name to a server IP with the A record : Click on manage your domain names > Click on the ...
How to setup Apache2 on a Debian server
https://w3ask.com/setup-apache2-debian-server/
Here is how to install Apache2 easily and fast if you want an alternative to nginx, and then add website conf files for example. Setup Apache ...
How to restart Apache2 on a Debian server
https://w3ask.com/restart-apache2-debian-server/
It may be useful to restart Apache2 after modifying a domain name configuration file, or after installing an application that is useful for ...
Error message : Socket bind() to port 25 for address 127.0.0.1 failed
https://w3ask.com/error-message-socket-bind-port-25-address-127-0-0-1-failed/
You may get an error message stating that the socket binding with port 25 for the local address failed with Exim4. Exim4 is an application that ...
Add a cronjob for rkhunter
https://w3ask.com/add-cronjob-rkhunter/
You can add a cronjob for rkhunter to have a checkup every day at a certain hour. Cronjob is very useful. With the addition of tasks you can ...








Linux Basics for Hackers
#ad


Linux command line
#ad


Linux Bible
#ad


How Linux works
#ad


Linux administration
#ad


Linux programming
#ad


Linux pocket guide
#ad





Languages

  • English
  • French
  • German
  • Italian
  • Dutch
  • Portuguese
  • Spanish

Know us

  • About
  • Contact
  • Categories list

Privacy

  • Privacy & Cookie Policy
  • Advertising policy
W3Ask © 2023. All rights reserved.
Disclaimer:

When you click on links to various merchants on this site and make a purchase, this can result in this site earning a commission. Affiliate programs and affiliations include, but are not limited to, the eBay Partner Network.

As an Amazon Associate I earn from qualifying purchases.

This page includes affiliate links for which the administrator of W3Ask may earn a commission at no extra cost to you should you make a purchase. These links are indicated using the hashtag #ad.


Information:

We do not assume any responsibility for the data displayed on our website. Please use at your own risk. Some or all of this data may be out of date or incomplete, please refer to the technical page on the respective manufacturer's website to find the latest up-to-date information regarding the specifics of a product.


Trading System Forex GadgetVersus GadgetVersus France