Home  >  Q&A  >  body text

nginx - Can the same server set up two domain names to access two different projects?

For example, there are two different projects developed by PHP and Ruby respectively and want to use them on the same server.
URL of PHP project:
http://site1.com
Ruby project URL:
http://site2.com
There is a port problem here, the default is 80. It is of course no problem to add another port after another URL to access, but if not, how to use Web Server settings?
Apache and Nginx both work. Is there a solution?

黄舟黄舟2713 days ago464

reply all(4)I'll reply

  • 阿神

    阿神2017-05-16 17:06:35

    Use nginx reverse proxy to change one of the listening ports to another port, add a virtual host to nginx, and then reverse proxy it

    reply
    0
  • 为情所困

    为情所困2017-05-16 17:06:35

    Both nginx and apache can directly create two virtual hosts, just use different directories, which is equivalent to putting two websites on one server. It is very simple.

    reply
    0
  • 阿神

    阿神2017-05-16 17:06:35

    Two server nodes are configured in nginx, both listening 80, but the server_name is different

    reply
    0
  • 阿神

    阿神2017-05-16 17:06:35

    Just set up different virtual hosts, this is true for both nginx and apache.

    reply
    0
  • Cancelreply