<\/span><\/h2>\r\n\r\n\r\n\r\nInstall the Apache Web server with the following command:<\/p>\r\n\r\n\r\n\r\n
sudo apt install apache2<\/pre>\r\n\r\n\r\n\r\nOnce, installed start and enable the service.<\/p>\r\n\r\n\r\n\r\n
sudo systemctl enable apache2 && sudo systemctl start apache2<\/pre>\r\n\r\n\r\n\r\nCheck the status of the service:<\/p>\r\n\r\n\r\n\r\n
sudo systemctl status apache2<\/pre>\r\n\r\n\r\n\r\nYou should receive the following output:<\/p>\r\n\r\n\r\n\r\n
root@vps:~#sudo systemctl status apache2\r\n\u25cf apache2.service - The Apache HTTP Server\r\n Loaded: loaded (\/lib\/systemd\/system\/apache2.service; enabled; vendor preset: enabled)\r\n Active: active (running) since Wed 2022-02-09 19:36:35 UTC; 2 days ago\r\n Docs: https:\/\/httpd.apache.org\/docs\/2.4\/\r\n Process: 89546 ExecReload=\/usr\/sbin\/apachectl graceful (code=exited, status=0\/SUCCESS)\r\n Main PID: 672 (apache2)\r\n Tasks: 9 (limit: 4617)\r\n Memory: 29.5M\r\n CGroup: \/system.slice\/apache2.service\r\n<\/pre>\r\n\r\n\r\n\r\n<\/span>Step 3. Install MariaDB database server<\/span><\/h2>\r\n\r\n\r\n\r\nMariaDB database server is required for creating a database for our YOURLS URL Shortener.<\/p>\r\n\r\n\r\n\r\n
apt-get install mariadb-server<\/pre>\r\n\r\n\r\n\r\nEnable and start the mariadb service<\/p>\r\n\r\n\r\n\r\n
sudo systemctl enable mariadb\r\nsudo systemctl start mariadb<\/pre>\r\n\r\n\r\n\r\nCheck the status of the MariaDB service:<\/p>\r\n\r\n\r\n\r\n
sudo systemctl status mariadb<\/pre>\r\n\r\n\r\n\r\nYou should receive the following output:<\/p>\r\n\r\n\r\n\r\n
root@vps:~# sudo systemctl status mariadb\r\n\u25cf mariadb.service - MariaDB 10.3.32 database server\r\n Loaded: loaded (\/lib\/systemd\/system\/mariadb.service; enabled; vendor preset: enabled)\r\n Active: active (running) since Fri 2022-02-11 22:59:44 UTC; 1min 49s ago\r\n Docs: man:mysqld(8)\r\n https:\/\/mariadb.com\/kb\/en\/library\/systemd\/\r\n Main PID: 138979 (mysqld)\r\n Status: \"Taking your SQL requests now...\"\r\n Tasks: 31 (limit: 4617)\r\n Memory: 68.0M\r\n CGroup: \/system.slice\/mariadb.service\r\n \u2514\u2500138979 \/usr\/sbin\/mysqld\r\n\r\n<\/pre>\r\n\r\n\r\n\r\n<\/span>Step 4. Create a database and user for YOURLS<\/span><\/h2>\r\n\r\n\r\n\r\nCREATE DATABASE yourls;\r\nGRANT ALL PRIVILEGES ON yourls.* TO 'yourls'@'localhost' IDENTIFIED BY 'YourStrongPasswordHere';\r\nFLUSH PRIVILEGES;\r\nexit;<\/pre>\r\n\r\n\r\n\r\n<\/span>Step 5. Install PHP with extensions<\/span><\/h2>\r\n\r\n\r\n\r\nSince the YOURLS URL Shortener is a set of PHP scripts, you need to install the PHP along with the PHP extensions.<\/p>\r\n\r\n\r\n\r\n
sudo apt-get install php7.4 php7.4-mysql php7.4-curl php7.4-json php7.4-cgi php7.4-xsl php7.4-sqlite<\/pre>\r\n\r\n\r\n\r\n<\/span>Step 6. Install YOURLS URL Shortener<\/span><\/h2>\r\n\r\n\r\n\r\nFirst of all, we need to clone the YOURLS URL Shortener from Github. Go into the HTML directory on your server:<\/p>\r\n\r\n\r\n\r\n
cd \/var\/www\/html\r\n\r\ngit clone https:\/\/github.com\/YOURLS\/YOURLS.git .<\/pre>\r\n\r\n\r\n\r\nOnce, cloned go into the user<\/b> directory of the cloned repo and copy the config-sample.php<\/b> to config.php<\/b><\/p>\r\n\r\n\r\n\r\ncd \/var\/www\/html\/user\r\ncp config-sample.php config.php<\/pre>\r\n\r\n\r\n\r\nOnce, copied open the config.php<\/b> file with your favorite editor and modify the fields for database, database user, and password that you set in the previous steps.<\/p>\r\n\r\n\r\n\r\n\/** MySQL database username *\/\r\ndefine( 'YOURLS_DB_USER', 'yourls<\/b>' );\r\n\r\n\/** MySQL database password *\/\r\ndefine( 'YOURLS_DB_PASS', 'YourStrongPasswordHere<\/b>' );\r\n\r\n\/** The name of the database for YOURLS\r\n ** Use lower case letters [a-z], digits [0-9] and underscores [_] only *\/\r\ndefine( 'YOURLS_DB_NAME', 'yourls<\/b>' );<\/pre>\r\n\r\n\r\n\r\n\/** MySQL hostname.
** If using a non standard port, specify it like ‘hostname:port’, e.g. ‘localhost:9999’ or ‘127.0.0.1:666’ *\/
define( ‘YOURLS_DB_HOST’, ‘localhost<\/b>‘ );<\/p>\r\n\r\n\r\n\r\n
\/** MySQL tables prefix
** YOURLS will create tables using this prefix (eg `yourls_url`, `yourls_options`, …)
** Use lower case letters [a-z], digits [0-9] and underscores [_] only *\/
define( ‘YOURLS_DB_PREFIX’, ‘yourls_<\/b>‘ );<\/p>\r\n\r\n\r\n\r\n
\/*
** Site options
*\/<\/p>\r\n\r\n\r\n\r\n
\/** YOURLS installation URL
** All lowercase, no trailing slash at the end.
** If you define it to “http:\/\/sho.rt”, don’t use “http:\/\/www.sho.rt” in your browser (and vice-versa)
** To use an IDN domain (eg http:\/\/h\u00e9h\u00e9.com), write its ascii form here (eg http:\/\/xn--hh-bjab.com) *\/
define( ‘YOURLS_SITE’, ‘http:\/\/yourdomainhere<\/b>‘ );<\/p>\r\n\r\n\r\n\r\n
Once, these values are set you need to scroll down in this file and set the username and password that you will need for later access of YOURLS. Find and change these lines of code:<\/p>\r\n\r\n\r\n\r\n
$yourls_user_passwords = [\r\n 'administrator<\/b>' => 'YourStrongPasswordHere<\/b>',\r\n \/\/ 'username2' => 'password2',\r\n \/\/ You can have one or more 'login'=>'password' lines\r\n];\r\n<\/pre>\r\n\r\n\r\n\r\nSave the changes in the file and close it.<\/p>\r\n\r\n\r\n\r\n