From c9860a0591238ac7001e59778aa57b30c24cdb3a Mon Sep 17 00:00:00 2001 From: Mehran Dehghanian Date: Sat, 6 Mar 2021 13:19:03 +0330 Subject: [PATCH] Add 'Host React App on Apache server' --- Host-React-App-on-Apache-server.md | 81 ++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Host-React-App-on-Apache-server.md diff --git a/Host-React-App-on-Apache-server.md b/Host-React-App-on-Apache-server.md new file mode 100644 index 0000000..1911b76 --- /dev/null +++ b/Host-React-App-on-Apache-server.md @@ -0,0 +1,81 @@ +# Host react application on Apache server + +### Step 1 : Create your app + +``` +$ npm install -g create-react-app +$ create-react-app my-app +``` + +### Step 2 : Build it for production + +``` +$ cd my-app +$ npm run build +``` + +### Step 3 : deploy + +- copy and paste everything in build folder to your server +- edit /etc/httpd/conf/httpd.conf + +``` + + ... + AllowOverride All + ... + +``` + +- create a “.htaccess” file in html directory and add this snippet : + +``` +Options -MultiViews +RewriteEngine On +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^ index.html [QSA,L] +``` +or edit /etc/httpd/conf/httpd.conf + +``` + + # + # Possible values for the Options directive are "None", "All", + # or any combination of: + # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews + # + # Note that "MultiViews" must be named *explicitly* --- "Options All" + # doesn't give it to you. + # + # The Options directive is both complicated and important. Please see + # http://httpd.apache.org/docs/2.4/mod/core.html#options + # for more information. + # + Options Indexes FollowSymLinks + + # + # AllowOverride controls what directives may be placed in .htaccess files. + # It can be "All", "None", or any combination of the keywords: + # Options FileInfo AuthConfig Limit + # + AllowOverride All + + Options -MultiViews + RewriteEngine On + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.html [QSA,L] + + # + # Controls who can get stuff from this server. + # + Require all granted + +``` + + +### Reference + +[Host react application on Apache server](https://medium.com/@kayode.adechinan/host-react-application-on-apache-server-90c803241483) + +### Source +https://gist.github.com/ywwwtseng/63c36ccb58a25a09f7096bbb602ac1de \ No newline at end of file