Skip to content

Latest commit

 

History

History
522 lines (415 loc) · 12.2 KB

README.md

File metadata and controls

522 lines (415 loc) · 12.2 KB

INFO

  • Guide created using Debian 11
  • If you don't have apt package manager maybe you have one of this package managers
  • If you have any suggestions create an Issue :D

PHP

Installation

1. Update and upgrade apt package manager

sudo apt update && sudo apt upgrade -y

2. Install required packages

sudo apt install -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg2

3. Add Ondrej Surý repository to sources list to be able to download and install PHP 8.*

sudo add-apt-repository ppa:ondrej/php

4. Update apt package manager

sudo apt update

5. Install PHP

You can replace with any other version of PHP, for example php5.6

sudo apt install php8.1 -y 

6. Check installation

php --version

7. Optional most used packages

sudo apt install php8.1-{bcmath,xml,fpm,mysql,zip,intl,ldap,gd,cli,bz2,curl,mbstring,pgsql,opcache,soap,cgi} -y

Optional configuration

All changes are in php.ini file. If you want set changes for CLI you need to update .ini file from /etc/php/8.1/cli/ directory. But if you want changes for websites you need to change .ini file from /etc/php/8.1/apache2/ directory

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

After changing in apache2 directory you must ALWAYS restart Apache2 server

sudo systemctl restart apache2

In nano you can go to specific line using CTRL + SHIFT + - , typing line number and pressing ENTER

Bigger POST upload size

post_max_size = 16M # Line 698

Bigger file upload size

upload_max_filesize = 16M # Line 850

More memory limit

memory_limit = 256M # Line 430

Composer

1. Update and upgrade apt package manager

sudo apt update && sudo apt upgrade -y

2. Install required PHP packages

Replace php8.1 with yours PHP version

sudo apt install wget php8.1-cli php8.1-zip unzip -y

3. Download Composer installer

wget -O composer-setup.php https://getcomposer.org/installer

4. Install Composer globally (For all users)

You can change installation directory by changing /usr/local/bin in --install-dir= parameter

sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

5. Update Composer

sudo composer self-update  

6. Check Composer version

sudo composer --version  

MySQL

Installation and basic configuration of MySQL and MySQL server

Installation

1. Update and upgrade apt package manager

sudo apt update && sudo apt upgrade -y

2. Install required packages

sudo apt install gnupg wget -y

3. Download MySQL .deb package

You can download another version of MySQL form here

# Example link, you put your link after wget
wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb

4. Add downloaded .deb package to package manager

Run your dpkg package with the -i flag, that indicates that you’d like to install from the specified file and * char depends all files that's name start from mysql-apt-config

sudo dpkg -i mysql-apt-config*

When you see screen with MySQL and MySQL tools select menu, select mysql-8 and press ENTER, press TAB and ENTER.

5. Update apt package manager

sudo apt update

6. Install MySQL server

sudo apt install mysql-server -y

During installation, you must set root account password and select authentication plugin. I recommend Strong password encryption

7. Check installation

sudo mysql --version

Configuration

1. Run secure installation and configure MySQL

sudo mysql_secure_installation

During installation, you need to configure the password validation level, choose whether you want to change the root password (if set), delete anonymous users or not, prohibit remote root login, delete the test database and reload the permissions.
I recommend: 2, No (if set), Yes, Yes, Yes, Yes

phpMyAdmin

Install phpMyAdmin

1. Update and upgrade apt package manager

sudo apt update && sudo apt upgrade -y

2. Install phpMyAdmin and required packages

Change php8.1 to your version, for example php5.6

sudo apt install wget php8.1 php8.1-cgi php8.1-mysqli php8.1-mbstring libapache2-mod-php php8.1-common php8.1-mysql phpmyadmin -y

During installation, you need to select phpMyAdmin type (Apache or lighthttpd). Press SPACE to select, TAB and ENTER. Next you must set up password to phpMyAdmin user and confirm it with root password (Set up in MySQL section)

Configure phpMyAdmin and resolve Deprecated... warnings and errors

1. Go to folder with phpMyAdmin

cd /usr/share

2. Create backup of phpMyAdmin

sudo mv phpmyadmin/ phpmyadminold/

3. Choose phpMyAdmin version and download

Go to phpMyAdmin version list, select wanted version and copy link.

wget https://files.phpmyadmin.net/phpMyAdmin/5.2.0/phpMyAdmin-5.2.0-all-languages.zip

4. Unzip downloaded folder

sudo unzip phpMyAdmin*

5. Copy downloaded directory and rename

sudo cp -r phpMyAdmin-5.2.0-all-languages phpmyadmin

# Optionally you can remove old directory
sudo rm -rf phpmyadminold

6. Create /tmp directory for phpMyAdmin

sudo mkdir /usr/share/phpmyadmin/tmp

7. Change permission to created directory

sudo chmod -R 777 /usr/share/phpmyadmin/tmp

8. Copy config file for phpMyAdmin

sudo cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php 

9. Set up blowfisz_secret encrypting property

sudo nano /usr/share/phpmyadmin/config.inc.php

Go to line 16 (Press CTRL + SHIFT + -, type 16 and press ENTER) and set up variable (Must be 32 characters long!)

$cfg['blowfish_secret'] = '11112222333344445555666677778888'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

Apache2 virtualhosts

You need to rename all domain.com with yours domain name

1. Create a domain directory

The -p flag create a /websites folder if you don't have it

sudo mkdir -p /websites/domain.com

2. Create a configuration file for a domain

sudo nano /etc/apache2/sites-available/domain.com.conf

3. Configure Virtual Host for your website

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName domain.com
    ServerAlias www.domain.com
    
    DocumentRoot /websites/domain.com
    
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    
    <Directory /websites/domain.com>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
     
    # SSL certificate, from HTTP to HTTPS
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =domain.com [OR]
    RewriteCond %{SERVER_NAME} =www.domain.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

4. Restart Apache2 server

sudo systemctl restart apache2

5. Enable site using a2ensite

sudo a2ensite domain.com.conf

6. Enable rewrite module in a2ensite

sudo a2enmod rewrite

7. Restart Apache2

sudo systemctl reload apache2

8. Setting up default Virtual Host to works correct

If you want host something on default host (000-deafult.conf) - for example: RoundCube - you need to set <Directory> tag in this Virtual Host like this:

sudo nano /etc/apache2/sites-available/000-default.conf

And under CustomLog ${APACHE_LOG_DIR}/access.log combined line you must put this lines

<Directory /var/www/html>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

Certbot

Installing Certbot

1. Update and upgrade apt package manager

sudo apt update && sudo apt upgrade -y

2. Install snapd package for another package managing

sudo apt install snapd -y

3. Install core package using snap

sudo snap install core

4. Refresh core using snap

sudo snap refresh core

5. Install Let'sEncrypt certbot using snap package

sudo snap install --classic certbot

6. Add symbolic link between snap installation folder and user sharable folder

sudo ln -s /snap/bin/certbot /usr/bin/certbot

Working with certificates

Adding certificate do domain

You need to replace all domain.com with your domain name and [email protected] with your email address

You need to add new certificate for all subdomains!

sudo certbot --apache --agree-tos --redirect -m [email protected] -d domain.com -d www.domain.com

If this is your first certificate on machine you need to agree wih TOS - type Y and press ENTER

Git

1. Update and upgrade apt package manager

sudo apt update && sudo apt upgrade -y

2. Install Git

sudo apt install git -y

3. Check installation

sudo git --version

SSH keys

1. Generate SSH key

sudo ssh-keygen -t rsa

2. Get SSH key:

sudo cat /root/.ssh/id_rsa.pub

NodeJS and NPM

1. Add .deb package to package manager

Replace 16.x with wanted version of NodeJS

curl -s https://deb.nodesource.com/setup_16.x | sudo bash

2. Install NodeJS using apt package manager

sudo apt install nodejs -y

3. Check installation

sudo node -v

Angular CLI

1. Install Angular CLI globally using -g flag

sudo npm install -g @angular/cli

2. Check installation

sudo ng version

Python

Installation

1. Update and upgrade apt package manager

sudo apt update && sudo apt upgrade -y

2. Install required packages

sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev -y

3. Download Python from official website

You can select another version from here

wget https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgz

4. Unzip downloaded package to install

sudo tar -xvf Python-3.10.0.tgz

5. Enter Python folder

cd Python-3.10.0

6. Run configure script for Python

sudo ./configure --enable-optimizations

7. Make Python installation

sudo make -j 2

8. Make alt-install for Python

sudo make altinstall

9. Check installation

sudo python3.10 --version

PIP3

1. Install required packages

sudo apt install python3-venv python3-pip -y

2. Install PIP and automatically upgrade

sudo pip3 install --upgrade pip

Change default version of Python

1. Update alternatives for Python

You need to change /usr/local/bin/python3.10 to path to Python version that you want to set as default.
1 number is a priority. 1 is the highest.

sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python3.10 1

Other packages

Sudo

1. Update and upgrade apt package manager

apt update && apt upgrade -y

2. Install sudo package

apt install sudo -y

Firefox

1. Update and upgrade apt package manager

apt update && apt upgrade -y

2. Install browser using apt package manager

sudo apt install firefox-esr -y

Geckodriver

1. Update and upgrade apt package manager

apt update && apt upgrade -y

2. Download tar archive with Geckodriver

wget https://github.com/mozilla/geckodriver/releases/download/v0.32.0/geckodriver-v0.32.0-linux64.tar.gz

3. Extract archive

sudo tar -xvzf geckodriver-v0.32.0-linux64.tar.gz

4. Make file executable

sudo chmod +x geckodriver