Question

Issues with Deploying Website on DigitalOcean

Hi everyone,

I’m trying to deploy a website on DigitalOcean but I’m encountering some issues. Specifically, I’m having trouble with the setup of my droplet and the configuration of my DNS settings.

Here are the steps I’ve taken so far:

  1. Created a droplet with Ubuntu 22.04.
  2. Installed Apache and PHP.
  3. Configured the DNS records to point to my droplet’s IP address.

Despite this, I keep getting a “403 Forbidden” error when trying to access the site. I’ve verified that the files are in the correct directory and have set the correct permissions.

Has anyone encountered a similar issue or does anyone have advice on how to resolve this? Any help would be greatly appreciated!

Thanks in advance!


Submit an answer


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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hey 👋

It sounds like you’ve already done quite a bit of the setup, which is awesome!

A “403 Forbidden” error usually points to a permissions issue or a configuration setting in Apache. Let’s go through a few things to troubleshoot and get your site up and running:

Make sure that the files in your web directory (/var/www/html/ by default) are accessible by the Apache user (www-data). You can adjust the permissions with the following commands:

sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/

This ensures that Apache can read and execute the files.

Check your Apache configuration file to make sure everything is set up correctly. You’ll want to ensure that the DocumentRoot is pointing to the correct directory and that you’ve allowed access:

<VirtualHost *:80>
    ServerAdmin admin@yourdomain.com
    DocumentRoot /var/www/html
    ServerName yourdomain.com
    <Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

After making changes, don’t forget to restart Apache:

sudo systemctl restart apache2

If you’ve just updated your DNS settings, remember that DNS changes can take some time to propagate. You can check if the DNS records are correctly pointing to your droplet’s IP using a tool like whatsmydns.net.

If you’re using an .htaccess file, make sure it doesn’t have any rules that could be causing the 403 error. Sometimes, misconfigured .htaccess files can restrict access unintentionally.

Ensure that the necessary Apache modules are enabled, especially mod_rewrite if you’re using it for URL rewriting. You can enable it with:

sudo a2enmod rewrite
sudo systemctl restart apache2

Check your firewall settings to ensure that traffic on port 80 (HTTP) is allowed:

sudo ufw allow 'Apache Full'
sudo ufw reload

Finally, if you’re still having trouble, check the Apache error logs for more details:

sudo tail -f /var/log/apache2/error.log

The logs can give you specific hints about what might be going wrong.

Good luck, and happy deploying!

- Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.