{"id":19946698,"url":"https://github.com/codeincrypt/site-setup-with-ssl-ubuntu","last_synced_at":"2026-03-03T20:33:03.938Z","repository":{"id":164082575,"uuid":"438644481","full_name":"codeincrypt/site-setup-with-ssl-ubuntu","owner":"codeincrypt","description":"Enable new webiste on Ubuntu server with SSL Certificate","archived":false,"fork":false,"pushed_at":"2021-12-15T14:24:52.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-01T14:17:22.646Z","etag":null,"topics":["acme","apache","letsencrypt","ssl"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeincrypt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-15T13:43:23.000Z","updated_at":"2024-02-21T09:29:06.000Z","dependencies_parsed_at":"2023-07-13T07:15:58.207Z","dependency_job_id":null,"html_url":"https://github.com/codeincrypt/site-setup-with-ssl-ubuntu","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codeincrypt/site-setup-with-ssl-ubuntu","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeincrypt%2Fsite-setup-with-ssl-ubuntu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeincrypt%2Fsite-setup-with-ssl-ubuntu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeincrypt%2Fsite-setup-with-ssl-ubuntu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeincrypt%2Fsite-setup-with-ssl-ubuntu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeincrypt","download_url":"https://codeload.github.com/codeincrypt/site-setup-with-ssl-ubuntu/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeincrypt%2Fsite-setup-with-ssl-ubuntu/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30058293,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T18:21:05.932Z","status":"ssl_error","status_checked_at":"2026-03-03T18:20:59.341Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acme","apache","letsencrypt","ssl"],"created_at":"2024-11-13T00:31:57.180Z","updated_at":"2026-03-03T20:33:03.916Z","avatar_url":"https://github.com/codeincrypt.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Set Up Apache Virtual Hosts on Ubuntu\n\n## 1. Set Up your Website on Apache\n\n### Step 1 — Create the Directory Structure\n\nWe’ll first make a directory structure that will hold the website. You should replace these with your actual domain names\n\n```\nsudo mkdir -p /var/www/yourdomain.com/public_html\n```\n\n### Step 2 — Grant Permissions\n\nChange the permissions to our current non-root user to be able to modify the files\n\n```\nsudo chown -R $USER:$USER /var/www/yourdomain.com/public_html\n```\nEnsure that read access is permitted to the general web directory and all of the files and folders it contains.\n\n```\nsudo chmod -R 755 /var/www\n```\n### Step 3 — Create New Virtual Host Files\n\n```\n\u003cVirtualHost *:80\u003e\n    ServerAdmin admin@yourdomain.com\n    ServerName yourdomain.com\n    ServerAlias www.yourdomain.com\n    DocumentRoot /var/www/yourdomain.com/public_html\n    ErrorLog ${APACHE_LOG_DIR}/error.log\n    CustomLog ${APACHE_LOG_DIR}/access.log combined\n\u003c/VirtualHost\u003e\n```\n\n### Step 4 — Demo Pages for Each Virtual Host\n\nEdit Your welcome page\n```\nnano /var/www/example.com/public_html/index.html\n```\n\n```\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eWelcome to yourdomain.com!\u003c/title\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003ch1\u003eSuccess! The example.com virtual host is working!\u003c/h1\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Step 5 — Enable the New Virtual Host Files\n\nWith our virtual host files created, we must enable them. We’ll be using the a2ensite tool to achieve this goal.\n```\nsudo a2ensite example.com.conf\n ```\nNext, disable the default site defined in 000-default.conf:\n```\nsudo a2dissite 000-default.conf\n ```\nWhen you are finished, you need to restart Apache to make these changes take effect and use systemctl status to verify the success of the restart.\n```\nsudo systemctl restart apache2\n ```\nNow your website was live\n\n## 2. Set Up Node Js and Secure Apache with Let's Encrypt on Ubuntu\n\n### Step 1 — Create New Virtual Host Files\n\n```\nsudo nano /etc/apache2/sites-available/yourdomain.com.conf\n```\n### Step 2 — Edit the yourdomain.com.conf\n```\n\u003cVirtualHost *:80\u003e\n    ServerName example.com\n    ServerAlias www.example.com\n\n    ProxyRequests Off\n    ProxyPreserveHost On\n    ProxyVia Full\n\n    \u003cProxy *\u003e\n        Require all granted\n    \u003c/Proxy\u003e\n\n    ProxyPass / http://127.0.0.1:8080/\n    ProxyPassReverse / http://127.0.0.1:8080/\n\u003c/VirtualHost\u003e\n```\nSave this conf file\n\n### Step 3 — Enable the New Virtual Host Files\nWith our virtual host files created, we must enable them. We’ll be using the a2ensite tool to achieve this goal.\n\n```\nsudo a2ensite yourdomain.com.conf\n```\nNext, disable the default site defined in 000-default.conf:\n```\nsudo a2dissite 000-default.conf\n```\nNext, need to restart Apache to make these changes take effect and use systemctl status to verify the success of the restart.\n```\nsudo systemctl restart apache2\n```\n### Step 3 — Installing Certbot\nWe need to install the Certbot software on your server. We’ll use the default Ubuntu package repositories for that.\n\n```\nsudo apt install certbot python3-certbot-apache\n```\n### Step 4 — Checking your Apache Virtual Host Configuration\n```\nsudo apache2ctl configtest\n```\n\nYou should get a Syntax OK as a response. If you get an error, reopen the virtual host file and check for any typos or missing characters. Once your configuration file’s syntax is correct, reload Apache so that the changes take effect:\n```\nsudo systemctl reload apache2\n```\nWith these changes, Certbot will be able to find the correct VirtualHost block and update it.\n\n### Step 5 — Obtaining an SSL Certificate\nThe Apache plugin will take care of reconfiguring Apache and reloading the configuration whenever necessary.\n\n```\nsudo certbot --apache\n```\nThis script will prompt you to answer a series of questions in order to configure your SSL certificate.\n\nOutput\n```\nSaving debug log to /var/log/letsencrypt/letsencrypt.log\nPlugins selected: Authenticator apache, Installer apache\nEnter email address (used for urgent renewal and security notices) (Enter 'c' to\ncancel): you@your_domain\n```\nAfter providing a valid e-mail address, hit ENTER. You will then be prompted to confirm if you agree to Let’s Encrypt terms of service. You can confirm by pressing A and then ENTER:\n```\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\nPlease read the Terms of Service at\nhttps://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must\nagree in order to register with the ACME server at\nhttps://acme-v02.api.letsencrypt.org/directory\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n(A)gree/(C)ancel: A\n```\nNext, you’ll be asked if you want to share your email. If no, type N. Otherwise, type Y. Then, hit ENTER.\n```\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\nWould you be willing to share your email address with the Electronic Frontier\nFoundation, a founding partner of the Let's Encrypt project and the non-profit\norganization that develops Certbot? We'd like to send you email about our work\nencrypting the web, EFF news, campaigns, and ways to support digital freedom.\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n(Y)es/(N)o: N\n```\nThe next step will prompt you to inform Certbot of which domains you’d like to activate HTTPS for.\nIf you’d like to enable HTTPS for all listed domain names (recommended), you can leave the prompt blank and hit ENTER to proceed.\nOtherwise, select the domains you want to enable HTTPS for by listing each appropriate number, separated by commas and/ or spaces, then hit ENTER.\n```\nWhich names would you like to activate HTTPS for?\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n1: your_domain\n2: www.your_domain\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\nSelect the appropriate numbers separated by commas and/or spaces, or leave input\nblank to select all options shown (Enter 'c' to cancel): \n```\nYou’ll see output like this:\n```\nObtaining a new certificate\nPerforming the following challenges:\nhttp-01 challenge for your_domain\nhttp-01 challenge for www.your_domain\nEnabled Apache rewrite module\nWaiting for verification...\nCleaning up challenges\nCreated an SSL vhost at /etc/apache2/sites-available/your_domain-le-ssl.conf\nEnabled Apache socache_shmcb module\nEnabled Apache ssl module\nDeploying Certificate to VirtualHost /etc/apache2/sites-available/your_domain-le-ssl.conf\nEnabling available site: /etc/apache2/sites-available/your_domain-le-ssl.conf\nDeploying Certificate to VirtualHost /etc/apache2/sites-available/your_domain-le-ssl.conf\n```\nNext,\n```\nPlease choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n1: No redirect - Make no further changes to the webserver configuration.\n2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for\nnew sites, or if you're confident your site works on HTTPS. You can undo this\nchange by editing your web server's configuration.\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\nSelect the appropriate number [1-2] then [enter] (press 'c' to cancel): 2\n```\nAfter this step, Certbot’s configuration is finished, and you will be presented with the final remarks about your new certificate, where to locate the generated files, and how to test your configuration using an external tool that analyzes your certificate’s authenticity:\n```\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\nCongratulations! You have successfully enabled https://your_domain and\nhttps://www.your_domain\n\nYou should test your configuration at:\nhttps://www.ssllabs.com/ssltest/analyze.html?d=your_domain\nhttps://www.ssllabs.com/ssltest/analyze.html?d=www.your_domain\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n\nIMPORTANT NOTES:\n - Congratulations! Your certificate and chain have been saved at:\n   /etc/letsencrypt/live/your_domain/fullchain.pem\n   Your key file has been saved at:\n   /etc/letsencrypt/live/your_domain/privkey.pem\n   Your cert will expire on 2020-07-27. To obtain a new or tweaked\n   version of this certificate in the future, simply run certbot again\n   with the \"certonly\" option. To non-interactively renew *all* of\n   your certificates, run \"certbot renew\"\n - Your account credentials have been saved in your Certbot\n   configuration directory at /etc/letsencrypt. You should make a\n   secure backup of this folder now. This configuration directory will\n   also contain certificates and private keys obtained by Certbot so\n   making regular backups of this folder is ideal.\n - If you like Certbot, please consider supporting our work by:\n\n   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate\n   Donating to EFF:                    https://eff.org/donate-le\n```\n\nYour certificate is now installed and loaded into Apache’s configuration. Try reloading your website using https:// and notice your browser’s security indicator. It should point out that your site is properly secured, typically by including a lock icon in the address bar.\n\nYou can use the SSL Labs Server Test to verify your certificate’s grade and obtain detailed information about it, from the perspective of an external service.\n\nIn the next and final step, we’ll test the auto-renewal feature of Certbot, which guarantees that your certificate will be renewed automatically before the expiration date.\n\n### Step 6 — Verifying Certbot Auto-Renewal\nTo check the status of this service and make sure it’s active and running, you can use:\n```\nsudo systemctl status certbot.timer\n```\nTo test the renewal process, you can do a dry run with certbot:\n\n```\nsudo certbot renew --dry-run\n```\n## Creator\n[Karthik Swarnkar](https://www.linkedin.com/in/codeincrypt/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeincrypt%2Fsite-setup-with-ssl-ubuntu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeincrypt%2Fsite-setup-with-ssl-ubuntu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeincrypt%2Fsite-setup-with-ssl-ubuntu/lists"}