Before going to set up and deploy a website on any hosting server, you need to register a domain for your website. There is various domain registrar available in the market to register a domain.
For more information, you can visit the below links:
NOTE: To set up and deploy a website on Linux Ubuntu Server, you need to install the following packages: Apache/Nginx
Note: In order to run below commands to set up and deploy a website, you need root access to the server.
Let’s Begin to set up a website “example.com”
Step 1:
First, create example.com.conf file on below location:
/etc/apache2/sites-available
Step 2:
To create/edit the above file, please execute below command:
$ sudo nano /etc/apache2/sites-available/example.com.conf
Paste below content in this file:
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerAdmin webmaster@localhost
DocumentRoot /var/www/example.com
ServerName example.com
ServerAlias www.example.com
Redirect permanent "/" "https://example.com/"
AllowOverride All
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
To active example.com site, please execute below command:
$ sudo a2ensite example.com.conf
$ sudo service apache2 restart
NOTE: Please follow the instrucions to generate SSL Certificates on above URL.
From the above URL, you will get following files:
example.com-csr.csr
example.com-crt.crt
example.com-key.key
Now, you need to put following files on below location:
example.com-crt.crt
example.com-key.key
Location:
/etc/ssl/example.com
Step 2:
First, create example.com-ssl.conf file on below location
/etc/apache2/sites-available
To create/edit above file, please execute below command:
$ sudo nano /etc/apache2/sites-available/example.com-ssl.con
Step 4:
Paste below content in this file:
ServerAdmin webmaster@example.com
ServerName example.com
ServerAlias www.example.com
#Redirect permanent "/" "https://example.com/"
DocumentRoot /var/www/example.com
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
# A self-signed (snakeoil) certificate can be created by installing
# the ssl-cert package. See
# /usr/share/doc/apache2/README.Debian.gz for more info.
# If both key and certificate are stored in the same file, only the
# SSLCertificateFile directive is needed.
SSLCertificateFile /etc/ssl/example.com/example.com-crt.crt
SSLCertificateKeyFile /etc/ssl/example.com/example.com-key.key
#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
SSLOptions +StdEnvVars
SSLOptions +StdEnvVars
To active example.com site, please execute below command:
$ sudo a2ensite example.com-ssl.conf
$ sudo service apache2 restart
Conclusion
This article will help people to set up and deploy a website on Linux machine especially Ubuntu 16.04/18.04 without spending too much time reading many blogs/articles.
If you have suggestions or any question please mention in comment. For more information reach out to EncoreSky.
How SEO & AI Are Changing The Future
After the Google Penguin algorithm came in 2012, the target changed to webspam & keyword st…
Flutter Advanced: Development for Custom UIs, Game Development and PWAs
Flutter, Google’s UI toolkit, has revolutionized the creation of natively compiled applications for mobile, web, and desktop from a single codebase. As Flutter evolves, it
The Ultimate UX Writing Guide to Improve User Experience.
Introduction User Experience (UX) is at the core of every successful product, website, or application. It encompasses not only the visual and functional aspects but
Integrating Apple Wallet in GoLang: A Step-by-Step Guide
Introduction Apple Wallet, formerly known as Passbook, is a versatile tool that empowers users to organize and manage an array of digital passes, including boarding
15 Best VS Code Extensions to Improve Your Productivity in 2023 (PART-1)
👋 Hey all, Boosting our productivity as a developer plays an important role in daily planning and work. Whenever you’re working on the complex structure
5 Core Scrum Values Can Improve Your Team Performance
If you are part of a team that is developing a new software product, you would want to deliver a product that is high quality,