How to set up multiple domain in one droplet or IP in Ubuntu server

Apache web server is one of the most powerful and flexible web servers and this the reason why it is highly popular. One of those features is to host multiple domains or sites on a single interface or IP by using matching mechanism. One cannot figure out that the same server is used for other domains also. Each configured domain then directs you to the specific directory which holds the site information.

Now, let’s go through the guide on how to set up multiple domains in one droplet or IP.

Process to set up multiple domains –

In your server, already there would a domain under /var/www/html directory. Now you want to add one more domain in that droplet. Let’s say the domain name is example.com

Now,

1. Make a directory for the new domain.

You have to make a directory in the server to hold the site data.

Open your Terminal and run the following code.

sudo mkdir -p /var/www/example.com/html

Go to /var/www  directory to check the newly created example.com folder.

2. Grant Permissions

sudo chown -R $USER:$USER /var/www/example.com/html

Also, modify the permission for the directory.

sudo chmod -R 755 /var/www/example.com

3. Create an index demo page

You can create a demo index.html page by using code or by directly uploading the index.html file in /var/www/example.com directory.

Now create a index.html file.

nano /var/www/example.com/html/index.html

In this file, create a simple code as mentioned below –

<html>
  <head>
    <title>Welcome to example.com!</title>
  </head>
  <body>
    <h1>Success!  The example.com virtual host is working!</h1>
  </body>
</html>

Then save and close the file.

4. Create New Virtual Host Config Files

Copy paste the following code and create a Virtual host file

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf

Now edit the file

sudo nano /etc/apache2/sites-available/example.com.conf

or directly go to /etc/apache2/sites-available to download and edit the file.

Paste the following code –

<VirtualHost *:80>
 ServerName example.com
 ServerAlias www.example.com
 #Redirect / http://www.example.com/
 ServerAdmin admin@example.com
 DocumentRoot /var/www/example.com/html

 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Save and close the file.

5. Enable the New Virtual Host Files

Now Enable the New Virtual Host Files.

sudo a2ensite example.com.conf

Check whether Apache is configured correctly or not by running the following code –

apachectl configtest

If Syntax OK restart the server by running the following code. If not then modify the error.

sudo service apache2 restart

Now your new domain is ready. Point your server IP to your new domain IP.  It takes some time to point the IP. Hit the URL after some time and find your new domain mapped under the same server.

Contact me if you have any queries or if you require any professional assistance related to your web world, I’d be happy to help.

How to install SSL Certificate

I remember, a few days back we were working on one e-commerce startup. While talking about the required features, when I counted SSL, he gave me such a look as if I committed some crime. Well, let me tell you he is not alone. Many website owners don’t find SSL worthy to be integrated. Before I proceed on how to configure, let me tell you Why.

SSL Certificate

Why is SSL Certificate important?

The primary and important reason is to keep the sensitive information encrypted across the Internet encrypted to ensure that only the dedicated recipient can recognize it. This becomes important because the data that we send over the Internet passes from computer to computer to reach to the target server. During this journey, any computer between you and the target server can see your sensitive information like username, passwords, credit card numbers, and much more,  if it is not encrypted with an SSL certificate. On the contrary, when an SSL certificate is used, the sent information becomes indecipherable to everyone other than the designated server. This protects from hackers & identity thieves. Now you see why SSL Certificate is important.

How to install SSL Certificate?

1. Generate a CSR and Private Key

First of all, you have to create CSR & KEY on your server. For this open your terminal and copy paste the following code.

openssl req -newkey rsa:2048 -nodes -keyout yourdomainname.com.key -out yourdomainname.com.csr

To generate a CSR (yourdomainname.com.csr), and a private key  (yourdomainname.com.key), run the command (replace the yourdomainname.com with the name of your domain)

Now, fill up the required fields. If you don’t know the answers of the field, then leave those fields empty. Just make sure that the name in “Common Name” field matches the name you want to use your certificate with–Like – yourdomainname.com.

Example:-

Country Name (2 letter code) [AU]:IN
State or Province Name (full name) [Some-State]:West Bengal
Locality Name (eg, city) []:Kolkata
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Your Company
Organizational Unit Name (eg, section) []:Web Security
Common Name (e.g. server FQDN or YOUR name) []:your_domain.com
Email Address []:your_email@domain.com

You can find the CSR and KEY in your server root directory.

2. Purchase Certificate and Upload CSR

Purchase a certificate from Namecheap or anywhere. Then open the Dashboard, upload the CSR file (which you created in the root directory) and activate the certificate.

3. Verify your domain

The certificate company provides you a txt file to verify your domain. Download the txt file and upload it to your /var/www/html directory.

4. Configure Apache to Use SSL

By this time, you would receive the certificate via email. Download the CRT and ca-bundle file and upload it to your server root directory, where you generated CSR and KEY.

Then proceed to /etc/apache2/sites-available and Download the 000-default.conf file.

Edit the following fields ONLY. Leave the remaining the way it is.

<VirtualHost *:80>
 ServerName www.your_domain.com
 Redirect / https://www.your_domain.com/
 
 DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost *:443>
 ServerName www.your_domain.com
 
 DocumentRoot /var/www/html
 SSLEngine on
 SSLCertificateFile /root/your_domain.crt
 SSLCertificateKeyFile /root/your_domain.com.key
 SSLCertificateChainFile /root/your_domain.ca-bundle
 
</VirtualHost>

Then upload the file in this directory and check the Apache validity of the config files in the server. Put the code in terminal apachectl configtest and check whether apache config is ok or not. Make sure to resolve the error first, if any.

Then, enable the Apache SSL module by running this command:  sudo a2enmod ssl

Now, restart your server by running this command: reboot

Done. SSL is installed in your domain. You can check by visiting –  https://www.your_domain.com

If you have any queries, then feel free to write in the comment section or for any personalized support you can ping me at info@tcatechnology.com.

How to integrate mailgun in any framework

Many at times  when you send email using server via SMTP,  emails does not get delivered. Really, I was facing this issue when emails were not delivered to Yahoo server.  This is a very common problem and to solve this problem, Mailgun is one of the best tools. If you using mailgun, then you can track every email from their dashboard. Believe me, it is very user-friendly and highly useful. I can’t explain my feeling when I was able to penetrate into Yahoo server. I am sure if you are facing this problem, then surely Mailgun would give you a sigh of relief.

How to integrate Mailgun?

  1. First of all, you will have to check whether SMTP is installed on your server or not. If not then install SMTP.
  2. Then,  verify your domain in Mailgun dashboard. Next,  add your domain. You can find SPF record and DKIM record in the dashboard itself. Add these two in your domain account as a DNS TXT record. Click here to know  how to verify your domain.
  3. Now, download Mailgun library from this link and upload to your root directory.
  4. Copy the following code and paste it to your page.
$to = "anupam@tcatechnology.com"; //Where you want to send
$subject = "Enter email subject here.";
$message = '<table><tr><td>Test body</td></tr></table>
require 'PHPMailer-master/PHPMailerAutoload.php';
 
 $mail = new PHPMailer;
 
 $mail->isSMTP(); // Set mailer to use SMTP
 $mail->Host = 'smtp.mailgun.org'; // Specify main and backup SMTP servers
 $mail->SMTPAuth = true; // Enable SMTP authentication
 $mail->Username = 'ENTER YOUR MAILGUN SMTP USER NAME'; // SMTP username
 $mail->Password = 'ENTER YOUR MAILGUN SMTP PASSWORD'; // SMTP password
 $mail->SMTPSecure = 'tls'; // Enable encryption, only 'tls' is accepted
 
 $mail->From = 'info@yourdomainname.com';
 $mail->FromName = 'Your company name';
 $mail->addAddress($to); // Add a recipient
 $mail->isHTML(true); // For HTML mail format
 
 
 $mail->Subject = $subject;
 $mail->Body = $message;
 
 if(!$mail->send()) {
 
 echo 'Mailer Error: ' . $mail->ErrorInfo;
 } else {
 echo "Success";
 }

You are done. You can now check email log and complete details from this link.  Screenshot of one such data is presented below.

mail gun

 

That’s all for now. In the last few days, received many emails regarding configuring SSL Certificate. So, my next topic would be how to move your website to https. Subscribe to our mailing list to remain tuned and receive our update directly in your mailbox.

Bye and happy developing folks.

 

Some important plugins for wordpress

You might be aware of the WordPress plugins. Yet, I’ll paste it for our convenience.

WordPress plugins are bits of software that can be uploaded to to extend and expand the functionality of your 
WordPress site.

We will have to admit, plugins are really useful and come to our rescue most of the times. Loaded with great features, it makes our life easy; else it would be hard to code for the each dedicated feature. Now, there are many plugins which you can use. Here, I am listing very few names which one can install while configuring a new WordPress website. Gradually, I’ll try to list few more names for the dedicated feature in next posts. Let me know in the comment section, if you have any suggestion. So, here we go.

1. Yoast SEO

It is one of the best and most complete plugin for SEO in WordPress. Packed with great features, it allows you to insert meta description, choose a keyword and put an SEO description. Download this plugin from here.

yoast seo

2. W3 Total Cache 

A powerful plugin for to increase the website speed. Click on the link to get complete details on how to configure W3 Total Cache for optimum use. Link to download the plugin.

3. Jetpack by WordPress.com

One of the most powerful plugin in WordPress – Jetpack. User interface is very friendly, and it allows you to do almost everything ranging from managing social media, blog posts, comments and much more. At the top of it, it makes your website fast.  Download the plugin here.

sharing settings

 

4. TinyMCE Advanced

Helps you arrange, add, remove the buttons shown in the Visual Editor toolbar in your WordPress Editor. Download the plugin from here. 

editor setting

That’s all for now. In the future, we are coming up with many more articles. Sign up for your newsletter to remain updated.

Why use W3 Total Cache Plugin – It’s importance and ways to configure it

W3 Total Cache

I was just browsing the internet when the title of one article caught my fancy.  I clicked on the link but to my disappointment, I failed in reading that article even after refreshing the page some 15-20 times. It wasn’t that my internet speed was low. I am sure, you all might have experienced it sometime. There are some websites which open at the click of the mouse while some make us wait till eternity.

 

Everyone wants a fast loading website. Don’t you? Apart from decent web hosting, beautifully coded plugins, you need to ensure that you have a content delivery network (CDN) and you are using a proper caching. We are lucky we W3 Total Cache to serve this purpose for WordPress website. In this article, we are going to show you the step by step guidance on how to install W3 Total Cache and configure it properly to get the maximum benefit.

So here we go…

 

How to install and configure W3 Total Cache

 

1. First thing first-  Download the W3 Total Cache plugin

2. Now time to configure it. Click on “Performance” in your WordPress admin.

3. Then, in “Page Cache” section, Enable the Page Cache and select Page Cache Mode Disk: Enhanced.

page cache

4.  In “Minify section” Enable the Minify section, chose Minify mode auto, Select Minify cache method Disk, Select  Js minifier JSMin (default) and select CSS minifier Default.

minify

5. Now come to “Database Cache” section. Enable the Database Cache option and select Database Cache Method Disk.

database cache

6.  In “Object Cache” option enable the option of Object Cache and Select the Object Cache Method Disk.

object cache

7. In “Browser cache” section, enable the Browser cache option.

browser cache

8.  In CDN section, don’t enable the CDN option. –

cdn

9. Then, leave the Reverse Proxy section.

peverse proxy

10. Again, leave the Monitoring section

Monitoring

11.  Leave the Licensing section also.

Licensing

12. Now come to Miscellaneous section. Enable the  Enable Google Page Speed dashboard widget and  Verify rewrite rules and leave the left option.

Miscellaneous

13. Leave the Debug section

debug

Save all settings and you are done. Feel free to comment if you have any questions/suggestions.

Click here to signup to our newsletter to remain connected and receive all our posts directly in your inbox.

 

Step by step guidance to make a wordpress website

Many years back, when I got fascinated with the web development world, I decided to create my own website but then I noticed most websites were developed using HTML, CSS and what not. Learning those seemed wayward that time and it took high effort and huge time to master.

One of the reasons why still most people consider developing a website as an  impossible task and think that it requires a knack of coding and designing. But this is no truer !!

Today, CMS (content management systems) like WordPress have made developing a website open to all. Simply putting, CMS is a user-friendly platform for developing your own website and handling your content on your own, rather than using lengthy codes.

Enough of description, let’s proceed to the main segment – Steps to make a WordPress website.

STEPS TO MAKE WORDPRESS WEBSITE

  • 1. Log in to your hosting account. Click here to know how to create your hosting account.
  • 2. Go to your control panel.
  • 3. Create a database.
  • 4. Go to your file manager “public_html” Folder and upload the WordPress file (You will have to download WordPress file from https://wordpress.org/download/ ).
  • 5. Now go to your domain and select a language, click on “Continue” button. After that, click on “Let’s go!” button.
  • 6. Then enter your —

i. Database name ii. Database user name iii. Your database Password .

Don’t make any changes in the  database host and  table prefix, leave it as it is and click on “Submit” button. On the next page click on “Run the install” button.
Database Config

  • 7. On the next page enter —

i .”Site Title” as per your choice. Enter Admin Username and Password (If your password is

Then, enter Admin Username and Password (If your password is weak then click on “confirm use of weak password”. Lastly, enter your email id and click on “Install WordPress” button. After Installation,  click on “Log In” button and enter your admin username and password (By default you can log in your admin panel www.yourdomainname.com/wp-admin ). admin config

  • 8. After login, you will be directed to the dashboard section where will find all the settings. Go to the “Themes” section where you can choose a theme and activate it.
  • choose theme
  • 9. Then go to “Pages”  -> Add New Page. You can create pages of your choice like Home, Services, Contact etc.new page
  • 10 . After creating pages go to “Appearance” to edit frontend visual-> Go to “Menus” and create a menu, put a menu name like “main menu” and click on create button. on the left-hand side, you can select menu options like which page to insert, tick that box and click on add menu – then swap it up or down as per your requirement. Click on “save menu” to save the settings.  “Primary menu” or main menu means header while the footer will result in footer menu .menu
  • 11. Go to Setting->Reading. For “Front page displays” select “A static page (select below) ” this option. For “Front page” select the Home page and for “Posts page” select Blog page. Then click on “Save Changes” button.readding settings
  • 12. You can change the  URL as per your requirement – like post name, post date, –in permalinks. Go to Settings – > Permalinks select “Post name” option and click on “Save Changes” button.permalink settings
  • 13. For a blog post,  Go to Post -> Categories and create your Categories. Then go to Post -> Add New Post. Enter a post title, Post content, select a “categories” and select a “Featured Image” then click on Publish button to make it live.

There are much more things to explore in WordPress. Signup to our newsletter to remain connected and receive all our posts directly in your inbox.

Feel free to comment if you have any questions/suggestions or if you simply want to say Hi !