Install Polr on CentOS 8 – Quick‑Start Guide
If you’re looking to spin up a lightweight link shortener without the hassle of a commercial SaaS, Polr is a solid choice. Below is a straight‑to‑the‑point walkthrough that covers everything from adding the right repos to configuring your database and PHP.
1. Prep Your Server
sudo dnf update -y && sudo dnf upgrade -y
An out‑of‑date system can bite you later—especially when dealing with dependencies like MariaDB or PHP that expect newer libraries.
2. Install Core Packages
Polr runs on PHP, a web server (we’ll use Nginx), and MariaDB. The default CentOS 8 repos ship PHP 7.2, but Polr needs at least 7.3, so we pull in the Remi repo.
sudo dnf install -y epel-release
sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm
sudo dnf module enable php:remi-7.4 -y # pick 8.0 if you prefer, but 7.4 is stable
sudo dnf install -y nginx mariadb-server \
php-fpm php-mysqlnd php-gd php-curl php-json php-cli php-zip php-xml php-bcmath \
git composer
The Remi repo gives you a newer PHP stack, and the extensions listed are what Polr expects. Forgetting php-xml or php-gd will trip you up during runtime.
3. Start & Enable Services
sudo systemctl enable --now nginx mariadb php-fpm firewalld
These services need to run at boot and be reachable from the network; otherwise your Polr install will never get a web request.
4. Secure MariaDB
sudo mysql_secure_installation
Follow the prompts: set root password, remove anonymous users, disallow remote root login, drop test database. I’ve seen deployments fail right after this step when people left the default “root” user without a password; the web app can’t connect.
5. Create Polr Database & User
sudo mysql -u root -p <<'SQL' CREATE DATABASE polr CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; GRANT ALL PRIVILEGES ON polr.* TO 'polruser'@'localhost' IDENTIFIED BY 'StrongPass!23'; FLUSH PRIVILEGES; EXIT; SQL
Polr needs its own database namespace. Using a dedicated user keeps the principle of least privilege in check.
6. Pull Polr from GitHub
sudo mkdir -p /var/www/polr cd /var/www/polr sudo git clone https://github.com/cydrobolt/Polr.git .
Cloning directly into /var/www keeps the files under the web root and simplifies permissions later.
7. Set Permissions
sudo chown -R nginx:nginx /var/www/polr
sudo find /var/www/polr -type d -exec chmod 755 {} \;
sudo find /var/www/polr -type f -exec chmod 644 {} \;
Nginx runs as the nginx user, so it needs read/write access to the storage directories. The storage, uploads, and .env files must be writable.
8. Configure .env File
sudo cp .env.example .env
Edit .env with a text editor:
APP_URL=http://your.server.ip DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=polr DB_USERNAME=polruser DB_PASSWORD=StrongPass!23
The .env file tells Polr where to find its database and what public URL it should advertise. If you forget to set APP_URL, links will point at the wrong domain.
9. Run Composer Install
sudo -u nginx composer install --no-dev
Composer pulls PHP dependencies that Polr relies on (Laravel framework, etc.). Running it as the web user avoids permission headaches later.
10. Apply Database Migrations
sudo -u nginx php artisan migrate
This creates all the tables Polr expects. If you skip this, the first request to the app will throw a “relation does not exist” error.
11. Configure Nginx
Create /etc/nginx/conf.d/polr.conf with:
server {
listen 80;
server_name your.server.ip;
root /var/www/polr/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
}
Reload Nginx:
sudo nginx -t && sudo systemctl reload nginx
The try_files line routes everything to Laravel’s front controller. If you forget it, Polr won’t resolve pretty URLs.
12. Adjust SELinux & Firewall (Optional but Recommended)
If SELinux is enforcing, enable database connectivity for PHP:
sudo setsebool -P httpd_can_network_connect_db=1
Open HTTP/HTTPS ports:
sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --permanent --add-service=https sudo firewall-cmd --reload
CentOS’s default SELinux policy blocks PHP from talking to MariaDB, and firewalld hides your site from the world. Without these tweaks you’ll hit a “connection timed out” or “no route to host” in the browser.
13. Final Touch – Hit It
Open a browser to http://your.server.ip (or the domain you set in .env). You should see Polr’s login screen. Log in with the default credentials (admin@example.com / admin) and change them immediately.
If anything looks off—errors pop up, pages don’t load—check /var/log/nginx/error.log and PHP logs for clues. The most common hiccup is a missing PHP extension; you’ll see a clear “Class not found” message pointing to the culprit.
That’s it: Polr is now serving links from your CentOS 8 box. Keep an eye on updates—Polr pulls fresh code via Git, so git pull followed by composer install --no-dev and php artisan migrate will keep you running smoothly.
Enjoy shortening URLs faster than a cat video can load!