YOURLS
Overview
YOURLS (Your Own URL Shortener) is an established open source link shortener that you run yourself. It turns long URLs into short ones under your own domain. You can auto-generate a keyword or choose your own, and YOURLS tracks every click: hits over time, the referrer sources sending traffic, and a country breakdown. Beyond the admin interface, it offers a bookmarklet, a full REST API for creating and querying links from your own code, and a plugin system.
This SecureAnyCloud image ships YOURLS 1.10.4 served by Apache and PHP 8.3 on a hardened Ubuntu 24.04 LTS base, patched at build time. It includes a bundled local MariaDB server, so the appliance is complete on its own. The installer is already completed and short link routing is configured in the web server itself, so links resolve the moment the instance boots.
What you get:
- YOURLS 1.10.4 served by Apache with PHP 8.3, managed by systemd
- A bundled MariaDB server holding the YOURLS database, already installed and ready
- The installer pre-completed, so no setup wizard is ever exposed
- Short link routing configured in the Apache virtual host, so links resolve correctly from the first boot
- A unique administrator password generated on the first boot of every VM and recorded in a root-only file
- No shipped default login: the administrator password ships rotated to a discarded random value, and the real per-VM password is set on first boot
- The administrator password stored only as a bcrypt hash, never in clear text
- MariaDB bound to
127.0.0.1only (the loopback interface, port 3306), never exposed to the network - A dedicated Azure data disk carrying both the MariaDB database and the YOURLS user tree
- An instance that follows whatever address you browse it on, so it works on the instance address and keeps working after you attach your own domain
- Host-only session cookies, so sign-in works whether you browse by IP or by a DNS name
- An empty shortener: the upstream sample links are removed, so your first link is your own
apache2.serviceandmariadb.serviceas enabled systemd units- An unauthenticated
/healthzendpoint for Azure Load Balancer health probes - 24/7 SecureAnyCloud support
Prerequisites
You need an active Azure subscription, an SSH key pair, and a VNet with a subnet in the target region.
Standard_B2s (2 vCPU / 4 GiB RAM) is a sensible starting size for a shortener serving a team or a modest public audience. Move up to Standard_D2s_v3 for high redirect volumes or large click histories.
Configure the network security group (NSG) to allow inbound 22/tcp from your management network, 80/tcp for the application, and 443/tcp if you terminate TLS on the VM. The bundled MariaDB listens on 127.0.0.1 only, so port 3306 stays off the network.
Step 1 - Deploy from the Azure Marketplace
In the Azure portal, choose Create a resource. Search for YOURLS URL Shortener on Ubuntu 24.04 LTS by SecureAnyCloud, and select Create.
Pick your subscription, resource group and region, and choose the Standard_B2s size. Select SSH public key authentication with the username azureuser, and allow inbound 22, 80 and 443.
The image attaches its own 20 GiB data disk for your links and click analytics, so you do not need to add one.
Step 2 - Deploy from the Azure CLI
# Accept the Marketplace terms once per subscription (required before the first CLI deploy)
az vm image terms accept --urn sac1647283583153:yourls-ubuntu-24-04:default:latest
az vm create \
--resource-group <your-rg> \
--name yourls \
--image sac1647283583153:yourls-ubuntu-24-04:default:latest \
--size Standard_B2s \
--admin-username azureuser \
--generate-ssh-keys \
--public-ip-sku StandardOpen ports 80 and 443:
az vm open-port --resource-group <your-rg> --name yourls --port 80,443Step 3 - Confirm the services are running
SSH in as azureuser and confirm that Apache and MariaDB are active. MariaDB is bound to 127.0.0.1:3306 only, while Apache serves on port 80.
systemctl is-active apache2 mariadbss -tlnH | grep -E ':80 |:3306 ' | sed 's/ */ /g'Confirm that the first-boot credential rotation completed. It leaves a marker file behind, and that check stays true for the life of the VM:
test -f /var/lib/sac/data/yourls-firstboot.done && echo "first boot: completed"yourls-firstboot is a one-shot service. It runs once, on the very first boot of your VM, to generate this instance's credentials. It then disables itself so it can never run again and overwrite them.
As a result, systemctl is-enabled yourls-firstboot reports disabled, and after any reboot systemctl is-active yourls-firstboot reports inactive. Both are the expected, healthy states for a service that has already done its job. Check the marker file above, not the service state.
Step 4 - Retrieve the per-VM administrator password
The first-boot service generates an administrator password that is unique to your VM and writes it to a root-only file. Read it over SSH:
sudo cat /root/yourls-credentials.txtYOURLS_URL is the address the VM resolved for itself on first boot: the public IP when the VM has one, otherwise its private address. It is recorded for reference and for command-line tooling on the VM.
YOURLS itself follows whatever address you browse it on. You do not need to edit any configuration when you attach a DNS name or when a stop and start changes the public IP.
Step 5 - Sign in
Browse to http://<vm-ip>/admin/ and sign in with the username admin and the password from the credentials file. Browsing to http://<vm-ip>/ redirects here.
After you sign in, you land on the admin interface. It shows your link total and click total, the box for shortening a new URL, and the table of every link you have created.
A fresh instance is empty. The upstream sample links are removed during the build, so the first link in the table is your own.
Step 6 - Shorten your first link
Paste a long URL into Enter the URL. Leave Custom short URL blank to have YOURLS generate a keyword, or type one to choose your own. Then select Shorten The URL. The new link appears immediately with its short URL, the original URL, the date and a click counter.
The short URL is built from the address you are browsing, so it is one your audience can use. Visiting it redirects straight to the original URL and records a click.
Step 7 - Read the click analytics
Every link has a statistics page. Append a + to any short URL, or select the Stats link, to open it. YOURLS reports the click count over the last 24 hours, 7 days, 30 days and all time, and your best day. It also provides tabs for traffic location and traffic sources.
The country breakdown under Traffic location is resolved on the VM itself from a GeoLite2 database bundled with YOURLS. Your visitors' addresses are never sent to a third-party service.
Step 8 - No known or default credentials
This image ships with no usable login. The administrator password set at build time is rotated to a random value that is discarded and never recorded. The first-boot service then sets a fresh password unique to your VM before YOURLS serves a single request.
YOURLS has no user table. Its accounts live in one array in its configuration file, so the single admin entry below is the complete list of accounts on this instance. It is stored as a bcrypt hash, never in clear text.
The round-trip check confirms that the per-VM password authenticates against the real sign-in form and that the session cookie is issued host-only.
sudo grep -A2 'yourls_user_passwords' /var/www/yourls/user/config.php | grep phpass | cut -c1-46sudo bash /usr/local/sbin/yourls-cred-roundtrip.shTo change the administrator password to one of your own, edit the $yourls_user_passwords array in /var/www/yourls/user/config.php. You can enter your new password there in plain text, and YOURLS replaces it with a hash the first time you sign in. That approach requires making the file writable by the web server.
The safer option, and the one this image is built around, is to generate the hash yourself and leave the file read-only:
sudo php -r 'echo "phpass:".password_hash("<new-password>", PASSWORD_BCRYPT)."\n";'Paste the printed value in place of the existing phpass:... string for the admin entry, keeping the surrounding quotes. Then reload Apache with sudo systemctl reload apache2.
Step 9 - Verify the stack and where your data lives
Confirm the installed release, the health endpoint and the data disk layout. Both the MariaDB database (every short link and every click) and the YOURLS user tree (your configuration plus any plugins or pages you add) live on the dedicated data disk, bind-mounted into place. Your data stays off the operating system disk.
grep YOURLS_VERSION /var/www/yourls/includes/version.phpcurl -sI http://127.0.0.1/healthz | sed -n 1pfindmnt -no SOURCE,TARGET,FSTYPE,SIZE /data;
findmnt -no SOURCE,TARGET /var/lib/mysql;
findmnt -no SOURCE,TARGET /var/www/yourls/userAdding your own domain and TLS
A shortener is only as good as the domain in front of it. Point a DNS A record at the VM's public IP, then issue a certificate with Certbot:
sudo apt-get update && sudo apt-get install -y certbot python3-certbot-apache
sudo certbot --apache -d s.your-domain.example --agree-tos -m you@your-domain.example --redirectCertbot configures Apache for HTTPS and installs a renewal timer. Nothing else needs to change. YOURLS on this image builds its short links, its pages and its sign-in form from the address you browse. Once your domain resolves and TLS is terminated, every new link is issued as https://s.your-domain.example/keyword automatically.
Links created before you attached the domain keep their keyword and are served on the new domain too.
Backing up
Everything worth keeping is on the data disk: the MariaDB database and the user tree. For a full machine-level backup, take an Azure snapshot of the data disk. Alternatively, dump the database and archive the tree:
sudo mysqldump --protocol=socket -uroot --single-transaction yourls > /var/tmp/yourls-backup.sql
sudo tar -czf /var/tmp/yourls-user.tar.gz -C /data/yourls userStore both copies off the VM. The simplest scheduled option is an Azure Backup policy on the VM and its data disk.
Security notes
- Protect the configuration file. The YOURLS configuration file holds the database password and the administrator hash. The web server denies access to it, so it cannot be fetched over HTTP.
- Keep MariaDB private. The bundled MariaDB listens on
127.0.0.1:3306only. Keep port 3306 closed in your NSG, because nothing outside the VM needs it. - Use per-VM passwords. The administrator and database passwords are unique to your VM, generated on first boot, and written only to
/root/yourls-credentials.txtwith0600 root:rootpermissions. The administrator password is stored in the configuration only as a bcrypt hash. - Keep the code tree read-only. The YOURLS code tree is owned by root and is not writable by the web server.
- Use host-only cookies. Session cookies are issued host-only, so sign-in behaves correctly whether you browse the instance by IP or through a DNS name.
- Keep the admin area private. The admin area and the API require your password, because YOURLS runs in private mode. Only the short link redirects themselves are public, which is what a shortener is for.
- Encrypt web traffic. Serve the shortener over HTTPS before you publish links, and restrict
22/tcpto your management network. - Keep the VM patched. The base OS is fully patched at build time, and unattended security upgrades remain enabled on your VM.
Trademark
YOURLS is a trademark of its respective owner. SecureAnyCloud is not affiliated with, endorsed by, or sponsored by the YOURLS project. This image packages the open source YOURLS software, which is distributed under the MIT licence. All product and company names are the property of their respective holders.
YOURLS includes GeoLite2 data created by MaxMind, available from https://www.maxmind.com.
Support
SecureAnyCloud provides 24/7 technical support for this image by email (sales@secureanycloud.com) and live chat. Support covers deployment, configuration, custom domain setup, upgrades, performance tuning and MariaDB administration. Critical issues receive a one-hour average response time.
Deploy on Azure
Launch YOURLS URL Shortener on Ubuntu 24.04 LTS on Azure with 24/7 support from SecureAnyCloud.
View this image
Need Help?
Our support team is available 24/7.
sales@secureanycloud.com
Overview
YOURLS (Your Own URL Shortener) is a popular self-hosted, open source link shortener. It lets you create short links on your own domain and choose custom keywords. It keeps the click analytics (hits over time, referrer sources and country breakdowns) on infrastructure you control rather than a third-party service. A bookmarklet and a full REST API are included.
This SecureAnyCloud image delivers YOURLS fully installed and security-hardened. Apache with PHP 8.3 fronts the application, and MariaDB holds every short link and click. The installer is pre-completed at build time, so no open setup wizard ships. Short-URL routing is configured in the web server (not in an .htaccess that a default configuration ignores), so links resolve the moment you launch.
Every instance generates a unique MariaDB password, a unique YOURLS administrator password and a fresh authentication cookie key on first boot, and writes them to a root-only file. No shared or default credential ships in the image. All of your data (the MariaDB database plus the YOURLS configuration and any plugins you add) lives on a dedicated data volume, separate from the operating system disk.
What you get:
- YOURLS 1.10.4 served by Apache on port 80 with PHP 8.3 and OPcache.
- MariaDB holding the links and click analytics, bound to the loopback interface only.
- The installer pre-completed and short-URL routing configured in the Apache virtual host, so no open setup step is reachable.
- Unique MariaDB and administrator passwords, plus a fresh cookie key, generated on first boot and recorded in a root-only file.
- The administrator password stored only as a bcrypt hash. The application follows whatever address you browse it on, so it works on the instance address and after you attach your own domain, with no edit.
- A dedicated data volume carrying the MariaDB datadir and the YOURLS
user/tree. apache2.serviceandmariadb.serviceas systemd units, enabled and active.- 24/7 SecureAnyCloud support.
Prerequisites
- An AWS account, an EC2 key pair in the target region, and a VPC with a public subnet.
- The recommended instance type: m5.large (2 vCPU / 8 GiB RAM).
- Security group inbound rules that allow
22/tcpfrom your management network for SSH, and80/tcp(and443/tcponce you enable HTTPS) for the web interface.
Step 1 - Launch the AMI
Subscribe to the listing in AWS Marketplace and choose Continue to Launch. Launch through the EC2 console or the AWS CLI.
Select the m5.large instance type, your key pair, and a security group that opens ports 22 and 80.
aws ec2 run-instances \
--image-id <ami-id> \
--instance-type m5.large \
--key-name <your-key-pair> \
--security-group-ids <security-group-id> \
--subnet-id <subnet-id> \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=yourls}]'Step 2 - Connect to your instance
Connect over SSH as the default login user for the OS variant you launched. This listing may ship more than one OS variant, so use the matching login user below.
- Ubuntu 24.04 LTS: SSH login user ubuntu. Connect with ssh ubuntu@<instance-public-ip>
Step 3 - Confirm the services are running
YOURLS is served by Apache and PHP, backed by MariaDB, with a one-shot first-boot service that creates the per-instance credentials. Confirm that the two long-running services are healthy:
systemctl is-active apache2.service mariadb.serviceEach reports active:
active activeStep 4 - Verify the stack and endpoints
Run these checks. They confirm the deployed YOURLS version, that MariaDB is bound to the loopback interface only, that the health endpoint answers and that the admin interface is up. They also confirm that the site root redirects to the admin interface, because YOURLS ships no public front page by default:
grep -oE "YOURLS_VERSION', '[0-9.]+'" /var/www/yourls/includes/version.php php -v | head -1 ss -tln | grep 127.0.0.1:3306 curl -s -o /dev/null -w 'healthz: HTTP %{http_code}\n' http://127.0.0.1/healthz curl -s -o /dev/null -w 'admin: HTTP %{http_code}\n' http://127.0.0.1/admin/ curl -s -o /dev/null -w 'root: HTTP %{http_code}\n' http://127.0.0.1/Expected output (the site root answers 302, redirecting to /admin/):
YOURLS_VERSION', '1.10.4' PHP 8.3.6 (cli) (built: Jul 16 2026 18:30:41) (NTS) LISTEN 0 80 127.0.0.1:3306 0.0.0.0:* healthz: HTTP 200 admin: HTTP 200 root: HTTP 302The database and the YOURLS user/ tree both live on the dedicated data volume, separate from the OS disk:
findmnt -no SOURCE,TARGET /data
findmnt -no SOURCE,TARGET /var/lib/mysql
findmnt -no SOURCE,TARGET /var/www/yourls/user/dev/nvme1n1 /data /dev/nvme1n1[/mysql] /var/lib/mysql /dev/nvme1n1[/yourls/user] /var/www/yourls/userStep 5 - Read your first-boot credentials
On the first boot of every instance, a one-shot service generates a unique administrator password and a unique database password. It records them, along with the browse address, in a root-only file. Read the file:
sudo cat /root/yourls-credentials.txtThe administrator account is admin, and its password is the value of YOURLS_ADMIN_PASSWORD. The administrator password exists in plaintext only in this root-only file. In the YOURLS configuration it is stored solely as a bcrypt hash. Once you have saved the password in your own password manager, you may delete this file.
Step 6 - Prove the sign-in round-trip
Confirm that the recorded administrator password authenticates end to end against the live login form. Also confirm that the session cookie comes back host-only, which is the correct, browser-accepted scope for a single-host appliance:
sudo bash /usr/local/sbin/yourls-cred-roundtrip.shROUNDTRIP OK: admin authenticated against the live login form; session cookie is host-onlyStep 7 - Sign in to the admin interface
Browse to http://<instance-public-ip>/ in your browser. It redirects to the admin interface. Sign in with the username admin and the password from Step 5.
Step 8 - Shorten a link
In the admin interface, paste a long URL into Enter the URL, optionally set a custom keyword, and choose Shorten The URL. YOURLS returns the short link and a stats link for it. Short links resolve at http://<instance-public-ip>/<keyword>.
The admin interface lists every short link you create, with its original URL, creation date, source IP and live click count.
Step 9 - Review click analytics
Open a link's statistics page (the + after a short URL) to see its click history over time, its historical counts, and the traffic-location and traffic-source breakdowns. The bundled GeoLite2 database powers the breakdowns.
Step 10 - Attach your own domain and enable HTTPS
YOURLS derives its site address from the request Host header. It works on the instance IP immediately and keeps working the moment you point a domain at the instance, with no configuration file to edit. To serve the shortener under your own domain over HTTPS, point an A record at the instance, then install a certificate with Certbot:
sudo apt-get update && sudo apt-get install -y certbot python3-certbot-apache
sudo certbot --apache -d links.your-domain.exampleOpen 443/tcp in the security group. The host-only authentication cookie and the short-URL routing continue to work unchanged under the new domain and under HTTPS.
How the image is secured
- No shared credential ships. YOURLS has no user table. The single administrator entry in the configuration is the complete account list. Its password, the database grant and the authentication cookie key are all rotated to discarded random values at build time and re-created per instance on first boot. The shipped image therefore authenticates nothing until your instance boots.
- The database is loopback-only. MariaDB listens on
127.0.0.1, and the security group never opens3306. - The configuration and library files are not web-reachable. The file holding the database password and administrator hash, and the PHP/library tree (including the 9 MB GeoLite2 database), return
403over HTTP. The browser assets the admin interface needs still serve normally. - First boot is a one-shot.
yourls-firstboot.serviceruns once, rotates every secret and records the browse address. It does not run again on later reboots. This is expected and not a fault.
Support
SecureAnyCloud provides 24/7 technical support for this YOURLS image by email (sales@secureanycloud.com) and live chat. Support covers deployment and configuration, custom domain and TLS setup, plugin and REST API configuration, version upgrades, performance tuning, and MariaDB database administration. For billing or subscription changes, contact sales@secureanycloud.com.
Deploy on AWS
Launch YOURLS with 24/7 support from SecureAnyCloud.
View on Marketplace
Need Help?
Our support team is available 24/7.
sales@secureanycloud.com