$ npm install -g create-react-app
$ create-react-app my-app
$ cd my-app
$ npm run build
- copy and paste everything in build folder to your server
- edit /etc/httpd/conf/httpd.conf
<Directory "/var/www/html">
...
AllowOverride All
...
</Directory>
- 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
<Directory "/var/www/html">
#
# 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
</Directory>
You can see my repository https://github.com/srbin25/Express-react-app , where you can add more componetes in react app and if you run npm start you gete all app on port 80. After command npm init you must make node - express server file like me. There get
// config port of server
const port = process.env.PORT || 80;
And when you run npm start you can get all file who you can copy on your host. But, for image or other file like this you must get here src links for him. Like is img src="http://localhost/path-where-is-your-file/name.ext" .
In this example local host there your need files is folder dist like root folder. That say code from file webpack.config.js
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},