How to Install Simple-URL-Shortener on macOS

Simple-URL-Shortener is an open-source URL shortener developed by azlux. This tutorial will guide you through the installation process on macOS.

Prerequisites

Step 1: Install Dependencies

Open the Terminal app and run the command below to install the required dependencies:

brew install nginx php@7.3 mariadb

This will install Nginx as the web server, PHP 7.3 as the scripting language, and MariaDB as the database.

Step 2: Clone the Simple-URL-Shortener Repository

Run the following command to clone the Simple-URL-Shortener repository to your computer:

git clone https://github.com/azlux/Simple-URL-Shortener.git

This will create a new directory called Simple-URL-Shortener in your current directory.

Step 3: Configure Nginx

Copy the Nginx configuration file from the repository to the Nginx configuration directory by running the command below:

sudo cp Simple-URL-Shortener/nginx.conf /usr/local/etc/nginx/

Next, open the Nginx configuration file in any text editor of your choice using the command:

sudo nano /usr/local/etc/nginx/nginx.conf

Find the line below:

root /usr/local/www/nginx;

Replace it with:

root /path/to/Simple-URL-Shortener/;

Remember to replace /path/to/Simple-URL-Shortener/ with the actual path to your Simple-URL-Shortener directory.

Save and close the file.

Test the Nginx configuration using the command:

sudo nginx -t

If there are no errors, restart Nginx using the command:

sudo brew services restart nginx

Step 4: Create the Database

Run the command below to log in to the MySQL server as the root user:

sudo mysql -u root

Create a new database named url_shortener and a new user with all privileges on the url_shortener database using the commands below:

CREATE DATABASE url_shortener;
CREATE USER 'urlshortener'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON url_shortener.* TO 'urlshortener'@'localhost';
FLUSH PRIVILEGES;

Remember to replace password in the command above with your own password.

Exit the MySQL server by running the command:

exit

Step 5: Configure Simple-URL-Shortener

Copy the config.php.example file to config.php by running the following command:

cp Simple-URL-Shortener/config.php.example Simple-URL-Shortener/config.php

Open the config.php file in any text editor of your choice using the command:

nano Simple-URL-Shortener/config.php

Make the following changes:

Save and close the file.

Step 6: Test Simple-URL-Shortener

Open your web browser and enter the URL http://localhost. If everything is working correctly, you should see the Simple-URL-Shortener homepage.

Conclusion

Congratulations! You have successfully installed Simple-URL-Shortener on your macOS system. You can now start using it to shorten URLs.

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!