-7

I am working for a client that has a CentOS 7 server running Apache 2.4.6. I have a Zend Framework/PHP based website running on the server. It only has an IP address. No domain name is pointed to it. I just have the document root set to the public folder of the PHP website, and all is working fine.

Now they want me to add another website to the server. I'm a programmer, not a sys admin, so I'm not sure how to proceed. I'm familiar with setting up virtual hosts to run multiple websites, but they usually have unique domain names. How do you run multiple sites with only 1 IP?

scott80109
  • 133
  • 4
  • 11
  • 7
    I'm voting to close this question as off-topic because it shows zero research effort, but answers the question itself. (Use Virtual Hosts). – fukawi2 Mar 13 '15 at 04:16
  • 3
    He's not trolling there's lots of information about multiple sites on apache here on SF and on the wiser internet. The apache documentation even has examples. – user9517 Mar 13 '15 at 06:58
  • 1
    @scott80109 Why do you think I'm trolling? Why do you think Virtual Hosts are *not* the solution to your question? This is exactly why Virtual Hosting was created; to serve multiple sites while only using 1 IP address. – fukawi2 Mar 13 '15 at 08:42

2 Answers2

7

Create a virtual host for each site. You can run them all on port 80 (or 443).

This problem is exactly what virtual hosts are for. There's no requirement that each virtual host have a unique domain, only a unique hostname. See Name-based Virtual Hosts.

Andrew Schulman
  • 8,561
  • 21
  • 31
  • 47
-6

There are many options. A simple one would be to use ports, so that connecting to port 80 will show the current site, while port 81 would show the next site. But really, you should make sure you use hostnames.

  • Thank you. It should eventually use hostnames, but as of now, it is just an internal test server for doing some UAT. I guess ports are just specified in the vhost config? – scott80109 Mar 13 '15 at 04:42
  • Yes, you can just have a and a with different DocumentRoot settings. – Guilhem Malfre Mar 13 '15 at 06:07
  • 6
    The 1990s called and asked if they could have their ports back. This is just so wrong today, the only real way forward is to use name based vhosts. Additionally, CentOS has SELinux which restricts the ports that httpd can connect to and no, disabling SElinux is not a solution. – user9517 Mar 13 '15 at 07:18
  • @GuilhemMalfre just b/c it's *possible*, doesn't mean it should be *done*. Think about the poor user experience and confusion that would result from such a solution. – MDMoore313 Mar 13 '15 at 18:59
  • I didn't say it should be done. In fact, I said it should not be done. Also, user experience is not a factor here, since it is just his own testing site. – Guilhem Malfre Mar 16 '15 at 01:23