How VPS - How to use/setup VPS
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System CentOS

How to Install YOURLS on CentOS 7

How VPS by How VPS
October 1, 2019
in CentOS
0
0
SHARES
35
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Prerequisites
  2. Step 1: Update the system
  3. Step 2: Install a web server—Apache
  4. Step 3: Install MariaDB 10.x
    1. 3.1 Create the MariaDB 10.1 YUM repo file
    2. 3.2 Install MariaDB 10.1 using YUM
    3. 3.3 Start the MariaDB service and set it as running at system startup
    4. 3.4 Secure the installation of MariaDB
    5. 3.5 Create a MariaDB database for YOURLS
  5. Step 4: Install PHP 7.1 and necessary PHP 7.1 extensions
  6. Step 5: Install YOURLS
    1. 5.1 Get the latest YOURLS code from YOURLS GitHub repo:
    2. 5.2 Configure YOURLS:
    3. 5.3 Create a virtual host for YOURLS:
    4. 5.4 Apply your settings:
    5. 5.5 Modify firewall rules:
    6. 5.6 Web access:
    7. 5.7 Post-installation security measures
  7. Want to contribute?


YOURLS (Your Own URL Shortener) is an open source URL shortening and data analytics application.

In this article, we will cover the process of installing YOURLS on a CentOS 7 server.

Prerequisites

  • A CentOS 7 x64 server instance.
  • A sudo user.
  • A domain example.com that points to your server’s IP address.

Step 1: Update the system

Log in as a sudo user, and then use the below commands to update the system:

sudo yum install epel-release -y
sudo yum clean all && sudo yum update -y && sudo shutdown -r now

After the reboot, log back into the server using the same sudo user.

Step 2: Install a web server—Apache

Install the Apache web server using YUM:

sudo yum install httpd -y

Remove the Apache welcome page:

sudo sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.conf

Prevent Apache from exposing files in visitors’ web browser:

sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.conf

Start the Apache service and set it to auto-start on system boot:

sudo systemctl start httpd.service
sudo systemctl enable httpd.service

Step 3: Install MariaDB 10.x

Install the latest stable release of MariaDB, MariaDB 10.1 as below:

3.1 Create the MariaDB 10.1 YUM repo file

cat <<EOF | sudo tee -a /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.1 CentOS repository list - created 2017-01-14 03:11 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF

3.2 Install MariaDB 10.1 using YUM

sudo yum install MariaDB-server MariaDB-client -y

3.3 Start the MariaDB service and set it as running at system startup

sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

3.4 Secure the installation of MariaDB

sudo /usr/bin/mysql_secure_installation

Answer questions as below, and ensure that you will use your own MariaDB root password:

  • Enter current password for root (enter for none): Just press the Enter button
  • Set root password? [Y/n]: Y
  • New password: your-root-password
  • Re-enter new password: your-root-password
  • Remove anonymous users? [Y/n]: Y
  • Disallow root login remotely? [Y/n]: Y
  • Remove test database and access to it? [Y/n]: Y
  • Reload privilege tables now? [Y/n]: Y

3.5 Create a MariaDB database for YOURLS

Log into the MySQL shell as root:

mysql -u root -p

Type your own MariaDB root password and then press Enter.

In the MySQL shell, create a database yourls, a database user yourlsuser, and the database user’s password yourpassword as follows.

Note: For security purposes, you should use your own user password instead of the sample password yourpassword.

CREATE DATABASE yourls DEFAULT CHARACTER SET UTF8 COLLATE utf8_unicode_ci;
CREATE USER 'yourlsuser'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON yourls.* TO 'yourlsuser'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

Step 4: Install PHP 7.1 and necessary PHP 7.1 extensions

Install PHP 7.1 and several PHP 7.1 extensions as follows:

sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
sudo yum install -y mod_php71w  php71w-mysqlnd php71w-common

Step 5: Install YOURLS

5.1 Get the latest YOURLS code from YOURLS GitHub repo:

sudo yum install git -y
cd /var/www/html/
sudo git clone https://github.com/YOURLS/YOURLS.git
sudo chown -R apache:apache /var/www/html/YOURLS
cd YOURLS

5.2 Configure YOURLS:

sudo cp user/config-sample.php user/config.php
sudo chown apache:apache user/config.php

Use the vi text editor to open the /var/www/html/YOURLS/user/config.php file:

sudo vi user/config.php

Find the below lines:

define( 'YOURLS_DB_USER', 'your db user name' );
define( 'YOURLS_DB_PASS', 'your db password' );
define( 'YOURLS_DB_NAME', 'yourls' );
define( 'YOURLS_SITE', 'http://your-own-domain-here.com' );
define( 'YOURLS_COOKIEKEY', 'modify this text with something random' );
$yourls_user_passwords = array(
        'username' => 'password',

Replace them one by one as follows:

define( 'YOURLS_DB_USER', 'yourlsuser' );
define( 'YOURLS_DB_PASS', 'yourpassword' );
define( 'YOURLS_DB_NAME', 'yourls' );
define( 'YOURLS_SITE', 'http://example.com' );
define( 'YOURLS_COOKIEKEY', 'fmoi4jfsjfasfjlkfjalfgcggjkihdgfjjgdfolsfmwemlgjhgigjgitjaaewesfsdfsdogmbnsin' ); // Use a long string consists of random characters.
$yourls_user_passwords = array(
        'username1' => 'password1', // Use your own username and password.

Save and quit:

:wq!

5.3 Create a virtual host for YOURLS:

cat <<EOF | sudo tee -a /etc/httpd/conf.d/yourls.conf
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/YOURLS/
ServerName yourls.example.com
ServerAlias www.yourls.example.com
<Directory /var/www/html/YOURLS/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/yourls.example.com-error_log
CustomLog /var/log/httpd/yourls.example.com-access_log common
</VirtualHost>
EOF

5.4 Apply your settings:

sudo systemctl restart httpd.service

5.5 Modify firewall rules:

sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --reload

5.6 Web access:

Point your web browser to http://example.com/admin, and then click the Install YOURLS link to finish the installation.

Having YOURLS successfully installed, click the YOURLS Administration Page link to visit the YOURLS Admin interface, and then use the username username1 and password password1 to log in.

5.7 Post-installation security measures

For security purposes, you should restrict permissions to YOURLS after the installation:

sudo chown -R root:root /var/www/html/YOURLS

When you need to upgrade the program or install a plug-in, you can revert the strict permissions for that purpose as follows:

sudo chown -R apache:apache /var/www/html/YOURLS

That concludes our tutorial. Thanks for reading.

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
How VPS

How VPS

Related Posts

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Install BoltWire CMS on CentOS 7
CentOS

How to Install BoltWire CMS on CentOS 7

February 14, 2020
Showterm.io – A Terminal/Shell Recording, Upload and Share Tool for Linux
CentOS

Setup HTTP Authentication With Nginx on CentOS 7

February 14, 2020
Next Post

How to Install Concrete5 on CentOS 7

How to Install Couch CMS 2.0 on a CentOS 7 LAMP VPS

Setup ConfigServer Security and Firewall (CSF) on CentOS 7

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Follow Us

  • 121 Followers
  • 87.2k Followers

Recommended

Install Drupal 7 on the One-Click LEMP Application

3 years ago

Redirect HTTP Requests To HTTPS On Apache 2

3 years ago

How to Install Craft CMS on FreeBSD 12

3 years ago
How To Configure Authentication and IIS 7.0 URL Authorization

How To Configure Authentication and IIS 7.0 URL Authorization

4 years ago

Instagram

    Please install/update and activate JNews Instagram plugin.

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

Topics

Apache Web Server Bluehost Review 2019 Bluehost Review 2020 Bluehost Review 2021 Centmin Mod CentminMod centos install htop fsck htop install HTTP DoS attack Install Snort on an Ubuntu install Zabbix on CentOS install Zabbix on CentOS 7 Linux Commands linux guide linux install htop linux vps setup guide MariaDB MariaDB Error Mysql mysqld error optimize MariaDB optimize Mysql snort Ubuntu
No Result
View All Result

Highlights

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Webmin Reviews

Virtualmin Reviews

CentOS Web Panel Reviews

Ajenti Reviews

ISPConfig Reviews

Trending

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

by How VPS
February 25, 2022
0

I tried to update some extensions by use yum on centOs which I specified in Dockerfile. After...

How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020
Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

February 17, 2020
Webmin Reviews

Webmin Reviews

February 17, 2020
How VPS – How to use/setup VPS

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Visit our landing page to see all features & demos.
LEARN MORE »

Recent News

  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8 February 25, 2022
  • How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”? November 17, 2020
  • How to optimize Mysql or MariaDB November 3, 2020

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

[mc4wp_form]

© 2018 JNews - City News Magazine WordPress theme. All rights belong to their respective owners.
JNews is a top selling 2018 WordPress News, Blog, Newspaper & Magazine Theme.

No Result
View All Result
  • Home

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.