First, you need to confirm node.js, npm and nginx have been installed on your server. We’ll skip this step.
Second, swith to your project directory, run the following command.
npm run build
or
yarn build (if you have installed yarn)
Then, adit the config file /etc/nginx/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root /home/ease/build; # the path of your project's build directory
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
Alter and save the file, then restart the service.
sudo service nginx restart
Now the React project is deployed.
0 Comments