{"id":18423,"date":"2016-01-09T15:27:06","date_gmt":"2016-01-09T21:27:06","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=18423"},"modified":"2022-06-03T03:43:54","modified_gmt":"2022-06-03T08:43:54","slug":"how-to-install-yourls-on-ubuntu-14-04","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-install-yourls-on-ubuntu-14-04\/","title":{"rendered":"How to install YOURLS on Ubuntu 14.04"},"content":{"rendered":"
In this guide, we will explain how to install YOURLS on an Ubuntu 14.04 VPS<\/strong> with MariaDB, PHP-FPM and Nginx. YOURLS stands for Your Own URL Shortener. YOURLS is an open source self-hosted application build with PHP which allows you to run your own URL shortening service. This guide should work on other Linux VPS<\/a> systems as well but was tested and written for an Ubuntu 14.04 VPS<\/a>. To add the MariaDB repository to your sources list and install the latest MariaDB server, run the following commands:<\/p>\n When the installation is complete, run the following command to secure your installation:<\/p>\n Next, we need to create a database for the YOURLS installation.<\/p>\n To install the latest stable version of PHP version 7 and all necessary modules, run:<\/p>\n Create a new PHP-FPM pool for your user:<\/p>\n Do not forget to change your_user with your username.<\/p>\n Restart PHP-FPM:<\/p>\n Create a root directory for the YOURLS installation using the following command:<\/p>\n Clone the github repository<\/p>\n Copy the Open the Ubuntu 14.04 comes with nginx version 1.4, to install the latest stable version of Nginx version 1.8, run:<\/p>\n Create a new Nginx server block with the following content:<\/p>\n Do not forget to change your_user with your username.<\/p>\n Activate the server block by creating a symbolic link :<\/p>\n Test the Nginx configuration and restart nginx:<\/p>\n Open http:\/\/myYOURLS.com\/admin in your favorite web browser and you should see the YOURLS install screen. Click on the ‘Install YOURLS’ button to populate the database.<\/p>\n That\u2019s it. You have successfully installed YOURLS on your Ubuntu 14.04 VPS. For more information about how to manage your YOURLS installation, please refer to the official YOURLS <\/a> documentation.<\/p>\n Of course you don\u2019t have to do any of this if you use one of our Linux VPS Hosting<\/a> services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.<\/p>\n PS<\/strong><\/span>. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":" In this guide, we will explain how to install YOURLS on an Ubuntu 14.04 VPS with MariaDB, PHP-FPM and Nginx. … <\/p>\n
\n<\/span><\/p>\nLogin to your VPS via SSH<\/h4>\n
ssh user@vps_IP<\/pre>\n
Update the system and install necessary packages<\/h4>\n
[user]$ sudo apt-get update && sudo apt-get -y upgrade\r\n[user]$ sudo apt-get install software-properties-common git nano<\/pre>\n
Install MariaDB 10.1<\/h4>\n
[user]$ sudo apt-key adv --recv-keys --keyserver hkp:\/\/keyserver.ubuntu.com:80 0xcbcb082a1bb943db\r\n[user]$ sudo add-apt-repository 'deb http:\/\/ftp.osuosl.org\/pub\/mariadb\/repo\/10.1\/ubuntu trusty main'\r\n[user]$ sudo apt-get update\r\n[user]$ sudo apt-get install -y mariadb-server<\/pre>\n
[user]$ mysql_secure_installation<\/pre>\n
[user]$ mysql -uroot -p<\/pre>\n
MariaDB [(none)]> CREATE DATABASE yourls;\r\nMariaDB [(none)]> GRANT ALL PRIVILEGES ON yourls.* TO 'yourls'@'localhost' IDENTIFIED BY 'yourls_passwd';\r\nMariaDB [(none)]> FLUSH PRIVILEGES;\r\nMariaDB [(none)]> \\q<\/pre>\n
Install PHP, composer and required PHP modules<\/h4>\n
[user]$ sudo add-apt-repository -y ppa:ondrej\/php-7.0\r\n[user]$ sudo apt-get update\r\n[user]$ sudo apt-get -y install php7.0-fpm php7.0-cli php7.0-mysql php7.0-curl<\/pre>\n
PHP-FPM configuration<\/h4>\n
[user]$ sudo nano \/etc\/php\/7.0\/fpm\/pool.d\/your_user.conf<\/pre>\n
[your_user]\r\nuser = your_user\r\ngroup = your_user\r\nlisten = \/var\/run\/php\/php7.0-fpm-your_user.sock\r\nlisten.owner = your_user\r\nlisten.group = your_user\r\nlisten.mode = 0666\r\npm = ondemand\r\npm.max_children = 5\r\npm.process_idle_timeout = 10s\r\npm.max_requests = 200\r\nchdir = \/\r\n<\/pre>\n
[user]$ sudo service php7.0-fpm restart<\/pre>\n
Clone and configure YOURLS<\/h4>\n
[user]$ mkdir -p ~\/myYOURLS.com\/{public_html,logs}<\/pre>\n
[user]$ git clone --branch master https:\/\/github.com\/YOURLS\/YOURLS.git ~\/myYOURLS.com\/public_html<\/pre>\n
user\/config-sample.php<\/code> file to
user\/config.php<\/code>.<\/p>\n
[user]$ cp ~\/myYOURLS.com\/public_html\/user\/config-sample.php ~\/myYOURLS.com\/public_html\/user\/config.php<\/pre>\n
user\/config.php<\/code> file and edit the following values<\/p>\n
[user]$ nano ~\/myYOURLS.com\/public_html\/user\/config.php<\/pre>\n
\/** MySQL database username *\/\r\ndefine( 'YOURLS_DB_USER', 'yourls' );\r\n\r\n\/** MySQL database password *\/\r\ndefine( 'YOURLS_DB_PASS', 'yourls_passwd' );\r\n\r\n\/** The name of the database for YOURLS *\/\r\ndefine( 'YOURLS_DB_NAME', 'yourls' );\r\n\r\n** If you define it to \"http:\/\/sho.rt\", don't use \"http:\/\/www.sho.rt\" in your browser (and vice-versa) *\/\r\ndefine( 'YOURLS_SITE', 'http:\/\/myYOURLS.com' );\r\n\r\n\/** A random secret hash used to encrypt cookies. You don't have to remember it, make it long and complicated. Hint: copy from http:\/\/yourls.org\/cookie **\/\r\ndefine( 'YOURLS_COOKIEKEY', 'fNK$M]~BfF&f0S#{X3P)sMM#A%2)R27D&THBMa8V' );\r\n\r\n\/** Username(s) and password(s) allowed to access the site. Passwords either in plain text or as encrypted hashes\r\n ** YOURLS will auto encrypt plain text passwords in this file\r\n ** Read http:\/\/yourls.org\/userpassword for more information *\/\r\n$yourls_user_passwords = array(\r\n 'your_username' => 'your_password',\r\n \/\/ 'username2' => 'password2',\r\n \/\/ You can have one or more 'login'=>'password' lines\r\n );\r\n<\/pre>\n
Install and configure Nginx<\/h4>\n
[user]$ sudo add-apt-repository -y ppa:nginx\/stable\r\n[user]$ sudo apt-get update\r\n[user]$ sudo apt-get -y install nginx<\/pre>\n
[user]$ sudo nano \/etc\/nginx\/sites-available\/myYOURLS.com<\/pre>\n
server {\r\n listen 80;\r\n server_name myYOURLS.com;\r\n root \/home\/your_user\/myYOURLS.com\/public_html;\r\n\r\n access_log \/home\/your_user\/myYOURLS.com\/logs\/access.log;\r\n error_log \/home\/your_user\/myYOURLS.com\/logs\/error.log;\r\n\r\n index index.php;\r\n\r\n location \/ {\r\n try_files $uri $uri\/ \/yourls-loader.php;\r\n expires 14d;\r\n add_header Cache-Control 'public';\r\n }\r\n\r\n location ~ \\.php$ {\r\n fastcgi_split_path_info ^(.+\\.php)(\/.+)$;\r\n fastcgi_pass unix:\/var\/run\/php\/php7.0-fpm-your_user.sock;\r\n fastcgi_index index.php;\r\n include fastcgi_params;\r\n fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\n fastcgi_intercept_errors off;\r\n fastcgi_buffer_size 16k;\r\n fastcgi_buffers 4 16k;\r\n }\r\n}\r\n<\/pre>\n
[user]$ sudo ln -s \/etc\/nginx\/sites-available\/myYOURLS.com \/etc\/nginx\/sites-enabled\/myYOURLS.com<\/pre>\n
[user]$ sudo nginx -t\r\n[user]$ sudo service nginx restart<\/pre>\n
Final steps<\/h4>\n
\n