欢迎光临
我们一直在努力

CentOS7-配置Apache虚拟主机

With Apache, you can use virtual hosts to direct http traffic for a given domain name to a particular directory (i.e. the root directory of the website for the domain in the request). This feature is commonly used to host multiple websites, but it’s suggested to using it for every website on your server including the first.

Install the Apache web server

If you haven’t have Apache installed on you server, please refer to this passage to install Apache first: CentOS7安装LAMP环境. And then return back to do the following operations.

Set up the virtual host

Create content for the website

Upload your files you prepared to the public_html folder you created in the last section.

Configure your virtual host directories

We’re going to copy a configuration usually used in Ubuntu/Debian and create two directories: one to store the virtual host files (sites-available) and the other to hold symbolic links to virtual hosts that will be published (sites-enabled).

Create sites-available and sites-enabled directories

Edit your Apache configuration file

Edit the main configuration file (httpd.conf) so that Apache will look for virtual hosts in the sites-enabled directory.

Create virtual host file

We’re going to build it from a new file in your sites-available directory.

1. Create a new config file:

2. Paste the code bellow in, replacing your own domain for example.com:

The lines ErrorLog and CustomLog are not required to set up your virtual host, but we’ve included them, in case you do want to tell Apache where to keep error and request logs for your site.

3. Save and close the file.

4. Enable your virtual host with a sym link to the sites-enabled directory.

5. Restart Apache

Reference:
  • Configure Apache Virtual Hosts – CentOS 7: https://hk.godaddy.com/help/configure-apache-virtual-hosts-centos-7-17338
赞(0) 打赏(金额可任意指定)
未经允许不得转载:峰间的云 » CentOS7-配置Apache虚拟主机
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

上海宝山顾村棉被加工店 专业加工新旧棉被

查看详情了解一下

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏