How to Install Osclass on Ubuntu 18.04 LTS
Osclass is an open source project that allows you to easily create a classified site without any technical knowledge. Its source code is hosted on Github. In this tutorial, you will learn how to install Osclass on Ubuntu 18.04 server.
Requirements
- PHP version 5.6 or greater
- MySQLi and GD modules for PHP
- MySQL database
- Nginx
Before you begin
Check the Ubuntu version.
lsb_release -ds
# Ubuntu 18.04 LTS
Create a new non-root
user account with sudo
access and switch to it.
adduser johndoe --gecos "John Doe"
usermod -aG sudo johndoe
su - johndoe
NOTE: Replace johndoe
with your username.
Set up the timezone.
sudo dpkg-reconfigure tzdata
Ensure that your system is up to date.
sudo apt update && sudo apt upgrade -y
Install unzip
.
sudo apt install -y unzip
Install PHP
Install PHP and required PHP extensions.
sudo apt install -y php7.2 php7.2-cli php7.2-fpm php7.2-common php7.2-mysql php7.2-gd php7.2-xml
Check the version.
php --version
# PHP 7.2.7-0ubuntu0.18.04.2 (cli) (built: Jul 4 2018 16:55:24) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.2.7-0ubuntu0.18.04.2, Copyright (c) 1999-2018, by Zend Technologies
Install MySQL and create a database
Install MySQL.
sudo apt install -y mysql-server
Check the version.
mysql --version && sudo mysqld --version
# mysql Ver 14.14 Distrib 5.7.23, for Linux (x86_64) using EditLine wrapper
# mysqld Ver 5.7.23-0ubuntu0.18.04.1 for Linux on x86_64 ((Ubuntu))
Run mysql_secure installation
script to improve security and set the password for the root
user.
sudo mysql_secure_installation
Would you like to setup VALIDATE PASSWORD plugin? N
Please set the password for root here.
New password: **********************
Re-enter new password: **********************
Remove anonymous users? Y
Disallow root login remotely? Y
Remove test database and access to it? Y
Reload privilege tables now? Y
Success.
All done!
Connect to MySQL as the root user.
sudo mysql -u root -p
# Enter password
Create an empty MySQL database and user for Osclass, and remember the credentials.
CREATE DATABASE dbname;
GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT;
Install and configure Nginx
Install Nginx.
sudo apt install -y nginx
Check the version.
sudo nginx -v
# nginx version: nginx/1.14.0 (Ubuntu)
Run sudo vim /etc/nginx/sites-available/osclass.conf
and populate the file with the following configuration.
server {
listen 80;
listen [::]:80;
server_name example.com; # Check this
root /var/www/osclass; # Check this
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.2-fpm.sock; # Check this
}
}
Activate the new osclass.conf
configuration by linking the file to the sites-enabled
directory.
sudo ln -s /etc/nginx/sites-available/osclass.conf /etc/nginx/sites-enabled/
Test the configuration.
sudo nginx -t
Reload Nginx.
sudo systemctl reload nginx.service
Install Osclass
Create a document root directory.
sudo mkdir -p /var/www/osclass
Change ownership of the /var/www/osclass
directory to johndoe
.
sudo chown -R johndoe:johndoe /var/www/osclass
Download and unzip the Osclass package.
cd /var/www/osclass
wget https://static.osclass.org/download/osclass.3.8.0.zip
unzip osclass.3.8.0.zip
rm osclass.3.8.0.zip
Change ownership of the /var/www/osclass
directory to www-data
.
sudo chown -R www-data:www-data /var/www/osclass
Finally, open your favorite web browser and navigate to the URL http://your-server-ip/index.php
or http://yourdomain.com/index.php
. Complete the required steps to finish the installation. To access the Osclass admin site, append /oc-admin
to your URL.