Are you willing to host react on Apache ??
Here are few steps.
sudo apt install apache2
This command will install apache on you machine.
and pull your react code using git
sudo git clone <your-git-repo>
sudo npm install
and build your react project using
sudo npm run build
you production will be in build folder now
You will have to mention path of build folder in .config files.
sudo vi /etc/apache2/apache2.conf
Comment existing Directory tags to avoid conflicts for example in my case I commented by adding # as shown below
#<Directory /> # Options FollowSymLinks # AllowOverride None # Require all denied #</Directory> # #<Directory /usr/share> # AllowOverride None # Require all granted #</Directory> #<Directory /var/www/> # Options Indexes FollowSymLinks # AllowOverride None # Require all granted #</Directory> #<Directory /srv/> # Options Indexes FollowSymLinks # AllowOverride None # Require all granted #</Directory>
Here in my case build of react is at /var/www/html/reactproject/build it may be different in your case replace this with you present build directory in following code
<VirtualHost *:80> #ServerName yourserver.com DocumentRoot /var/www/html/reactproject/build # Relax Apache security settings <Directory /var/www/html/reactproject/build> Allow from all Options -MultiViews Require all granted </Directory> </VirtualHost>
Every time you edit Apache files restart apache by using following command
sudo systemctl restart apache2.service
sudo systemctl status apache2.service
You are good to go. for further assistance feel free to contact me will love to help you out
IF YOU LIKED THIS ARTICLE MAKE SURE TO FOLLOW ME ON DEV.TO AND ON INSTAGRAM