DefaultValue / ubuntu_post_install_scripts

From clean Ubuntu to deployed Magento 2 in 5 commands. This is a part of the local infrastructure project which aims to create easy to install and use environment for PHP development based on Ubuntu LTS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Docker-based PHP development infrastructure

Install all PHP development software with a single script.

This script also installs the Dockerizer tool that is designed to:

  • Install any Magento 2 version in 1 command.
  • Add Docker files to your existing projects in one command.

It is possible to rerun this script to update software and install new packages. It will not break anything. A backup of your ~/.bash_aliases file will be created during the update.

Full YouTube presentation

Running the script

Automated environment installation script for Ubuntu 20.04-22.10 x64 or Ubuntu-based distributions:

sh ubuntu_20.04-22.04_x64.sh

Important! Do not run it with sudo or when you switch to the root user. Never. Otherwise, a lot of things may have insufficient permissions.

Ubuntu Upgrade

Scripts can be rerun after upgrading your Ubuntu installation to the newer version (for example, from 21.10 to 22.04).

Web server application stack

Everything is Docker-based. See Dockerizer and Full YouTube presentation

Installed software list

  • curl: A Tool to transfer data to or from a server
  • Diodon: clipboard manager
  • Docker + docker-compose: Spin up development environments
  • htop: Process manager
  • git & git-gui: Version control system
  • Google Chrome: Browser
  • guake: Pulldown terminal
  • mc (Midnight Commander): Console file manager
  • mkcert: Generating trusted SSL certificates for local development
  • nodejs, php: Needs no introduction
  • PHPStorm: IDE
  • Shutter: Making and editing screenshots
  • Sublime Text: Text editor
  • Slack: Messenger
  • Tweaks: Ubuntu fine-tuning
  • vim: CLI text editor which you can't exit from
  • VirtualBox: Virtualization tool for setting up Windows and other OS

PHP modules that are installed:

  • bz2
  • cli
  • common
  • curl
  • intl
  • mbstring
  • mysql
  • opcache
  • readline
  • ssh2
  • xml
  • xdebug
  • zip

PHP Tools:

xDebug is configured automatically and does not require additional adjustments if you use PHPStorm. php.ini settings are updated for development environment.

You may also want to download the free Microsoft IE/Edge virtual machines for VirtualBox

Bash aliases

There are a lot of useful aliases added to the ~/.bash_aliases file.

Docker-related aliases:

  • COMPOSITIONS: Show a list of Docker containers and their composition locations

Aliases for docker-compose (mostly expect to have docker-compose.yaml and docker-compose-dev-tools.yaml files in the current directory):

  • UP: Starts compositions generated by Dockerizer in the development mode
  • DOWN: Stops compositions generated by Dockerizer without removing volumes
  • DOWNV: Stops compositions generated by Dockerizer and removes volumes
  • PS: Shows the status of all containers in the current directory
  • RESTART: Restarts compositions generated by Dockerizer
  • START: Starts compositions generated by Dockerizer
  • STOP: Stops compositions generated by Dockerizer

Dockerizer V3 aliases:

  • DOCKERIZER: Path to Dockerizer to make other aliases shorter
  • BUILD: Run Dockerizer command composition:build-from-template from any directory
  • SETUP: Run Dockerizer command magento:setup from any directory
  • REINSTALL: Run Dockerizer command magento:reinstall from any directory
  • CONNECT: Run Dockerizer command docker:mysql:connect. Use it from the directory with docker-compose files containing mysql service
  • IMPORTDB: Run Dockerizer command docker:mysql:import-db. Use it from the directory with docker-compose files containing mysql service
  • EXPORTDB: Run Dockerizer command docker:mysql:export-db. Use it from the directory with docker-compose files containing mysql service

See Dockerizer Wiki for more information about its commands and capabilities.

Enter Docker containers:

  • PHP: Enter the php container. Use it from the directory with docker-compose files containing php service
  • PHPROOT: Enter the php container with root privileges. Use it from the directory with docker-compose files containing php service

PHP container aliases:

  • CI: Run composer install in the php container. Use it from the directory with docker-compose files containing php service

Magento 2 aliases. Run them in the directory containing the docker-compose.yaml file containing php service:

  • MAGENTO: Alias for php bin/magento command. Can be used to call Magento commands or as a part of other aliases
  • CC: Run php bin/magento cache:clean;
  • CF: Run php bin/magento cache:flush;
  • IR: Run php bin/magento indexer:reindex;
  • SU: Run php bin/magento setup:upgrade;
  • SDC: Run php bin/magento setup:di:compile;
  • URN: Run php bin/magento dev:urn-catalog:generate and replace /var/www/html with $PROJECT_DIR$ (internal PHPStorm variable).
  • MODEDEV: Set Magento 2 mode to developer
  • MODEDEF: Set Magento 2 mode to default
  • MODEPROD: Set Magento 2 mode to production

Other aliases:

In case HTTPS is still insecure

If the certificates generated by the mkcert are insecure then run the following and restart the browser:

mkcert -install

This may happen because browsers are not started during the software installation and local CA is not yet trusted by the browser.

Tips for developers

  1. Create bookmark for at least ~/misc folder in Nautilus (file manager) - just move the folder to the left sidebar of Nautilus to add it to bookmarks.

  2. Use Ubuntu Startup Applications to automate launching apps on system startup.

  3. Use Guake pulldown terminal as an alternative to the Terminal application. Set it to, for example, F1 key. Set switching tabs to ALT+1, ALT+2 and so on because this is a default shortcut for many other apps. Use its Start Guake at login configuration to add it to the Startup applications - otherwise Guake will delete itself from the list. For Ubuntu on Wayland you must set a custom shortcut for guake-toggle command instead of using Guake preferences.

Adding custom shortcuts

Shortcut for 'guake-toggle'

  1. Enable workspaces in Ubuntu and learn how to use them (if not yet) and how to move windows between workspaces. You may like using static number of workspaces instead of dynamically adding/removing them.

If you prefer to loop through the current workspace apps only rather than all apps on all workspaces:

gsettings set org.gnome.shell.app-switcher current-workspace-only true
  1. Use Tweaks to fine-tune your system.

  2. It is possible to customize terminal output to show current time and Git branch when you-re inside the repository. Use $PS1 like this in your ~/.bash_aliases:

# Let's make the prompt more colorful and show Git branch if available
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;35m\][\d \t] \[\033[01;33m\]\w\[\033[01;31m\]\[\033[01;34m\]$(__git_ps1)\[\033[01;31m\] > \[\033[01;32m\]'

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\w\a\]$PS1"
    ;;
*)
    ;;
esac

Or take this one as an example and modify it for your needs. Be sure to backup the file before that.

Author and maintainer

Maksym Zaporozhets

About

From clean Ubuntu to deployed Magento 2 in 5 commands. This is a part of the local infrastructure project which aims to create easy to install and use environment for PHP development based on Ubuntu LTS.


Languages

Language:Shell 100.0%