Tag: ubuntu

  • Rootless docker

    References

    ASSUMPTIONS

    1. You have no docker as root installed
    2. You have no root access (Not even use apt install)
    3. You want to install rootless and systemd style docker and docker compose and all other plugins
    4. You have a Ubuntu system – Latest (or VM) with default kernel
    5. Your Ubuntu distribution is not cutdown version

    Docker Root Installation Pre-Requisites

    loginctl enable-linger rtcamp # It creates /run/user/$(id -u)

    export XDG_RUNTIME_DIR=/run/user/$(id -u)

    echo "export PATH=/home/rtcamp/bin:\$PATH" >> ~/.bashrc

    echo "export DOCKER_HOST=unix:///run/user/\$(id -u)/docker.sock" >> ~/.bashrc

    Docker Installation

    curl -fsSL https://get.docker.com/rootless | sh

    Installing docker compose

    DOCKER_COMPOSE_VER=$(curl --silent https://api.github.com/repos/docker/compose/releases | jq -r '.[0].tag_name')

    DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} # only for the script to run

    mkdir -p $DOCKER_CONFIG/cli-plugins

    curl -SL https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VER}/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose

    chmod u+x $DOCKER_CONFIG/cli-plugins/docker-compose

    It all works 🎉 !

    But here are some common problems

    Network slow

    For this you can refer to https://docs.docker.com/engine/security/rootless/#network-is-slow

    Using privileged ports aka <1024

    #### Login to user having sudo access ####

    cp -v /etc/sysctl.conf /tmp/sys.conf
    echo "net.ipv4.ip_unprivileged_port_start=0" >> /tmp/sys.conf

    sudo mv -v /tmp/sys.conf /etc/sysctl.conf

    sudo sysctl --system
  • WordPress and Nginx (OpenResty)

    WordPress

    WordPress is a web content management system. It was originally created as a tool to publish blogs but has evolved to support publishing other web content, including more traditional websites, mailing lists and Internet forum, media galleries, membership sites, learning management systems and online stores.


    Ngins (Open Resty)

    OpenResty® is a full-fledged web platform that integrates our enhanced version of the Nginx core, our enhanced version of LuaJIT, many carefully written Lua libraries, lots of high quality 3rd-party Nginx modules, and most of their external dependencies. It is designed to help developers easily build scalable web applications, web services, and dynamic web gateways.


    File Structure

    The file structure is important to know which files to modify and which ones to not. Some are auto generated and auto modified (as we modify the settings in the admin GUI dashboard. Some are done manually [Only a very few things, that too very rarely])

    https://www.wpbeginner.com/beginners-guide/beginners-guide-to-wordpress-file-and-directory-structure/

    The above link talks about some basic file structure.


    Working


    Installing

    The installation can be done by 2 methods

    • Manually unpacking files (from tar)
    • Using WP-CLI (Almost Automated)

    Manual Installation

    Manual installation implies creating a repository, then downloading the package(tar) from wordpress and then unpacking it in a repository and then setting up the configs and database that is needed.

    https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lemp-on-ubuntu-18-04

    More about the manual method above.

    WP-CLI

    WP-CLI basically stands for WordPress CLI and can be used to automate some task like creating db, site root directory, installation , configuration etc. This makes it easier to install WordPress on any machine at ease.

    https://make.wordpress.org/cli/handbook/guides/installing/#recommended-installation

    https://make.wordpress.org/cli/handbook/guides/quick-start/#practical-examples

    Steps to follow for automatic(wp-cli) method is above

    Nginx Config

    Both of these needs nginx configs setup manually only (Can be automated)

    ...
    http {
    include mime.types;
    default_type application/octet-stream;
    server {
    ...
    root /var/www/wordpress/wordpress.example.com;
    index index.php index.html;
    ...
    location / {
    index index.php index.html;
    try_files $uri $uri/ /index.php$is_args$args;
    }
    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { log_not_found off; access_log off; allow all; }
    location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
    expires max;
    log_not_found off;
    }
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
    root /var/www/wordpress/wordpress.example.com;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one

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

    This is a basic config that needs to be done in order to have a fully working wordpress instalaltion.


    Possible Issues

    You can face issues in CSS breaking in the site if nginx is not configured properly or if ssl is not configured properly.

    Php Dependencies

  • Linux Saviours

    Few Basic linux (Ubuntu) stuff that will save you time and get the job done with ease.

    Linux and it's programs are by default built to allows users to accomplish tasks easily. But many people dont even know that there are many other useful commands and tools.

    Many people know the basics or only what they use more often, but there are more than what a general end user will know/use and what is included in the tool that the users may not be aware. These will make life easier for us. We shall see some of them here.

    Help

    There are a bunch of tool and places where we can get information and help about a certain tool or a command. Most of the the well build packages/application/tools have these things well documented and put in place as per need. But some custom tools/application/packages may not have it. Some of the things that can help us to get help are

    • man command(Manual) # Man Pages
      • man passwd
    • whatis command
      • whatis passwd
    • help/-help/–help argument
      • passwd -help
    • info command
      • info passwd
    • /usr/share/doc location
      • cat /usr/share/doc/passwd/*

    These are the commands and arguments and locations where we can find many useful information about any tool that has proper documentation.

    File System Structure

    Everything in linux is a file (just like how everything is a object in python) and so these needs to be well defined and well structured to have everything working properly and to have things in the right place.

    The "/" (Forward leaning slash) is the start of the file system (Also called as root of the file system). Everything in linux follow this tree structure only. Some most used and important directories are as follows.

    • Home Directories: /root/home/username
    • User Executables: /bin/usr/bin/usr/local/bin
    • System Executables: /sbin/usr/sbin/usr/local/sbin
    • Shared Libraries: /lib/usr/lib/usr/local/lib
    • Kernels & Boot-loaders: /boot
    • Configuration Files: /etc
    • Device Files: /dev
    • Temporary Files: /tmp
    • Other Mount-points: /media/mnt
    • Server Data: /var/srv
    • System Informations: /proc/sys
    • Optional Applications: /opt

    Sometimes when installing linux people tend to put different paths in different partitions. Even when it is in different partition’s the file system structure remains the same.

    This remains same by mounting it in the path or symlinking the partition in the root filestructure.

    File System (FS) is different from this. FS is all about partition scheme and partitioning and its methods and optimization etc.

    File(s) and Folder(s) Permission(s)

    Every file and folder has default and predefined permissions, they can be changed/removed/revoked etc by few commands. We need to be aware of what are the file and folder permissions to know what is happening and how to access it or why it is not accesible and who can access it.

    Yes linux and access control method of users and groups which can control access to a group of files/folders depending on the permission to a user or group. We can have more/less permission even without the group/user having enough permission over a file/folder/. This can be done by anyone who has higher privelages (root).

    These can be done by commands like

    • chown (Change Owner)
      • chown <owner name> <file|folder>
      • chown -R immanuel /
    sudo /etc/shadow # Will show the list of all owners
    • chmod (Change Mode)
      • chmod <permission> <file|folder>
      • chmod 777 /
    WhoPermission
    1st Digit: Owner Permission4 Read
    2nd Digit: Group Permission2 Write
    3rd Digit: Other Permission1 Execute
    • chgrp (Change Group)
      • chgrp <group> <file|folder>
    cat /etc/group # Shows all the groups

    Tab (Key/Space)

    The Tab key is one of the cool keys in keyboard for linux. It helps us in autofill and autcomplete.

    Say if you are going to a reposity that has averylongname then you dont have to type it completely. You just type a few characters like avery and then press tab and it will autocomplete it.

    If there are more than one of the same patterend names then press the tab key twice to show all the files/folders with the same names then you can choose which one to use.

    Tiled (~)

    This is used to go to home instantly or to create somethin in home directory.

    • cd ~ (Normally just cd will do the same)
    • cd ~testfolder/testfile

    Pipes (|,>,<,>>,&)

    Pipes are used in terminal to process or send input/output/error to a files or to the next command.

    command < fileSend file as a Input to the command.
    command > fileRedirect STDOUT of command to file.
    command >> fileAppend STDOUT of command to file.
    command 2> fileRedirect STDERR of command to file.
    command 2>> fileAppend STDERR of command to file.
    command1 | command2Redirecting Output to Program

    Text Processin in Terminal

    Here’s a description of the text processing in terminal

    • Cut
    • Wc
    • Head
    • Cat
    • Tail

    Cut:

    • Purpose: Extracts specific sections from each line of a file or input.
    • Syntax: cut [options] [file]
    • Common options:
      • -f fields: Selects specific fields (columns) based on delimiters.
      • -d delimiter: Specifies the delimiter to use (default is tab).
      • -c characters: Selects specific characters from each line.
    • Example: cut -f 1,3 -d ":" /etc/passwd
      • # Extract first and third fields (username and UID)

    WC:

    • Purpose: Counts the number of lines, words, and characters in a file or input.
    • Syntax: wc [options] [file]
    • Common options:
      • -l: Counts lines.
      • -w: Counts words.
      • -c: Counts characters.
    • Example: wc -lw myfile.txt
      • # Count lines and words in myfile.txt

    Head:

    • Purpose: Displays the first few lines of a file.
    • Syntax: head [options] [file]
    • Common options:
      • -n number: Specifies the number of lines to display (default is 10).
    • Example:head -n 5 myfile.txt
      • # Show the first 5 lines of myfile.txt

    Cat:

    • Purpose: Concatenates files and prints their contents to the standard output.
    • Syntax: cat [options] [file1] [file2]...
    • Common options:
      • -n: Numbers all lines.
      • -e: Displays non-printing characters.
    • Example:cat -n file1.txt file2.txt
      • # Display contents of both files with line numbers

    Tail:

    • Purpose: Displays the last few lines of a file.
    • Syntax: tail [options] [file]
    • Common options:
      • -n number: Specifies the number of lines to display (default is 10).
      • -f: Follows the file, displaying new lines as they are added.
    • Example:tail -f mylog.txt
      • # Monitor the log file for new entries

    Diff:

    • Purpose: Compares two files and displays their differences. Syntax: diff [options] file1 file2
    • Common options:
      • -u: Produces a unified diff, showing differences in a more readable format.
      • -c: Produces a context diff, showing differences along with surrounding lines.
      • -y: Produces a side-by-side diff, showing files in two columns. 
    • Example: diff -u old_file.txt new_file.txt
      • # Shows differences between the files in a unified format

    Grep:

    • Purpose: Searches for lines matching a pattern in a file or input. Syntax: grep [options] pattern [file]
    • Common options:
      • -i: Ignores case distinction.
      • -v: Inverts the match, printing lines that don’t match the pattern.
      • -r: Recursively searches for patterns in all files within a directory.
      • -n: Prints line numbers of matching lines.
    • Example: grep -i “error” log.txt
      • # Finds lines containing “error” (case-insensitive)

    Sed:

    • Purpose: Stream editor for modifying text files. Syntax: sed [options] 'command' file
    • Common commands:
      • s/pattern/replacement/: Substitutes pattern with replacement.
      • d: Deletes lines matching a pattern.
      • p: Prints lines matching a pattern.
      • i: Inserts text before a line.
      • a: Appends text after a line.
    • Example: sed ‘s/localhost/myserver.com/g’ config.txt
      • # Replaces “localhost” with “myserver.com” globally

    Network Interface Configuration

    Purpose: Manages network interfaces on a Linux system.

    Tools:

    • ifconfig: Displays information about network interfaces and enables/disables them.
    • system-config-network: Graphical tool for configuring network interfaces (may not be installed by default).
    • Network Configuration Files: Store settings in /etc/sysconfig/network-scripts/ directory.

    Key Concepts:

    Network Interface Files:

    • Located in /etc/sysconfig/network-scripts/ifcfg-ethX (replace ethX with the interface name).
    • Contain settings in the format VARIABLE=VALUE.
    • Common settings:
      • DEVICE: Interface name.
      • HWADDR: MAC address (optional).
      • BOOTPROTO: DHCP or static IP configuration.
      • IPADDR: IP address (for static configuration).
      • NETMASK: Network mask (for static configuration).
      • GATEWAY: Default gateway (for static configuration).
      • ONBOOT: Whether to bring up the interface at boot.
      • USERCTL: Whether to allow non-root users to control the interface.
      • TYPE: Interface type (e.g., Ethernet).

    Global Network Settings:

    • Located in /etc/sysconfig/network.
    • Common settings:
      • NETWORKING: Enables/disables networking.
      • HOSTNAME: System hostname.
      • GATEWAY: Default gateway (can be overridden in interface files).

    Enabling/Disabling Interfaces:

    • ifup ethX: Brings up interface ethX.
    • ifdown ethX: Brings down interface ethX.

    DNS Configuration:

    • Domain Name Service (DNS) translates hostnames to IP addresses.
    • DNS server addresses specified in /etc/resolv.conf or by DHCP.
    • Common settings:
      • search: Domain names for incomplete hostnames.
      • nameserver: IP addresses of DNS servers.

    Local DNS Server Configuration:

    • Uses /etc/resolv.conf.
    • Order of nameserver entries is important (fastest and available servers first).

    Process Management

    Purpose: Manages processes running on a Linux system.

    Key Concepts:

    Processes:

    • Sets of instructions loaded into memory.
    • Identified by unique Process IDs (PIDs).
    • Have UIDs, GIDs, and SELinux contexts for filesystem access.
    • Tracked in the /proc filesystem.

    Viewing Processes:

    • ps: Lists processes, with options for:
      • All terminals (a)
      • Non-terminal processes (x)
      • User information (u)
      • Parentage (f)
      • Custom output (o)
    • pgrep: Finds processes by predefined patterns.
    • pidof: Finds processes by exact program names.

    Process States:

    • Running: Actively using the CPU.
    • Sleeping: In memory but inactive.
    • Uninterruptable Sleep: Waiting for a resource, cannot be woken by signals.
    • Zombie: Terminated but not fully flushed from process list.

    Signals:

    • Simple messages sent to processes using commands like kill.
    • Processes respond to signals they’re programmed to recognize.
    • Common signals:
      • HUP (1): Reread configuration files.
      • KILL (9): Terminate immediately.
      • TERM (15): Terminate cleanly.
      • CONT (18): Continue if stopped.
      • STOP (19): Stop process.

    Sending Signals:

    • kill: By PID.
    • pkill: By pattern.
    • killall: By name.

    Scheduling Priority:

    • Determines how processes share the CPU.
    • Affected by “nice” value (-20 to 19, default 0).
    • Lower nice value = higher priority.

    Altering Priority:

    • nice: When starting a process.
    • renice: After process has started (root only can decrease).

    Process Management Tools:

    • tophtop: CLI tools for real-time process monitoring and management.
    • gnome-system-monitor: GUI tool for process management.

    Alias

    Purpose: Creates shortcuts for frequently used commands or combinations of commands.

    Syntax:

    • alias [new_name]="[original_command]"

    Examples:

    • alias ll="ls -l"
    • alias rm="rm -i" (prompts for confirmation before deletion)
    • alias grep="grep --color=auto" (adds color highlighting to grep output)
    • alias myip="curl ifconfig.me"
    • alias hist="history | grep"

    Key Points:

    • Aliases are temporary by default, lasting only for the current shell session.
    • To make aliases permanent, add them to your shell configuration file (~/.bashrc for Bash).
    • Aliases can be nested (aliases within aliases).
    • Use alias by itself to list all defined aliases.
    • Use unalias [alias_name] to remove an alias.

    Common Use Cases:

    • Shortening long commands.
    • Adding default options to commands.
    • Creating custom commands for specific tasks.
    • Correcting common typos.
    • Personalizing your shell environment.

    Find and Locate

    Purpose: Find files and directories on a Linux system.

    Key Differences:

    Featurefindlocate
    Search methodSearches the filesystem in real timeUses a pre-built database for faster searches
    AccuracyAlways up-to-dateMight miss recently added files if database is not updated
    SpeedSlower for large searchesFaster for most searches
    FlexibilityMore options for fine-grained controlLimited options

    Find Command:

    Syntax:

    • find [path] [expression]

    Common Expressions:

    • -name: Find by filename.
    • -type: Find by file type (e.g., f for files, d for directories).
    • -size: Find by file size (e.g., +10M for files larger than 10MB).
    • -mtime: Find by modification time (e.g., -7 for files modified within the last 7 days).
    • -exec: Execute a command on each found file.

    Examples:

    • find /home -name "*.txt": Find all text files in /home.
    • find . -type f -size +10M: Find files larger than 10MB in the current directory.
    • find /var/log -mtime +30 -exec rm {} \;: Delete log files older than 30 days.

    Locate Command:

    Syntax:

    • locate [pattern]

    Key Points:

    • Relies on a database updated by updatedb (usually run daily by cron).
    • Use updatedb manually to update the database before using locate.
    • Faster for general searches but might miss recently added files.

    Examples:

    • locate "*.jpg": Find all JPEG files.
    • locate "report.pdf": Find a file named “report.pdf”.

    Best Practices:

    • Use find for real-time, accurate searches with flexible options.
    • Use locate for quick, general searches when database is up-to-date.
    • Consider using updatedb before locate to ensure best results.

    System Logs

    Purpose: Centralized storage and management of messages, errors, and debugging information from applications on Red Hat Enterprise Linux systems.

    Common Log Files:

    • /var/log/dmesg: Kernel messages from the boot process.
    • /var/log/messages: Standard system log containing messages from system software, non-kernel boot issues, and dmesg output. (Readable by root only.)
    • /var/log/secure: Security-related messages and errors (logins, TCP wrappers, xinetd). (Readable by root only.)
    • /var/log/audit/audit.log: Audited messages from the kernel, including SELinux messages. (Use ausearch and aureport to view.)

    Monitoring System Logs:

    • Use text editors or tools like less or tail to view log files.
    • Employ tools like grep to filter specific content.

    Generating Log Messages:

    • Use logger(1) to manually generate log messages.

    Audit Log Tools:

    • ausearch: Search for specific events in the audit log.
    • aureport: Generate reports based on audit log data.

    Example:

    • Generate a log message: logger This is a test message.
    • View the message in /var/log/messagestail -n1 /var/log/messages
  • OpenResty SSL Setup: Install and Secure Site withNginx with Let’s Encrypt on Ubuntu

    OpenResty SSL Setup: Install and Secure Site withNginx with Let’s Encrypt on Ubuntu

    Securing your website with SSL is crucial for both security and SEO benefits. In this guide, we’ll walk through the complete process of OpenResty SSL setup, including how to install OpenResty on Ubuntu, configure SSL using Certbot, and enable auto-renewal.


    Prerequisites for OpenResty SSL Setup

    Before we begin, ensure you have the following:

    • A Linux server (Ubuntu preferred)
    • Root or sudo access
    • A registered domain name pointing to your server

    Step 1: Install OpenResty on Ubuntu

    OpenResty is an extended version of Nginx that includes powerful scripting capabilities. Follow the official OpenResty installation guide to install it on your Ubuntu server.

    Step 2: Install Certbot for OpenResty Nginx SSL

    Certbot is an automated tool for obtaining SSL certificates from Let’s Encrypt.

    To install Certbot, run:

    sudo apt update
    sudo apt install certbot -y

    Step 3: Obtain an SSL Certificate for OpenResty HTTPS Configuration

    Run the following command to generate an SSL certificate for your domain:

    sudo certbot certonly --standalone --preferred-challenges http -d example.com

    Replace example.com with your actual domain name.

    Once completed, your SSL certificates will be located in:

    /etc/letsencrypt/live/example.com/

    Step 4: Configure Nginx OpenResty SSL Settings

    Now, update your Nginx OpenResty configuration to use the SSL certificate.

    Open your configuration file:

    sudo nano /usr/local/openresty/nginx/conf/nginx.conf

    Nginx OpenResty HTTPS Configuration

    Add the following server block inside the http block:

    server {
        listen 443 ssl;
        server_name example.com;
    
        ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    
        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_ciphers HIGH:!aNULL:!MD5;
    
        location / {
            root /var/www/html;
            index index.html;
        }
    }

    Save and exit (Ctrl + X, then Y, then Enter).

    Step 5: Restart OpenResty Nginx for SSL to Take Effect

    Restart Nginx OpenResty for the changes to take effect:

    sudo systemctl restart openresty

    If Nginx OpenResty is not set up as a service, you may need to start it manually:

    sudo /usr/local/openresty/nginx/sbin/nginx

    Step 6: Auto-Renew OpenResty SSL Certificate with Certbot

    Let’s Encrypt certificates expire every 90 days, so setting up auto-renewal is important.

    Add the following cron job to renew the certificate automatically:

    sudo crontab -e

    Add this line at the end:

    0 0 * * * certbot renew --quiet && systemctl reload openresty

    This will check and renew the certificate daily at midnight.

    Conclusion

    Your Nginx OpenResty server is now secured with SSL! You’ve successfully completed the OpenResty SSL setup, installed Nginx OpenResty, configured SSL with Certbot, and set up auto-renewal for your certificates. Now, your website can securely serve content over HTTPS.

    For further reading, check out:

    If you have any questions or face issues, feel free to drop a comment below!

  • Step-by-Step Guide to Configuring Nginx and PHP-FPM on Ubuntu

    Step-by-Step Guide to Configuring Nginx and PHP-FPM on Ubuntu

    In this blog we will see how to properly configure Nginx and php-fpm in a linux (ubuntu) machine or server.


    Pre-Requisites:

    Linux (Ubuntu) Server.
    
    Php.
    
    Nginx.

    Considering that the linux server is already setup and running with ubuntu, lets get started with the Nginx and php fpm setup.


    Installing Nginx.

    You can follow THIS link and install Nginx

    Installing PHP

    You can follow THIS link and install PHP.


    Basic Nginx (V 1.24) Setup for PHP-FPM (8.4)

    server {
      ...
    # Add index.php nginx config
    index ... index.php ...;

    # Pass PHP scripts on Nginx to FastCGI (PHP-FPM) server
    location ~ \.php$ {
    include fastcgi_params;
    # Nginx php-fpm sock config:
    fastcgi_pass unix:/run/php/php8.1-fpm.sock;
    fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    # deny access to Apache .htaccess on Nginx with PHP,
    # if Apache and Nginx document roots concur
    location ~ /\.ht {
    deny all;
    }
    ...
    } # End of PHP FPM Nginx config example

    This is just a example config snippet and not the whole/actual configuration.

    Depending on your system’s default configuration you may need to change fastcgi_pass parameter.

    It can be of the following variation

    fastcgi_pass 127.0.0.1:9000; # For locally passing the php files
    
    fastcgi_pass unix:/run/php/php8.1-fpm.sock; # For using unix socket to pass the file

    unix socket location may vary per system (can be /run/php/php8.1-fpm.sock /var/run/php/php8.1-fpm.sock). This doesnt make a difference if the locations are symlinked or mounted. If incase it is not done then this needed to be noted carefully.

    Another way is to change the phpfpm pool.d/www.conf file to use local host instead of unix socket.

    Finally restart the php and nginx services.

    Here are some articles and blogs and links that will help you to learn and know more about these.

    https://nginx.org/en/docs/beginners_guide.html
    
    https://nginx.org/en/docs/switches.html
    
    https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
    
    https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/
    
    https://easyengine.io/wordpress-nginx/why-nginx/
    
    https://serverguy.com/comparison/apache-vs-nginx/
    
    http://nginx.org/en/docs/http/ngx_http_core_module.html
    
    https://www.journaldev.com/26342/nginx-location-directive
    
    https://nginx.org/en/docs/beginners_guide.html
    
    https://nginx.org/en/docs/switches.html
    
    https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
    
    https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/
    
    https://easyengine.io/wordpress-nginx/why-nginx/
    
    https://serverguy.com/comparison/apache-vs-nginx/
    
    http://nginx.org/en/docs/http/ngx_http_core_module.html
    
    https://www.journaldev.com/26342/nginx-location-directive
  • Oh-My-ZSH

    Oh-My-ZSH

    Oh My Zsh is a delightful, open source, community-driven framework for managing your Zsh configuration. It comes bundled with thousands of helpful functions, helpers, plugins, themes, and a few things that make you shout….

    Installing OH My ZSH

    Oh My ZSH is installed by running one of the following commands in your terminal. You can install this via the command-line with either curl or wget.

    Curl

    sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

    Wget

    sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

    If you are on a fresh installation of mac, then it will install some terminal tools. If your in other OS it may need some other dependency as well

    Oh My ZSH Themes

    OMZ [Oh-My-ZSH] supports many themes and plugins. These can be installed, set and used by the following commands.

    omz theme set|use <theme name>

    Example

    - omz theme set gnzh
    - omz theme use gnzh

    Alias

    OMZ allow setting of alliases in the zsh config file [.zshrc] itself. You can open the .zshrc file which is in the home folder and then go to the alias part and then add a alias you want. If the alias part does not exist then you can simply add it in the end of the file.

    # Custom made Alias.
    alias curlx="curl -XGET -IL"

    and then save it. You may need to restart your shell [sometimes logout and login or restart the system]

    Oh My ZSH Plugins

    Now we can move to installing plugins, another interesting thing by omz.

    To do so

    omz plugin load <plugin name>

    and then

    omz enable <plugin name>

    will do the job.

    Example

    - omz plugin load tmux
    - omz plugin enable tmux

    You need to have tmux installed for this to work.

    Customizing Tmux

    Tmux allow multiple customization. We shall customise the default key binding of the tmux from Ctrl + B to Ctrl + r

    To do it.

    - nano ~/.tmux.conf
    
    # Change the prefix key to C-a
    - set -g prefix C-a
    - unbind C-b
    - bind C-a send-prefix

    Save and relaunch terminal and tmux