so I'm trying to set up a YOURLS URL shortener on my Ubuntu 16.04 DO droplet. I'm very new to MySQL and PHP, so I can't figure out what might be wrong. I'm pretty good with Nginx as I've been using it forever, but it seems as if these errors are caused by the MySQL database and/or PHP config.
The setup:
Nginx root (for site): /var/www/bnbr.co/public_html
(bnbr.co is the domain I'll be using)
PHP config file (located at /var/www/bnbr.co/public_html/config.php)
php7.0-fpm pool (located at /etc/php/7.0/fpm/pool.d/username.conf)
MySQL setup:
MariaDB [(none)]> CREATE DATABASE yourls;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON yourls.* TO 'username'@'localhost' IDENTIFIED BY 'passwd';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q
EDIT: Nginx config file for domain (located at /etc/nginx/sites-enabled/bnbr_co)
# main
server {
listen 443;
server_name bnbr.co;
root /var/www/bnbr.co/public_html;
index index.php;
ssl on;
ssl_certificate /etc/letsencrypt/live/bnbr.co/cert.pem;
ssl_certificate_key /etc/letsencrypt/live/bnbr.co/privkey.pem;
ssl_session_timeout 10m;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
ssl_prefer_server_ciphers on;
location / {
try_files $uri $uri/ /yourls-loader.php;
expires 14d;
add_header Cache-Control 'public';
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm-username.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
}
# HTTP --> HTTPS REDIRS
# main
server {
listen 80;
server_name bnbr.co;
return 301 https://$server_name$request_uri;
} #`
I'm new to this stuff so I hope you guys can help.
Thanks!
I'll put here all steps necessary to do.
1) create user and walk through steps that it will ask:
2) create folders:
3) copy Your stuff to
publicfolder4) set owner and mods:
5) create php pool config at
/etc/php/7.0/fpm/pool.d/bnbr.confwith following content:6) restart php-fpm service
7) create host config for nginx and make it enabled:
8) restart nginx
Explanation:
I'm creating
bnbruser to keep all stuff in concrete isolated with user privileges place.Telling in php-fpm pool config that I need fpm listener with
bnbrprivileges and also defining where that spawned by fpm php process can access withopen_basedirdirective.Telling nginx to check
/home/bnbr/publicfolder.P.S. No need for letsencrypt, just attach Your domain to CloudFlare and it will give You long term wildcard ssl certificate + will hide Your server from ddos attacks.