Home Linux ServerWeb Server Adding the website to LOMP Stack on Ubuntu 20.04

Adding the website to LOMP Stack on Ubuntu 20.04

by Thạch Phạm
Published: Last Updated on
A+A-
Reset

Adding the website to LOMP Stack on Ubuntu 20.04 with 4 steps.

Có thể bạn sẽ thích

Introduction

Continuing with the series about LOMP Stack, AZDIGI will show you how to add a new website to the LOMP Stack on Ubuntu 20.04.

Conditions to be met:

  1. Ubuntu Server 20.04
  2. Use Root rights and install LOMP Stack
  3. The domain to be configured has been pointed to the server IP.

Implementation guide

Step 1: SSH into the server

To upgrade the ProFTPD version on DirectAdmin, we first need to SSH or access your VPS/server with root privileges. If you don’t know how to SSH into your VPS/Server, you can refer to the following tutorial:

Step 2: Create a folder to save the website

For example, in this article, I will do a demo with the website lomp.azdigi.space, the structure will be as follows:

Note: Remember to change lomp.azdigi.space to your website.

  • Create a folder to save website data
AZDIGI Tutorial
mkdir /usr/local/lsws/lomp.azdigi.space
sudo chmod -R 755 /usr/local/lsws/lomp.azdigi.space
    
  • Create content for the website

I will quickly create an index.html file for the website.

AZDIGI Tutorial
 sudo nano /usr/local/lsws/lomp.azdigi.space/index.html
    

Enter the content below and save.

<html>
  <head>
    <title>Welcome to LOMP Stack</title>
  </head>
  <body>
    <h1>Success! lomp.azdigi.space virtual host is working!</h1>
  </body>
</html>

Step 3: Create a Virtual Host for the new website

To create a Virtual Host for a new website, you need to log in to the Admin Panel with the link http://IP-Server:7080/.

  • Create Virtual Hosts

At the GUI interface, you access Virtual Hosts >> click the + button to add a new Virtual Host.

CleanShot 2022 06 01 at

In the next interface, you need to fill in the following details:

  • Virtual Host Name: Tên website của bạn.
  • Virtual Host Root: $SERVER_ROOT/websitecuaban
  • Config File: $SERVER_ROOT/conf/vhosts/websitecuaban/vhconf.conf
  • Enable Scripts/ExtApps: Yes
  • Restrained: Yes
CleanShot 2022 06 01 at

Next, you need to restart Openlitespeed to get the new configuration.

CleanShot 2022 06 01 at

If the addition is successful, you will see the new Virtual Host as follows:

CleanShot 2022 06 01 at 08.36.14@2x 1

  • Set the Document root path for the website
CleanShot 2022 06 01 at

Select the General tab => click the edit icon.

CleanShot 2022 06 01 at

In the General tab >> in the Document Root section, enter the path you created in Step 2: Create a folder to save the website.

CleanShot 2022 06 01 at

At the Index Files section, you also click the edit icon and change the information as follows:

CleanShot 2022 06 01 at

At the Rewrite tab, the Rewrite Control section you edit as below:

CleanShot 2022 06 01 at
CleanShot 2022 06 01 at

Next, scroll down to the Rewrite Rules section, select edit and add the content below:

rewriteFiler /usr/local/lsws/lomp.azdigi.space/.htaccess

Note: Remember to replace the bolded part with your website path.

CleanShot 2022 06 01 at
  • Connect new Vhost to port 80

You need to connect to the website with port 80 to be able to access it. To configure, you access Listeners >> press the + sign to add configuration.

CleanShot 2022 06 01 at 09.15.50@2x 1
CleanShot 2022 06 01 at

Next, you need to edit as follows:

CleanShot 2022 06 01 at
CleanShot 2022 06 01 at
CleanShot 2022 06 01 at

Step 4: Install SSL for the website

To make your website secure and look more professional, you should install SSL. And I will install SSL through the Cerbot automated tool with the following commands:

  • Install Cerbot
AZDIGI Tutorial
sudo apt-get install -y certbot
    
  • Create Let’s Encrypt certificate for website
AZDIGI Tutorial
certbot certonly --webroot -w /usr/local/lsws/lomp.azdigi.space/ -d lomp.azdigi.space
    
CleanShot 2022 06 01 at

After successful installation, you will receive 2 Certificates and Private key paths as above. You proceed to save these 2 paths to configure in the next part.

To use SSL, you need first to adjust the configuration to allow SSL use as follows:

  • Change the port to 443 and set the Secure status to Yes

You go to Listeners >> and choose to edit the Listener corresponding to your website.

CleanShot 2022 06 01 at 16.40.38@2x 1
CleanShot 2022 06 01 at

Next, edit the configuration as below:

CleanShot 2022 06 01 at

  • Set the path containing the SSL certificate

In this step, you need to set the path containing the SSL certificate you just installed above for your website by accessing the SSL tab >> SSL Private Key & Certificate.

CleanShot 2022 06 01 at
CleanShot 2022 06 01 at

Next, scroll down to the SSL Protocol section and click the edit icon.

CleanShot 2022 06 01 at
CleanShot 2022 06 01 at

After editing the configuration, you can restart Openlitespeed by clicking the Graceful Restart button.

CleanShot 2022 06 01 at

Now go to your website to check the results. And as a result, I have successfully accessed the website with SSL and previously created index.html content.

CleanShot 2022 06 01 at

Above are all the steps to add a website to the LOMP Stack on Ubuntu 20.04 server. Hopefully, this article is helpful to you and wish you success.

Đánh giá

Tham gia nhóm hỗ trợ Server - Hosting

Tham gia nhóm Hỗ trợ Server - Hosting & WordPress để cùng nhau hỏi đáp và hỗ trợ các vấn đề về WordPress, tối ưu máy chủ/server.

Tham gia ngay

Bài viết cùng chuyên mục

AZDIGI – Không chỉ là đơn vị hàng đầu trong lĩnh vực Web Hosting và Máy chủ, chúng tôi mong muốn mang lại những kiến thức bổ ích nhất và luôn cập nhật thường xuyên cho cộng đồng người đam mê thiết kế website, công nghệ,…

Vui lòng không sao chép nội dung nếu chưa xin phép. Designed and Developed by PenciDesign