Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to run React JS and Wordpress on the same web server?

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?

like image 652
Brien Crean Avatar asked Apr 09 '26 16:04

Brien Crean


1 Answers

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>
like image 145
Tyler Sebastian Avatar answered Apr 12 '26 07:04

Tyler Sebastian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!