How to Install OSClass with Nginx on Ubuntu 20.04

Osclass is a free, open-source and user-friendly application that can be used to create your own classified websites on your own server. It comes with a feature-rich editor, user-friendly admin portal, flexible and template system that helps you to create your own listing site without any technical knowledge. It has a log of features including, Multi-language, Captcha, Dashboard, SEO Friendly, Integrated search engine, Free site creator and many more.

In this tutorial, we will explain how to install Osclass classified website cms with Nginx and Let's Encrypt SSL on Ubuntu 20.04 server.

Prerequisites

  • A server running Ubuntu 20.04.
  • A valid domain name pointed with your server IP.
  • A root password is configured the server.

Install LEMP Stack

First, you will need to install the Nginx web server, MariaDB server, PHP and other required packages in your server. You can install all of them with the following command:

apt-get install nginx mariadb-server php7.4 php7.4-cli php7.4-fpm php7.4-common php7.4-mysql php7.4-gd php7.4-xml curl gnupg2 unzip -y

After installing all the packages, you can proceed to the next step.

Create a Database for Osclass

Next, you will need to create a database and user for Osclass. First, login to MariaDB with the following command:

mysql

Once login, create a database and user for Osclass with the following command:

MariaDB [(none)]> CREATE DATABASE osclass;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON osclass.* TO 'osclass'@'localhost' IDENTIFIED BY 'password';

Next, flush the privileges and exit from the MariaDB shell with the following command:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Once you are finished, you can proceed to the next step.

Download Osclass

First, you will need to download the latest version of Osclass from the Git repository. You can download it with the following command:

wget https://github.com/Dis555/Osclass/releases/download/4.2.0/Osclass-Evolution4.2.0.zip

Once the download is completed, unzip the downloaded file to the Nginx root directory with the following command:

unzip Osclass-Evolution4.2.0.zip -d /var/www/html/osclass

Next, change the ownership of the osclass directory to www-data and give proper permission with the following command:

chown -R www-data:www-data /var/www/html/osclass
chmod -R 755 /var/www/html/osclass

Once you are finished, you can proceed to the next step.

Configure Nginx for Osclass

Next, you will need to create an Nginx virtual host configuration file to serve Osclass. You can create it with the following command:

nano /etc/nginx/sites-available/osclass.conf

Add the following lines:

server {
    listen 80;
    listen [::]:80;

    server_name osclass.linuxbuz.com;
    root /var/www/html/osclass;

    index index.php index.html;

    location / {
      try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # Check this
    }
}

Save and close the file then enable the Nginx virtual host with the following command:

ln -s /etc/nginx/sites-available/osclass.conf /etc/nginx/sites-enabled/

Next, check the Nginx for any configuration error with the following command:

nginx -t

You should get the following output:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Finally, restart the Nginx service to apply the changes:

systemctl restart nginx

Next, verify the status of the Nginx service using the following command:

systemctl status nginx

You should see the following output:

? nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2020-08-13 06:21:23 UTC; 4s ago
       Docs: man:nginx(8)
    Process: 13399 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 13412 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 13415 (nginx)
      Tasks: 3 (limit: 2353)
     Memory: 3.5M
     CGroup: /system.slice/nginx.service
             ??13415 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             ??13416 nginx: worker process
             ??13417 nginx: worker process

Aug 13 06:21:23 ubuntu2004 systemd[1]: Starting A high performance web server and a reverse proxy server...
Aug 13 06:21:23 ubuntu2004 systemd[1]: Started A high performance web server and a reverse proxy server.

Once you are finished, you can proceed to the next step.

Secure Osclass with Let's Encrypt

It is always a good idea to secure your Osclass website with Let's Encrypt SSL. First, you will need to install the Certbot client in your server. The Certbot is a Let's Encrypt client used to manage the SSL certificate for your domain. You can install the Certbot client with the following command:

apt-get install python3-certbot-nginx -y

After installing the Certbot client, run the following command to install the Let's Encrypt SSL for your website.

certbot --nginx -d osclass.linuxbuz.com

You will be asked to provide your email address and accept the term of service as shown below:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for osclass.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/osclass.conf

Next, you will also need to select whether or not to redirect HTTP traffic to HTTPS as shown below:

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Type 2 and hit Enter to continue. Once the certificate has been installed, you should see the following output:

Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/osclass.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://osclass.linuxbuz.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=osclass.linuxbuz.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/osclass.linuxbuz.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/osclass.linuxbuz.com/privkey.pem
   Your cert will expire on 2020-11-11. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

 - We were unable to subscribe you the EFF mailing list because your
   e-mail address appears to be invalid. You can try again later by
   visiting https://act.eff.org.

At this point, your Osclass website is secured with Let's Encrypt SSL.

Access Osclass

Now, open your web browser and type the URL https://osclass.linuxbuz.com. You will be redirected to the following screen:

Install OSClass

Click on the INSTALL button to start the installation. You should see the following screen:

Requirements check

Make sure all the requirements have met then click on the RUN THE INSTALL button. You should see the following screen:

Database details

Provide your database name, database username, password and click on the NEXT button. You should see the following screen:

Admin user creation

Provide your admin username, password, email and click on the NEXT button. Once the installation has been finished, you should see the following screen:

Installation successful

Click on the FINISH AND GO TO THE ADMINISTRATION PANEL button. You will be redirected to the Osclass login screen as shown below:

Login

Provide your admin username, password and click on the LOG IN button. You should see the Osclass dashboard in the following screen:

OSClass dashboard

Conclusion

In this guide, you learned how to install Osclass cms with Nginx on Ubuntu 20.04 server. You also learned how to secure Osclass with Let's Encrypt SSL. I hope you can now easily create your own classified website with Osclass.

Share this page:

0 Comment(s)