Categories
Git

Git remove large file wrongly committed

git filter-branch --tree-filter 'rm -rf path/to/your/file' HEAD
git push
Categories
Web Server

Integrating PHP in Apache

To enable PHP in Apache add the following to httpd.conf and restart Apache:

LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so
    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

Finally, check DirectoryIndex includes index.php

DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:

/usr/local/etc/php/7.4/
Categories
Git

Build git server

For Debian,

sudo apt update && sudo apt install git

For centos,

sudo yum install git
sudo useradd -r -m -U -d /home/git -s /bin/bash git
sudo su - git
mkdir -p ~/.ssh && chmod 0700 ~/.ssh
touch ~/.ssh/authorized_keys && chmod 0600 ~/.ssh/authorized_keys
git init --bare ~/reponame.git

Git server is ready!

Pushing and Pulling from Local

On the LOCAL

cat ~/.ssh/id_rsa.pub

Add the above id_rsa.pub file content from LOCAL to below authorized_keys file ON THE SERVER

sudo nano /home/git/.ssh/authorized_keys

Create a LOCAL repo

cd /path/to/local/repo
git init .
git remote add origin git@SERVER_IP_ADDRESS:reponame.git
touch test_file
git add .
git commit -m "initial commit"
git push -u origin master
Categories
Database

Postgres backup restore command line

Backup

pg_dump -U DB_USER -W -F t DB_NAME > /path/to/file/dump_name.sql

Restore

Using psql

psql -U DB_USER DB_NAME < dump_name.sql

Using pg_restore

pg_restore -d DB_NAME /path/to/file/dump_name.sql -c -U DB_USER
Categories
Command Line

Plesk basic commands

Create customer

/usr/local/psa/bin/customer --create USERNAME -passwd PASSWORD -name USERNAME

Create user

plesk bin user --create EMAIL -owner USERNAME -passwd PASSWORD -cname USERNAME -role ROLE

The role could be owner or webmaster or …

Create subscription

plesk bin subscription --create example.com -owner USERNAME -service-plan "Default Domain" -ip xx.xx.xx.xx -login USERNAME -passwd "PASSWORD"