3

I am using the Wordpress REST API to provide a back end to my React JS front end. Right now both are running on separate Apache servers on AWS and all works well.

Is it possible to run both on the same server? So that my React front end is making requests to Wordpress on the same server?

1 Answer 1

3

Sure, if you want to use Apache to handle distributing your frontend and handling the WP backend, read up on Virtual Hosts: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts

The gist of it is that you'll have a VH for your frontend

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName example.com
    ServerAlias www.example.com <-- see here
    DocumentRoot /var/www/example.com/client
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

and a VH for your backend

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName example.com
    ServerAlias api.example.com <-- and here
    DocumentRoot /var/www/example.com/server
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the reply. Makes sense. Is it possible to test this without having to purchase and setup a domain name, using the IP or current DNS of the AWS instance instead for example? Or would that involve a different setup, e.g. Aliases
To test it without a domain, use different ports and the instance IP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.