In this tutorial, we will be going through the steps to install Gallery CSS on Ubuntu Server Latest. Gallery CSS is a lightweight and easy-to-use CSS image gallery that can be used to display images on websites. By the end of this tutorial, you'll be able to set up Gallery CSS on your Ubuntu Server in no time.
Before you begin, ensure that you have the following installed on your Ubuntu Server:
If you have not installed these yet, you can follow our tutorials on how to install Nginx on Ubuntu Server, install PHP on Ubuntu Server, and install MySQL on Ubuntu Server before you proceed.
To begin, navigate to the Gallery CSS GitHub page by going to the following link:
https://github.com/benschwarz/gallery-css
On the page, locate the green "Code" button and click on it. From the dropdown, select "Download ZIP" to download the Gallery CSS package.
Once the download is complete, navigate to the directory where the file was downloaded, and extract the package using the following command:
$ unzip gallery-css-master.zip
This command will create a new directory called gallery-css-master
in the same directory where the file was downloaded.
Next, we will move the Gallery CSS files to the web directory where they can be accessed by the server. In our case, we will move the files to the default Nginx web directory, which is /var/www/html/
.
To do this, use the following command to move the contents of the gallery-css-master
directory to the Nginx web directory:
$ sudo mv gallery-css-master/* /var/www/html/
This command will move all the files and folders inside the gallery-css-master
directory to the Nginx web directory.
We will be using MySQL to store the data for Gallery CSS. We will need to create a database and a user with appropriate permissions to access the database.
To do this, log in to the MySQL shell by running the following command:
$ sudo mysql
Once you're in the MySQL shell, create a new database for Gallery CSS by running the following command:
mysql> CREATE DATABASE gallerycss;
Next, create a new user and grant it access to the database by running the following command:
mysql> GRANT ALL PRIVILEGES ON gallerycss.* TO 'gallerycssuser'@'localhost' IDENTIFIED BY 'password';
Replace password
with a strong password of your choosing. This command creates a user called gallerycssuser
with full privileges on the gallerycss
database.
Exit the MySQL shell by running the following command:
mysql> exit
Now that we have created the necessary database and user, we need to modify the Gallery CSS configuration file to use them.
Navigate to the config
directory inside the Nginx web directory using the following command:
$ cd /var/www/html/config/
Inside this directory, you will find a file called config.php
. Open this file using a text editor:
$ sudo nano config.php
Inside the file, locate the following lines:
$config['db_host'] = 'localhost';
$config['db_name'] = '';
$config['db_user'] = '';
$config['db_pass'] = '';
Replace the values inside the quotes with the following:
$config['db_host'] = 'localhost';
$config['db_name'] = 'gallerycss';
$config['db_user'] = 'gallerycssuser';
$config['db_pass'] = 'password';
Make sure to replace password
with the password you set for the MySQL user in Step 3.
Save and exit the file by pressing Ctrl+X
, then Y
, and then Enter
.
Now that everything is set up, you can visit the Gallery CSS gallery page by navigating to the following URL in your web browser:
http://your_server_ip/
You should see a fully functional Gallery CSS gallery page with sample images.
In this tutorial, we went through the process of installing Gallery CSS on Ubuntu Server Latest. We covered the steps needed to download and extract the package, move the files to the Nginx web directory, set up a MySQL database and user, and modify the configuration file to use them. Now that you have Gallery CSS installed, you can customize it and use it to display images on your website.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!