Installing YOURLS on Ubuntu Server Latest
YOURLS (Your Own URL Shortener) is a free and open-source software that allows you to create and manage your own URL shortener. In this tutorial, we will guide you through the steps of installing YOURLS on Ubuntu Server Latest.
Prerequisites
Before proceeding with the installation, make sure that you have the following requirements:
- Ubuntu Server Latest installed.
- Access to the terminal with sudo privileges.
- Apache Web Server installed and configured.
Step 1: Install PHP and Required Extensions
First, update the package repository cache of your system.
sudo apt update
Install PHP and required extensions using the following command.
sudo apt install php php-mysql php-curl php-gd php-mbstring php-xml
Step 2: Install YOURLS
Download the latest stable version of YOURLS from the official website.
cd /var/www/html
sudo wget https://github.com/YOURLS/YOURLS/releases/latest/download/yourls-latest.zip
Unzip the downloaded file using the following command.
sudo unzip yourls-latest.zip
Rename the extracted directory to something more meaningful.
sudo mv YOURLS-*/ yourls
Set the correct ownership and permissions to the YOURLS directory.
sudo chown -R www-data:www-data /var/www/html/yourls/
sudo chmod -R 755 /var/www/html/yourls/
Step 3: Configure the Database
Create a new database and user for YOURLS to use. This can be done using PHPMyAdmin or the MySQL command-line interface.
mysql -u root -p
mysql> CREATE USER 'yourlsuser'@'localhost' IDENTIFIED BY 'yourlspassword';
mysql> CREATE DATABASE yourls_db;
mysql> GRANT ALL PRIVILEGES ON yourls_db.* TO 'yourlsuser'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
Step 4: Configure YOURLS
Copy the configuration file user/config-sample.php to user/config.php.
cd /var/www/html/yourls/user
sudo cp config-sample.php config.php
Open the config.php file using a text editor and update the following lines.
define( 'YOURLS_DB_USER', 'yourlsuser' );
define( 'YOURLS_DB_PASS', 'yourlspassword' );
define( 'YOURLS_DB_NAME', 'yourls_db' );
define( 'YOURLS_SITE', 'http://yourdomain.com' );
Save and close the file.
Step 5: Configure Apache Web Server
Create a new virtual host for YOURLS.
sudo nano /etc/apache2/sites-available/yourls.conf
Add the following configuration to the file and save it.
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/yourls
ServerName yourdomain.com
ServerAlias www.yourdomain.com
<Directory "/var/www/html/yourls">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/yourls_error.log
CustomLog ${APACHE_LOG_DIR}/yourls_access.log combined
</VirtualHost>
Enable the virtual host and restart the Apache service.
sudo a2ensite yourls.conf
sudo systemctl restart apache2
Step 6: Access YOURLS
Open your web browser and type the URL http://yourdomain.com in the address bar. You should see the YOURLS installation page.
Follow the on-screen instructions to complete the installation process.
Conclusion
Congratulations! You have successfully installed YOURLS on Ubuntu Server Latest. You can now create and manage your own URL shortener.