Setup developers Ubuntu computer - atabegruslan/Notes GitHub Wiki

Setup LAMP and other essentials

https://github.com/atabegruslan/Notes/wiki/LAMP

Other ways/tutorials for installing LAMP

Then don't forget to append Include /etc/phpmyadmin/apache.conf to /etc/apache2/apache2.conf

Start and stop apache and mysql

sudo service apache2 stop
sudo service mysql stop
sudo service apache2 start
sudo service mysql start

For the easy of localhost development

  1. User and web server run with the same permissions

https://askubuntu.com/questions/733193/give-web-sever-directory-fullpermission

## sudo chown -R [USER NAME]:[USER NAME] /var/www  
sudo chown -R ruslan:ruslan /var/www/html  

sudo gedit /etc/apache2/envvars  
# Edit the following:
# ---
# export APACHE_RUN_USER=ruslan  
# export APACHE_RUN_GROUP=ruslan  
# ---
# Save and close

sudo service apache2 restart

The other looser restrictions that we can afford to set on our localhost

Increase the max size of the .sql import files, to avoid

MySQL database import fails: ERROR 1118 (42000): Row size too large

Add to /etc/mysql/my.cnf:

[mysqld] 
max_allowed_packet = 2G 
innodb_log_file_size = 2G 
innodb_log_buffer_size = 2G 
internal_tmp_disk_storage_engine=MyISAM 
innodb_strict_mode = 0 
innodb_file_per_table=1 
innodb_file_format = Barracuda 

Or cp etc/mysql/mysql.cnf /home/ruslan/mysql.cnf and add the same lines above.

https://support.plesk.com/hc/en-us/articles/115000256794-MySQL-database-import-fails-ERROR-1118-42000-Row-size-too-large

Increase upload size

  1. Use php -i | grep php.ini to find out the correct php.ini
  1. Edit php.ini: sudo gedit php.ini
upload_max_filesize=2G
post_max_size=2G
  1. sudo service apache2 restart

Increase the length of the dump-able string, to var_dump the entire long string

Method 1

On top of each PHP file, after the Namespace declaraction, outside the Class

ini_set("xdebug.var_display_max_children", -1); 
ini_set("xdebug.var_display_max_data", -1); 
ini_set("xdebug.var_display_max_depth", -1); 

Method 2

Add xdebug.var_display_max_depth=-1 to php.ini

In detail:

; with sane limits
xdebug.var_display_max_depth = 10
xdebug.var_display_max_children = 256
xdebug.var_display_max_data = 1024 

; with no limits
; (maximum nesting is 1023)
xdebug.var_display_max_depth = -1 
xdebug.var_display_max_children = -1
xdebug.var_display_max_data = -1 

Of course, these may also be set at runtime via ini_set().

Useful if you don't want to modify php.ini and restart your web server.

But need to quickly inspect something more deeply.

ini_set('xdebug.var_display_max_depth', '10');
ini_set('xdebug.var_display_max_children', '256');
ini_set('xdebug.var_display_max_data', '1024');

Turn off MySQL strict mode

Method 1:

Check current sql_modes by: show variables like 'sql_mode';

Remove the sql_mode "NO_ZERO_IN_DATE,NO_ZERO_DATE

https://stackoverflow.com/questions/36882149/error-1067-42000-invalid-default-value-for-created-at

Method 2:

sudo gedit /etc/mysql/conf.d/disable_strict_mode.cnf

Append these:

[mysqld]
sql_mode=IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Save and restart with: sudo service mysql restart

https://serverpilot.io/docs/how-to-disable-strict-mode-in-mysql-5-7/

By disabling strict mode problems like ERROR 1067 Invalid default value for 'another_col' and ERROR 1118 (42000): Row size too large can be avoided.

Install other commonly used programs

FileZilla

https://www.atechtown.com/install-filezilla-on-ubuntu/

sudo add-apt-repository ppa:adabbas/1stppa 
sudo apt-get update  
sudo apt-get install filezilla

MySQL WorkBench

Navicat

or

Download: https://downloadly.ir/software/programming/navicat-premium/

Run: cd navicat121_premium_en_x64 && sh start_navicat

Renew: cd ~ && rm -rf .navicat64

DBeaver

POEdit

Video Screen Recorder (#2 Simple Screen Recorder is good)

https://www.ubuntupit.com/15-best-linux-screen-recorder-and-how-to-install-those-on-ubuntu/

VLC Player

https://www.linuxhelp.com/how-to-install-vlc-media-player-on-ubuntu-17-04

Screenshooter

sudo apt-get install gnome-screenshot

Meld

Sublime Text

https://linuxize.com/post/how-to-install-sublime-text-3-on-ubuntu-18-04/

Chrome

https://linuxize.com/post/how-to-install-google-chrome-web-browser-on-ubuntu-18-04/

JDK

https://stackoverflow.com/questions/14788345/how-to-install-the-jdk-on-ubuntu-linux

Git

https://www.liquidweb.com/kb/install-git-ubuntu-16-04-lts/

Github 2FA

Gitlab 2FA

Gitlab Personal Access Token

https://gitlab.{company}.dk/profile/personal_access_tokens

composer config http-basic.gitlab.{company}.dk <username> <personal access token>
composer install

Slack

2FA

https://get.slack.help/hc/en-us/articles/204509068-Set-up-two-factor-authentication

PHPStorm

Install

Open 'Ubuntu Software' and install from there (old way)

Or via terminal: https://www.linuxbabe.com/desktop-linux/install-phpstorm-ubuntu-15-10

License

A JetBrains PhpStorm license has been assigned to your JetBrains Account.
Please use your JetBrains Account credentials in the product to activate your license.
https://www.jetbrains.com/phpstorm/buy/#edition=commercial

A license file will be received.
When PHPStorm start for first time, register with code then drag this file in.

To short-circuit the trial limit

  • Delete the Home directory > .config > JetBrains > PphStormXXXX.X > eval folder
  • In file: Home directory > .config > JetBrains > PphStormXXXX.X > options > other.xml , remove <property name="evl.blahblah"/>
  • Delete the Home directory > .java > .userPrefs > jetbrains > phpstorm

Example

rm -rf ~/.config/JetBrains/PhpStorm2020.2/eval
sudo sed -i -E 's/<property name=\"evl.*\".*\/>//' ~/.config/JetBrains/PhpStorm2020.2/options/other.xml
rm -rf ~/.java/.userPrefs/jetbrains/phpstorm

Compress Zip

Virtual Hosts

  1. /etc/apache2/sites-available/000-default.conf (XAMPP's is here: xampp\apache\conf\extra\httpd-vhosts.conf)
<VirtualHost 127.0.0.3:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/website
    ServerName www.website.local
    ServerAlias website.local
</VirtualHost>
  1. /etc/hosts (XAMPP's is here: C:\Windows\System32\drivers\etc\hosts)
127.0.0.3    website.local
  1. sudo service apache2 restart

Linux's 'Env Vars'

  • .bash_profile and .profile - Once
  • .bashrc - Everytime

https://unix.stackexchange.com/questions/129143/what-is-the-purpose-of-bashrc-and-how-does-it-work

Example - Commonly used functions:

sudo gedit ~/.profile

refresh-phpstorm-lisense() {
  rm -rf ~/.config/JetBrains/PhpStorm2020.2/eval
  sudo sed -i -E 's/<property name=\"evl.*\".*\/>//' ~/.config/JetBrains/PhpStorm2020.2/options/other.xml
  rm -rf ~/.java/.userPrefs/jetbrains/phpstorm
}

add-permission() {
  sudo chmod 777 -R $1
}

alias edit-hosts="sudo gedit /etc/hosts";

source ~/.profile

Example - PATH:

You would want to add eg: export PATH="$PATH:/some/addition" into .bash_profile instead of .bashrc.

https://hackprogramming.com/2-ways-to-permanently-set-path-variable-in-ubuntu

export PATH=$PATH:/some/addition/bin
source ~/.profile

See also Mac's: https://github.com/atabegruslan/Notes/wiki/Setup-developers-Mac-computer#path

Ubuntu's 'control panel'

sudo apt install gnome-control-center

Install non-linux-native software eg MS Edge

Use WINE or PlayOnLinux, then install MS Edge on it.

Wine is a free and open-source compatibility layer that aims to allow application software and computer games developed for Microsoft Windows to run on Unix-like operating systems. Wine also provides a software library, known as "Winelib", against which developers can compile Windows applications to help port them to Unix-like systems.

Wine provides its compatibility layer for Windows runtime system (also called runtime environment) which translates Windows system calls into POSIX-compliant system calls, recreating the directory structure of Windows, and providing alternative implementations of Windows system libraries, system services through wineserver and various other components (such as Internet Explorer, the Windows Registry Editor, and msiexec). Wine is predominantly written using black-box testing reverse-engineering, to avoid copyright issues.

https://en.wikipedia.org/wiki/Wine_(software)

PlayOnLinux is a graphical frontend for the Wine software compatibility layer which allows Linux users to install Windows-based video games, Microsoft Office (2000 to 2010), Microsoft Internet Explorer, as well as many other applications such as Apple iTunes and Safari.

While initially developed for Linux-based systems, it is also used on macOS and FreeBSD under the names PlayOnMac and PlayOnBSD, respectively. It can also be used on other operating systems supported by Wine.

https://en.wikipedia.org/wiki/PlayOnLinux

Install, uninstall and manage versions of very common tools

Ubuntu

Version

https://linuxize.com/post/how-to-check-your-ubuntu-version/

PHP

Version

Composer

Install

https://github.com/atabegruslan/Notes/wiki/Install,-Uninstall,-Change-versions-of-various-programs#composer

Uninstall

During the installation you got a message Composer successfully installed to: ... this indicates where Composer was installed.

But you might also search for the file composer.phar on your system.

Then simply:

Delete the file composer.phar

Delete the Cache Folder:

  • Linux: /home//.composer
  • Windows: C:\Users<username>\AppData\Roaming\Composer

https://stackoverflow.com/questions/30396451/remove-composer

Version

https://stackoverflow.com/questions/64597051/how-to-downgrade-or-install-a-specific-version-of-composer

Node

Install

https://github.com/atabegruslan/Notes/wiki/Install,-Uninstall,-Change-versions-of-various-programs#node

Uninstall

https://github.com/atabegruslan/Notes/wiki/Install,-Uninstall,-Change-versions-of-various-programs#uninstall-node

Version

https://github.com/atabegruslan/Notes/wiki/Install,-Uninstall,-Change-versions-of-various-programs#change-node-versions

NPM

Install

https://docs.npmjs.com/try-the-latest-stable-version-of-npm

Docker

Install

https://github.com/Ruslan-Aliyev/Docker#install

Uninstall

Mac: https://nektony.com/how-to/uninstall-docker-on-mac

Android Studio

Uninstall

https://github.com/atabegruslan/Notes/blob/main/notes/android/complete_uninstall.pdf

Python

Uninstall

WP

Install

https://code.tutsplus.com/articles/download-and-install-wordpress-via-the-shell-over-ssh--wp-24403

Version

Laravel

Version

http://www.elcoderino.com/check-laravel-version/

Notes

See hidden files

Ubuntu: Control + H Mac: Command + Shift + .

Apache and PHP log files

Composer Memory Limit

Set in php.ini

php -i | grep php.ini # Find correct php.ini
gedit /…/bin/php/php7.4.12/conf/php.ini # Or in Mac: open -e /…/bin/php/php7.4.12/conf/php.ini

Set: memory_limit = -1

Or in terminal everytime: php -d memory_limit=-1 /usr/local/bin/composer ...

XAMPP on Linux

Get your public ssh key

cat ~/.ssh/id_rsa.pub

⚠️ **GitHub.com Fallback** ⚠️