I already have a digital droplet created and using it on another site. I am using laravel forge.

I would like to add another site to the same droplet. Now I added the hostname the .com and www .com version to the droplet. However, when I visit the site ‘server IP could not be found’.

When creating the project, in digital ocean asks me if I would like to move the resource(droplet) over from the previous site to this new one. But if I do that would that would it affect the other site?

If anyone could provide some guidance that would be greatly appreciated.

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.

×
2 answers

Are you adding a new website/webapp?

Not sure how Forge handles this, but the normal procedure is to add a new virtual host if you are using Apache. (/etc/apache/sites-available)

Don’t have to mess with the droplet.

  • Hi @ksorbo it’s a new website.

    In terms of Forge, I simply added another website using the existing server which is showing me it’s functioning. In DO under networks added the other two domains @ and name. At Namecheap (purchased domain) I added the custom DNS ns1.digitalocean.com, 2, and 3. But it’s still showing me a 404 when visiting the site?

    I really don’t have experience with Apache, hence why I choose Forge, it handles the server stuff.

    • I was searching all over to figure this out because I need to do exactly what you want to do. It is a little confusing between Forge and Digital Ocean. Here is the setup (I’m running Ubuntu and NGINX)

      1. A single droplet in DO

      2. Create 2 (or however many ‘sites’ you want) Projects under Digital Ocean. The first site will have the 'Droplet’ and 'Domain’ under it (which already worked in your case and mine).

      3. The second 'Project’ in DO will only have a 'Domain’ section…(I thought you had to have a Droplet for each project, but then it would ask you to move resources of the single droplet).

      4. Create your DNS 'A’ record to point your domain to the IP of your existing Droplet. Both DO projects should now point to the same IP of the Droplet. Don’t forget to add CNAME records to include www

      5. In Forge you should have both 'Sites’ setup and deployed with the correct Git repos, env files (if needed), databases, etc.

      6. You already updated your nameservers on your domain provider, so that is done.

      -There isn’t much setup involved on the Forge side of things to get this to work. Just make sure you have the right path to the web route of your project (example: Laravels is /public , my Yii app is /app/web). It just depends on the application.

      -IF you are running NGINX, you can verify the 2 sites are setup by FTP/SSH into your DO box, go to root folder then /etc/nginx/site-available (or sites-available, its symlinked).. You should see your 2 sites each have their own file. This is how NGINX knows how to handle both domains to one IP address. If you’re using Apache it should be something similar, but again Forge takes care of creating the 2 virtual hosts for you.

      Thats it, one thing to note is that your browser may have cached your DNS record before you had it properly setup. Clearing cache, using a different browser or incognito mode will ensure its cleared out.

      Hope this helps

      • Hello,

        Thanks for this detailed message. I have done everything you mentioned, confirming both site-available inside Nginx.

        The only thing that might differ is instead of CNAME I just used ‘A’ records.

        Images of both the nginx status and what DO looks like.

        https://ibb.co/gvj0758
        https://ibb.co/GnjqY8L
        https://ibb.co/bF69BF6

        • Are you still getting a 404 or ‘Server Not Found’? The DNS entries look ok, but you might be putting them under the wrong project in DO.

          I have 2 projects in DO:

          The first one has the Droplet and 1 Domain entry

          The second just has 1 Domain entry pointing to the IP of the Droplet.

          You dont need 2 separate entires for project1.com and www.project1.com. You simply need a CNAME record under each domain to map www.project1.com -> project1.com

          Check my screenshots, hopefully they help. Sorry for the redactions but my projects are still under development.

          https://ibb.co/Rymm6Pg
          https://ibb.co/CzVyKHB
          https://ibb.co/nDP6zCJ

        • I replied with screenshots and is awaiting moderation. You need to have the first domain in your 1st project (with the droplet) and your second domain in project 2 (without a droplet). Each project will have only one domain record / DNS settings for itself.

          Also, you don’t need to make separate DNS records for www. Simply make one project1.com pointed to your droplets IP, then create a CNAME record under the single DNS Record for each Project.

        • A 404 most likely means the path to your web (index file) is incorrect. You will need to double check this path in Forge under each site.

          • I came across this error in forge I wonder if this has something to do with it

            ls: cannot access ’/home/forge/123.com/storage/logs/*.log’: No such file or directory

            server {
                listen 443 ssl http2;
                listen [::]:443 ssl http2;
                server_name ###.com;
                server_tokens off;
                root /home/forge/###.com/public;
            
            
            
                ssl_protocols TLSv1.2;
                ssl_ciphers ECDHE-RSA-AES256-GCM-SHA5SHA384:DHE-RS
                ssl_prefer_server_ciphers on;
                ssl_dhparam /etc/nginx/dhparams.pem;
            
                add_header X-Frame-Options "SAMEORIGIN";
                add_header X-XSS-Protection "1; mode=block";
                add_header X-Content-Type-Options "nosniff";
            
                index index.html index.htm index.php;
            
                charset utf-8;
            
            
                location / {
                    try_files $uri $uri/ /index.php?$query_string;
                }
            
          • Yeah, so ssh into your Droplet, cd /home/forge/123.com/ make sure there is a folder called ‘storage’ (if not type: sudo mkdir storage) and make sure there is a folder called 'logs’ inside of that. Then create a file called .log (looks like it is a hidden file with the . prefix)..alternativley find the place in your code that is trying to access that path and comment it out. Make sure your permissions are correct on the folders, otherwise you will get a 403

thanks @VIMaster that issue is now resolved. I created the file as you mentioned. Still getting the 404 though. I reached out to support hoping they can provide more insight. Everything I’ve checked so far seems to be functioning correctly.

Submit an Answer