在一台服务器/IP上托管多个域 [英] Host Multiple Domains on One Server/IP

查看:187
本文介绍了在一台服务器/IP上托管多个域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了phpList和要添加到一台服务器中的Codeigniter项目.

I have phpList already setup and Codeigniter project that I want to add in one server.

位于/etc/httpd/conf.d/phplist.conf的phpList配置具有:

The phpList configuration which is located /etc/httpd/conf.d/phplist.conf has:

<VirtualHost *:80>
    ServerName phplist.example.com
    ServerAdmin admin@example.com
    DocumentRoot /var/www/phplist-3.0.5/public_html

    LogLevel warn
    ErrorLog /var/log/httpd/phplist_error.log
    CustomLog /var/log/httpd/phplist_access.log combined
</VirtualHost>

这里可能是CI项目的设置,但我不知道如何创建它.

Here is my possible setting for the CI project, but I don't know how to create one.

<VirtualHost *:80>
    ServerName listcsv.com
    ServerAdmin admin@listcsv.com
    DocumentRoot /var/www/citest/index.php
</VirtualHost>

/etc/httpd/conf/httpd.conf文件下面有一个IncludeOptional conf.d/*.conf,所以我认为这将包括phplist上的配置文件.

Below the /etc/httpd/conf/httpd.conf file has a IncludeOptional conf.d/*.conf so I think this would include the configuration file on phplist.

我不知道我应该去哪些设置和配置文件, 我应该在/etc/httpd/conf/httpd.conf上进行编辑还是将其与phpList配置一起添加到/etc/httpd/conf.d/phplist.conf?

I don't know what settings and where configuration file should I go, should I edit on /etc/httpd/conf/httpd.conf or just add it together with the phpList configuration at /etc/httpd/conf.d/phplist.conf?

我尝试通过http://phplist.example.com访问phplist,但无法访问该站点.

I tried accessing phplist at http://phplist.example.com but the site cannot be reached.

我可以通过转到 http://server-ip-address/lists/admin来访问phpList 在浏览器上.

I could access the phpList by going to http://server-ip-address/lists/admin on the browser.

此外,我无法访问CI项目.

Also, I cannot access the CI project.

推荐答案

我建议创建虚拟主机将存储在的目录,以及告诉Apache虚拟主机已准备好为网站服务的目录

I would recommend creating the directory that the virtual hosts will be stored in, as well as the directory that tells Apache that a virtual host is ready to serve the website

sudo mkdir /etc/httpd/sites-available # vhost files 
sudo mkdir /etc/httpd/sites-enabled # symbolic links for vhost enabled

告诉Apache在哪里寻找虚拟主机

Tell Apache where to look for virtual hosts

sudo vim /etc/httpd/conf/httpd.conf

在文件末尾添加此行

IncludeOptional sites-enabled/*.conf

保存并退出.

为每个网站/域创建自己的虚拟主机

For each website/domain create its own vhost

sudo vim /etc/httpd/sites-available/example1.com.conf
sudo vim /etc/httpd/sites-available/example2.com.conf
sudo vim /etc/httpd/sites-available/example3.com.conf

启用虚拟主机

sudo ln -s /etc/httpd/sites-available/example1.com.conf /etc/httpd/sites-enabled/example1.com.conf
sudo ln -s /etc/httpd/sites-available/example2.com.conf /etc/httpd/sites-enabled/example2.com.conf
sudo ln -s /etc/httpd/sites-available/example3.com.conf /etc/httpd/sites-enabled/example3.com.conf

我们完成了,重新启动Apache服务器以使更改生效

We done, restart your Apache server for the changes to take affect

sudo apachectl restart

别忘了将您的域指向Web服务器的公共IP地址.

Don't forget to point your domains to the web server's public IP address.

这篇关于在一台服务器/IP上托管多个域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆