Apache 2 configuration domain name binding method details

  • 2020-05-24 06:41:22
  • OfStack

preface

Recently, I installed a new OJ system. Since it is hard to remember to use ip all the time, I decided to attach a domain name to it. In the process of configuration also encountered 1 some problems, now summarize the following to share with you, convenient to have the need of friends reference learning.

Methods the following

Baidu online a lot of tutorials, found that we are in the configuration of httpd.conf file, but I myself in Linux below apache did not have this file, in the spirit of try 1, I created a new httpd.conf, and then use the online code copy in.


<VirtualHost  your ip:80>
  ServerAdmin webmaster@localhost
  DocumentRoot /var/www/html/JudgeOnline
  ( The location of the folder you want to bind to, the root directory in html I'm going to bind to JudgeOnline Folder. When you're done, delete this row )
  ServerName  Your domain name 
</VirtualHost>

Then the domain name is bound to ip. After being able to bind, I found that, in any case, all the pages I visited were under html, not under JudgeOnline as I wanted. This is depressed, I get along for a long time, then went to check the Apache directory under the meaning of these several files, in fact, Apache initial call apache2.conf this file, and then call other files in this file.

When I opened apache2.conf, I found that it actually called mods-enabled, conf-enabled, sites-enabled, and ports.conf, so I made a httpd.conf, but it wasn't actually called in Apache2, so what we should have changed is the configuration file starting with 000 under sites-enabled. In there is the same configuration as in the other tutorial 1, and restart apache when you are done.

Apache2 restart instructions also changed, see apache2. conf inside you will find there are instructions, before apache location is in/usr bin/apache2, but present position/etc/init d/apache2, so restart instructions


/etc/init.d/apache2 restart

OK, now I have successfully completed the domain name binding, and also let me know the configuration of apache2, this wave is not bad.

conclusion

The above is the whole content of this article, I hope the content of this article to your study or work can bring 1 definite help, if you have questions you can leave a message to communicate.


Related articles: