How to Install Pastila on Manjaro

Pastila is a lightweight, open-source pastebin software that comes with features for syntax highlighting, URL shortening, and password protection. This tutorial will guide you on how to install Pastila on Manjaro Linux.

Prerequisites

Before you proceed with the installation process, ensure that you have the following requirements:

Step 1: Update the System

Ensure that your system is updated and all packages are up-to-date. You can execute the following command to update the system:

sudo pacman -Syu

Step 2: Install Nginx Web Server

Pastila uses the Nginx web server to serve webpages. You need to install Nginx web server using the Pacman package manager.

sudo pacman -S nginx

After installing Nginx, start and enable the service to start automatically on boot time:

sudo systemctl start nginx
sudo systemctl enable nginx

To verify that Nginx is running, open the web browser and navigate to http://localhost. You should see the Nginx welcome page.

Step 3: Install PostgreSQL Database Server

Pastila uses PostgreSQL database server to store pastes and user data. You can install PostgreSQL using Pacman package manager:

sudo pacman -S postgresql

Once you have installed PostgreSQL, initialize the database server and start the PostgreSQL service:

sudo postgresql-setup --initdb --unit postgresql
sudo systemctl start postgresql
sudo systemctl enable postgresql

To verify that PostgreSQL is running, execute the following command:

sudo systemctl status postgresql

Step 4: Install Pastila

You can create a separate user account for Pastila using the following command:

sudo useradd -r -d /opt/pastila -m -U -s /usr/bin/nologin pastila

Clone the Pastila repository into /opt/pastila directory:

sudo git clone https://github.com/atmoner/pastila.git /opt/pastila

Change the ownership of the /opt/pastila directory to the pastila user:

sudo chown -R pastila:pastila /opt/pastila

Change the directory to /opt/pastila and install the dependencies using the Composer package manager:

cd /opt/pastila
sudo composer install

Create a new PostgreSQL database and user for Pastila:

sudo -i -u postgres
createdb pastila_db
createuser -P pastila_user

Assign a password to the pastila_user and grant permissions to access the database:

psql
ALTER USER pastila_user WITH PASSWORD 'password_here';
GRANT ALL PRIVILEGES ON DATABASE pastila_db to pastila_user;
\q
exit

Copy the .env.example file and rename it to .env:

sudo cp .env.example .env

Edit the .env file and modify the following settings:

APP_URL=http://localhost
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=pastila_db
DB_USERNAME=pastila_user
DB_PASSWORD=password_here

Generate the application key and create tables using the following command:

php artisan key:generate
php artisan migrate

Change the ownership of the storage and bootstrap/cache directories to the pastila user:

sudo chown -R pastila:pastila storage bootstrap/cache

Step 5: Configure Nginx

Create a new Nginx configuration file for Pastila:

sudo tee /etc/nginx/sites-available/pastila <<EOF
server {
    listen 80;
    server_name localhost;
    root /opt/pastila/public;
    index index.html index.htm index.php;

    location / {
        try_files \$uri \$uri/ /index.php\$is_args\$args;
    }

    location ~ \.php$ {
        include fastcgi.conf;
        fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}
EOF

Create a symbolic link from the configuration file to the sites-enabled directory:

sudo ln -s /etc/nginx/sites-available/pastila /etc/nginx/sites-enabled/

Verify the Nginx configuration syntax:

sudo nginx -t

Restart the Nginx service:

sudo systemctl restart nginx

Step 6: Test the Installation

Open your web browser and navigate to http://localhost. You should see the Pastila homepage. Congratulations! You have successfully installed Pastila on your Manjaro Linux system.

Conclusion

In this tutorial, we have demonstrated how to install Pastila on Manjaro Linux. Pastila is a powerful opensource pastebin software that is easy to install and use. You can now use Pastila to create and share pastes online.

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!