oot@ubuntu-s-2vcpu-4gb-120gb-intel-lon1-01:~/Epos-F# sudo ls -l /root/Epos-F/build
total 516
-rwxr-xr-x 1 www-data www-data 447 May 20 09:05 asset-manifest.json
-rwxr-xr-x 1 www-data www-data 424159 May 20 09:03 cloud.png
-rw-r--r-- 1 www-data www-data 639 May 20 09:05 index.html
-rwxr-xr-x 1 www-data www-data 79838 May 20 09:03 logo.png
-rwxr-xr-x 1 www-data www-data 471 May 20 09:03 manifest.json
-rwxr-xr-x 1 www-data www-data 67 May 20 09:03 robots.tx
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
Hi there,
It’s not recommended to place your website’s content in the root directory (/root
). Instead, it’s best practice to move it to the /var/www/html
directory, which is the default directory for serving web content on many web servers, including Nginx.
Move the Build Files:
Move your build files from /root/Epos-F/build
to /var/www/html/Epos-F
. You can do this using the following commands:
sudo mkdir -p /var/www/html/Epos-F
sudo mv /root/Epos-F/build/* /var/www/html/Epos-F/
Update Permissions:
Ensure the files have the correct ownership and permissions. They should be owned by the www-data
user and group:
sudo chown -R www-data:www-data /var/www/html/Epos-F
sudo chmod -R 755 /var/www/html/Epos-F
Update Nginx Configuration:
Edit your Nginx configuration to point to the new directory. Open your Nginx configuration file, which is usually found in /etc/nginx/sites-available/
or /etc/nginx/conf.d/
. You can use a text editor like nano
:
sudo nano /etc/nginx/sites-available/default
Update the root
directive to point to the new location:
server {
listen 80;
server_name your_domain_or_IP;
root /var/www/html/Epos-F;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}
Restart Nginx: After making these changes, restart the Nginx service to apply the new configuration:
sudo systemctl restart nginx
Check Nginx Status: Ensure that Nginx is running and has no configuration errors:
sudo systemctl status nginx
If you encounter any errors, check the Nginx error log for more details:
sudo tail -f /var/log/nginx/error.log
Let me know how it goes!
- Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.