Khandaker Toihidul Islam
Software Engineer
Backend : PHP | Mysql | Symfony | CakePhp | Wordpress | Drupal
Frontend : Node js | Vue js | React Js | Javascript | HTML | CSS | Bootstrap
Tools , Server : Nginx | Apache | Git | Jenkins | Jira | Asana | Silenium | Spira

Domain pointing to Digital Ocean – Nginx

Very simple steps

  1. create record and link to droplet
  2. Create a folder “sub.example.com” in /var/www/html/
  3. Create a config file “sub.example.com” in etc/nginx/site-availabe
server {
    listen 80;
    listen [::]:80;

    root /var/www/html/sub.example.com;
    index index.php index.html index.htm index.nginx-debian.html; 

    server_name sub.example.com www.sub.example.com;

    location / {
            try_files $uri $uri/ =404;
    }
    location ~ \.php$ {
        #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        include fastcgi_params;                
        fastcgi_intercept_errors on;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        fastcgi_param SCRIPT_FILENAME 
                $document_root/$fastcgi_script_name;
    }
}
3. Run this  ln -s /etc/nginx/sites-available/sub.example.com /etc/nginx/sites-enabled/sub.example.com
4. Test configuration       sudo nginx -t
5. Restart Nginx server    sudo systemctl restart nginx

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *