Setting upp development environment

Web server

 

sudo apt install acl wget curl vim git tree php php-common libapache2-mod-php \
php-cli php-fpm php-json php-pdo php-mysql php-zip php-gd  php-mbstring \
php-curl php-xml php-pear php-bcmath php-cgi zip unzip certbot \
python3-certbot-apache mariadb-server
sudo a2enmod rewrite
sudo a2enmod ssl

 

Apache

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

 

<VirtualHost *:80>
  ServerAdmin webmaster@localhost
  DocumentRoot /var/www/html

  RewriteEngine on

  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined

  <Directory /var/www/html>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
  </Directory>

  RewriteCond %{SERVER_NAME} =example.com [OR]
  RewriteCond %{SERVER_NAME} =www.exaple.com
  RewriteRule ^ %{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

 

sudo vim /etc/apache2/sites-available/default-ssl.conf

 

<IfModule mod_ssl.c>
  <VirtualHost _default_:443>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    RewriteEngine on

    <Directory /var/www/html>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      allow from all
    </Directory>

    SSLEngine on

    SSLCertificateFile  /etc/ssl/certs/snake-oil.crt
    SSLCertificateKeyFile /etc/ssl/private/snake-oil.key

    <FilesMatch "\.(cgi|shtml|phtml|php)$">
        SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory /usr/lib/cgi-bin>
        SSLOptions +StdEnvVars
    </Directory>

  </VirtualHost>
</IfModule>

 

PHP

 

sudo php -i | grep -i "upload\_max\_filesize\|post\_max\_size\|max\_file\_uploads\|memory\_limit"

 

Change values in sudo vim /etc/php/7.4/apache2/php.ini and sudo vim /etc/php/7.4/cli/php.ini to:

 

max_file_uploads => 20 => 20
post_max_size => 8M => 40M
upload_max_filesize => 2M => 30M
memory_limit=>128=>512

 

Certificate

 

openssl genrsa -out pki/private/server.key
openssl req -new -key pki/private/server.key -out pki/reqs/server.req
./easyrsa sign-req server server

 

bash

 

export OSH="$HOME/.config/oh-my-bash"; bash -c "$(curl -fsSL raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)"

 

Node.js

Download and install

Nodejs

 

mkdir ~/dev
cd dev
wget nodejs.org/dist/v18.12.1/node-v18.12.1-linux-x64.tar.xz
VERSION=v18.12.1
DISTRO=linux-x64
sudo mkdir -p /usr/local/lib/nodejs
sudo tar -xJvf node-$VERSION-$DISTRO.tar.xz -C /usr/local/lib/nodejs

 

Register Nodejs in profile vim ~/.profile and add

 

# Nodejs
VERSION=v18.12.1
DISTRO=linux-x64
export PATH=/usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin:$PATH

 

Save, exit and reload profile

 

. ~/.profile

 

Continue reading Mastering VIM