How to Install Pastefy on OpenSUSE latest

Introduction

Pastefy is a free and open source pastebin service that allows sharing of code snippets and text with others. In this tutorial, we will discuss how to install Pastefy on OpenSUSE latest

Prerequisites

Before beginning this tutorial, you should make sure that you have:

Step 1: Install Dependencies

Pastefy requires some dependencies to be installed. You can install the dependencies using the following command in terminal:

sudo zypper install git nginx php7 php7-fpm php7-gd php7-mbstring php7-pdo php7-imagick

This will install git, nginx, PHP7 and required PHP modules.

Step 2: Clone Pastefy Repository

Once the dependencies are installed, clone the Pastefy repository using the following command:

git clone https://github.com/Lednerb/Pastefy.git

This will clone the repository into the directory 'Pastefy'. Change directory into Pastefy:

cd Pastefy

Step 3: Configure Nginx

The next step is to configure Nginx server. Create and open nginx configuration file at /etc/nginx/conf.d/pastefy.conf using your favorite text editor:

sudo nano /etc/nginx/conf.d/pastefy.conf

Copy the following into the file Editor:

server {
    listen       80;
    server_name  your_domain.com;  # replace with your domain name

    location / {
        root   /path/to/Pastefy;
        index  index.php;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    location ~ \.php$ {
        root           /path/to/Pastefy;
        fastcgi_pass   unix:/var/run/php-fpm7.sock;
        fastcgi_index  index.php;
        try_files      $uri =404;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

Update values of server_name and root directory respectively.

Save the file by pressing 'ctrl + X' then 'Y'. Lastly, press 'Enter'.

Step 4: Configure PHP-FPM

Now, we need to configure PHP-FPM. Open the PHP-FPM configuration file at /etc/php7/fpm/php-fpm.conf using your favorite text editor:

sudo nano /etc/php7/fpm/php-fpm.conf

Make the following changes:

pid = /var/run/php-fpm7.pid
listen = /var/run/php-fpm7.sock

Save the file by pressing 'ctrl + X' then 'Y'. Lastly, press 'Enter'.

Step 5: Configure PHP

Next, we will configure PHP. Open the PHP configuration file at /etc/php7/cli/php.ini using your favorite text editor:

sudo nano /etc/php7/cli/php.ini

Make following changes:

cgi.fix_pathinfo=0

Save the file by pressing 'ctrl + X' then 'Y'. Lastly, press 'Enter'.

Step 6: Install Database

Pastefy uses MySQL database to store data. You can install MySQL database using the following command:

sudo zypper install mysql-server

Start and enable the MySQL service:

sudo systemctl start mysql-server
sudo systemctl enable mysql-server

Set the MySQL root password using the following command:

sudo mysql_secure_installation

Follow the on-screen instructions to configure the MySQL root password and remove unsafe defaults.

Once done, login to MySQL with the following command:

sudo mysql -u root -p

Create a new database and user:

CREATE DATABASE pastefy;
CREATE USER 'pastefy_user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON pastefy.* TO 'pastefy_user'@'localhost';
FLUSH PRIVILEGES;
exit;

Replace 'password' with your preferred password for the user.

Step 7: Configuration

To configure Pastefy, rename the file .env.example to .env:

mv .env.example .env

Edit the .env file:

sudo nano .env

Make changes with the following fields:

DB_DATABASE=pastefy
DB_USERNAME=pastefy_user
DB_PASSWORD=password  # replace with your MySQL password

Step 8: Install Composer

Pastefy uses Composer to manage its dependencies. You can install Composer using the following command:

sudo zypper install composer

Step 9: Install Dependencies

Next, install the PHP dependencies.

composer install

Step 10: Generate App Key

Generate a new app key:

php artisan key:generate

Step 11: Create Tables

Create database tables using migration:

php artisan migrate

Step 12: Fix File Permissions

Switch to the web site root directory:

cd /path/to/Pastefy

Set appropriate file permissions:

sudo chown -R nginx:nginx storage bootstrap/cache
sudo chmod -R 775 storage bootstrap/cache

Step 13: Restart Services

Finally, restart nginx and PHP-FPM:

sudo systemctl restart nginx
sudo systemctl restart php7-fpm

Conclusion

Congratulations! You have successfully installed Pastefy on OpenSUSE, and now you can paste and share text or code snippets with others.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!