Home / How To / How to install OSClass with Nginx on Ubuntu 20.04

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 create your own listing page without technical knowledge. It has a log of features including, Multilingual, Captcha, Dashboard, SEO Friendly, Integrated Search Engine, Free Website 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.

conditions

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

Install LEMP Stack

First you need to install the Nginx web server, MariaDB server, PHP and other necessary packages on your server. You can install all 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

Once you have installed all the packages, you can proceed to the next step.

Create a database for Osclass

Next, you need to create a database and users for Osclass. Log in to MariaDB with the following command:

mysql

After logging in, create a database and a 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';

Then flush the privileges and leave the MariaDB shell with the following command:

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

When you are done, you can move on to the next step.

Download Osclass

First you 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

When the download is complete, extract the downloaded file to the Nginx root directory using the following command:

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

Then change the ownership of the osclass directory to www-data and grant the correct permission with the following command:

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

When you are done, you can move on to the next step.

Configure Nginx for Osclass

Next, you must create a Nginx virtual host configuration file to operate 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 activate the Nginx virtual host with the following command:

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

Then check Nginx for any configuration errors 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

Then verify the status of the Nginx service with 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.

When you are done, you can move on 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 need to install the Certbot client on your server. 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 Let’s Encrypt SSL for your Web site.

certbot --nginx -d osclass.linuxbuz.com

You will be asked to enter your email address and accept the service 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

Then you also need to choose whether to redirect HTTP traffic to HTTPS as shown below:Advertisement

Advertisement

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 press 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.

Right now, your Osclass website is secured with Let’s Encrypt SSL.

Access to Osclass

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

Install OSClass

click INSTALL to start the installation. The following screen is displayed:

Requirements control

Make sure all requirements are met and then click RUN THE INSTALLATION button. The following screen is displayed:

Database information

Enter your database name, database name, password and click NEXT button. The following screen is displayed:

Admin user creation

Enter your admin username, password, email and click NEXT button. When the installation is complete, you will see the following screen:

Successful installation

click Finish and go to the administration panel button. You will be redirected to the Osclass login screen shown below:

Sign in

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

OSClass dashboard

Conclusion

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


Source link