Running development version of create-react-app in Apache - reactjs

I've looked around for this everywhere and there is tonnes of documentation on how to DEPLOY apps created with create-react-app to apache which is fairly straight forward, however there's barely anything on how to run your development environment on apache.
I'm working on an app that's going to be deployed on an apache server and so I want to mimic the environment during development but can't figure out how to set it up correctly. Is it even possible?
I have the following conf file set up for my site - but because the index.html file doesn't directly include the JS required for React to do its magic, I just get an empty page with the <div id="root"></div> holder.
Conf:
<VirtualHost *:80>
ServerName warehouse.local.com
DocumentRoot /var/www/warehouse-local/public
ErrorLog /var/log/apache2/warehouse.local.com-error_log
CustomLog /var/log/apache2/warehouse.local.com-access_log common
<Directory /var/www/warehouse.local.com>
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Anyone got any advice on how to achieve what I'm after?

emmm,why you want to run dev version in Apache?
I think ,I will need Apache just when I deploy my prduction version of react app.

Related

iRedMail 0.9.9 with Apache2, how to get the web interface working

Could anyone tell me how, or point me into a working tutorial on how to get iRedMail working when using Apache2?
Installation is succesful, all I need now is the web interface. We cannot use Nginx because there are a lot of websites hosted on this server, so we have to stick to Apache.
I hope someone can tell me how we can get the web interface working with Apache.
iRedMail version: 0.9.9
Deployed with: installer
Linux/BSD distribution: Ubuntu 18.04
Backend: MariaDB
Web server: Apache2
Been Googling for 2 days now without finding a working solution unfortunately.
The URL that I installed it on should be webmail.mydomain.com
Best regards
The working example for me is below:
<VirtualHost *:443>
...
WSGIDaemonProcess iredadmin user=iredadmin threads=15
WSGIProcessGroup iredadmin
WSGIScriptAlias /iredadmin /opt/www/iredadmin/iredadmin.py/
Alias /iredadmin/static /opt/www/iredadmin/static/
<Directory /opt/www/iredadmin/>
Order deny,allow
Allow from all
Require all granted
</Directory>
...
</VirtualHost>

Why does my Index of Directory shown if I access my website

In the past month I work on pure php laravel framework which the project is already done and running on live. This month our team asking for revising the project to reactjs with laravel php framework. Which the development stage is already done this past few weeks. Our team trying to deploy in production in which they encounter one problem when we access the website Ex. www.myproject.com the page show the root project folder it look like this.
Note: That my project is fresh and we not configure anything to htaccess.
The scenario before i deploy the project:.
npm install
then
npm run production
to get the final index.js file which will contain all the code bundled
Package.json:
Webpack.config.js
Web server
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName appname.com
ServiceAlias www.appname.com
DocumentRoot /var/www/appname/public
<Directory "/var/www/appname/public">
Options FollowSymLinks
ReWriteEngine On
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Source

Apache structure and config for React app with self hosted headless CMS

I want to build a React powered app that uses a self hosted instance of Cockpit to fetch data and host both on an Apache server.
I'm familiar with installing Cockpit to the default DocumentRoot, but I'm not sure where to put the frontend files. I don't want to just messily dump them in the same folder, since there'd probably be also conflicts with Cockpit files.
How can I seperate both apps in a clean way and tell Apache to serve them correctly?
After doing a bit of research with more specific keywords, I found the answer myself:
Basically you want to create folders for both app and API (i.e. Cockpit) in your DocumentRoot. Then you are able to set Virtual Hosts in your Apache configuration like this (assuming your folders are named client and server and your DocumentRoot is /var/www/html/):
<VirtualHost *:80>
DocumentRoot "/var/www/html/client"
ServerName www.example.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/html/server"
ServerName api.example.com
</VirtualHost>
API calls can then be made via the api.example.com subdomain.
See https://httpd.apache.org/docs/2.4/vhosts/examples.html for more examples.

Apache localhost authentication

I am trying to setup up basic authentication to a folder on my localhost running apache. Currently the app runs fine without authentication. I have setup a virtual host so I can access my application through dev.myapp.com
The code I add to my .htaccess file to force authentication is:
<Directory "/Users/myusername/Sites/dev.myapp.com">
AuthType Basic
AuthName Test
AuthBasicProvider file
AuthUserFile /etc/apache_users
Require valid-user
</Directory>
I have created a user.
When I type dev.myapp.com into the browser I get an internal server error. I am fairly new to apache. A point in the right direction would be appreciated.
Thanks.
First off, using .htaccess is a bit slower and requires that you have set the AllowOverride directive accordingly. It is recommended that you instead use httpd.conf to establish basic authentication. The Apache documentation explains all of this so check out this link http://httpd.apache.org/docs/2.2/howto/auth.html.
Regardless, I think I see the error. Your <Directory> tag looks a little odd. I understand the name of your site is dev.my.app.com but is that the actual name of the folder where the site dev.myapp.com points to on your server? Your httpd.conf file should have an entry like this:
<VirtualHost *>
DocumentRoot "document/root/path"
Other directives here
</VirtualHost>
The DocumentRoot is where Apache directs all incoming web traffic. If you are trying to establish authentication for your entire site, the value of DocumentRoot is most likely what you would want in your Directory tag ... making it <Directory /document/root/path>.
To locate httpd.conf look in in /etc/apache2/. Make sure to restart your server after you change the file (sudo /etc/init.d/apache2 restart). Hope that helps, please update if you haven't already resolved the problem.

How to install cakephp on localhost?

I wanna to know how to install cakephp on localhost?
Please explain me.
I usually make an apache and mysql installation on a linuxbox. I can use windows too, however I do not recommend it ;)
So, I usually make a new entry into the /etc/hosts file to make a sitename available to cakephp.
127.0.0.1 localhost caketest.local
next step to copy all cakephp files into a subdirectory inside /home/myusername/public_html/caketest
app
cake
index.php
plugins
README
vendors
.htaccess
then I set up the site to apache (not neccessary),
<VirtualHost *:80>
DocumentRoot "/home/myusername/public_html/caketest"
ServerName caketest.local
# This should be omitted in the production environment
SetEnv APPLICATION_ENV development
<Directory "/home/myusername/public_html/caketest">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
restart apache. you also need to edit the .htaccess files and place a RewriteBase directive with hte path to the actual directory, e.g.
RewriteBase /~myusername/caketest
create a database, set the db connection in cake config files and that's all.
you can point your browser to http://caketest.local
if you do not want a test site url you can skip hosts, and apache vhost creation, but the url to use should be http:/localhost/~myusername/caketest
another important thing is to enable userdir modul in apache, and also check if using php is enabled in userdirs too.
If you're on windows, get WAMP. Install it, then download CakePHP in C:\wamp\www\. Extract CakePHP in that folder so you have a folder kind of like this: C:\wamp\www\cakephp\. Now you can access the installation by going to localhost/cakephp/.
An old article of mine but still quite relevant:
Installing CakePHP
Assuming you have a *AMP setup (Apache+MySQL+PHP), just copy the files to your htdocs folder. On Ubuntu, it's /var/www, so you would create /var/www/myApp and copy the whole Cake structure into there, ending up with something like:
/var/www/myApp/app/
/var/www/myApp/cake/
/var/www/myApp/vendors/
/var/www/myApp/index.php
/var/www/myApp/.htaccess
Then you can access your app by the url: http://localhost/myApp

Resources