Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Find bookmark question in stackoverflow and askubuntu FIRST (Private).
- *TIPS:*
- - to upgrade only a package:
- ```
- sudo apt-get update
- sudo apt-get --only-upgrade install <packagename>
- ```
- - Ubuntu distribution version: `lsb_release -sc`
- # install aptitude for better resolve conflict when install packages
- ```
- sudo apt-get install aptitude
- ```
- # install unity tweak
- `sudo apt-get install unity-tweak-tool`
- # Install Git
- ```
- sudo apt-get install git
- ```
- # Install Vim
- `sudo apt-get install vim`
- # Install zsh and oh-my-zsh:
- `sudo apt-get install zsh`
- Restart terminal, check, set as default:
- ```shell
- zsh --version;
- chsh -s $(which zsh)
- ```
- Set default user (user logged in), turn off update in config:
- `vim ~/.zshrc`
- ## Install Oh-my-zsh:
- `sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"`
- Optional: use agnoster theme: https://github.com/robbyrussell/oh-my-zsh/wiki/themes
- # Install chrome
- ```
- cd /tmp
- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- sudo dpkg -i google-chrome-stable_current_amd64.deb
- sudo apt-get -f install
- ```
- # Install sublime text:
- http://tipsonubuntu.com/2017/05/30/install-sublime-text-3-ubuntu-16-04-official-way/
- ```
- wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
- echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
- # or dev version (paid version)
- echo "deb https://download.sublimetext.com/ apt/dev/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
- sudo apt-get update
- sudo apt-get install sublime-text
- subl --version
- ```
- # Install vscode
- ```
- curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
- sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
- sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
- sudo apt-get update
- sudo apt-get install code # or code-insiders
- code --version
- ```
- Update VS Code:
- https://github.com/moeenz/vscode-updater
- # Install LAMPP (or PHP, MySQL/PosgreSQL, Apache/NginX):
- - Download xampp's setup file and run: `sudo path/to/file/file-name`
- - Remove: `sudo rm -rf /opt/lampp`
- Default mysql user: root, password: NONE
- Or install invidually: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04
- ## Apache:
- ```
- sudo apt-get install apache2
- apache2 -v
- ```
- Disable/enable apache2 from startup:
- ```
- sudo update-rc.d apache2 disable/enable
- ```
- Disable/enable apache2 service
- ```
- sudo systemctl disable/enable apache2
- ```
- Start/stop apache2
- ```
- sudo systemctl start/stop apache2
- ```
- Configuration: allow external access in firewall
- ```
- sudo ufw app list
- sudo ufw allow in 'Apache Full'
- sudo ufw enable
- sudo ufw status
- ```
- Open web browser and test. See public address:
- ```
- hostname -I
- # or
- curl -4 icanhazip.com
- ```
- ## PHP
- ```
- sudo apt-get install software-properties-common
- sudo add-apt-repository ppa:ondrej/php
- sudo apt-get update
- sudo apt-get install php7.2
- # packages
- sudo apt-get install php7.2-curl php7.2-json php7.2-opcache php-common php-tcpdf php7.2-cli php7.2-fpm php7.2-mbstring php7.2-readline php-gd php-pear php-xml php7.2-common php7.2-gd php7.2-mysql php7.2-xml php-gettext php-phpseclib
- ```
- Suggusted:
- 1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman
- 2. If you are using apache2, you are advised to add ppa:ondrej/apache2
- 3. If you are using nginx, you are advise to add ppa:ondrej/nginx-mainline
- or ppa:ondrej/nginx
- ## MariaDB
- ```
- sudo apt-get install software-properties-common
- sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
- sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mirror.delorahosting.com/mariadb/repo/10.2/ubuntu xenial main'
- sudo apt-get update
- sudo apt-get install mariadb-server
- # check
- mysql -V
- sudo systemctl start mariadb/mysql
- # default port is 3306
- # Login with root account (default)
- mysql -u root -p
- ```
- config security: `sudo mysql_secure_installation`
- ## Phpmyadmin:
- ```
- sudo add-apt-repository ppa:nijel/phpmyadmin
- sudo apt-get update
- sudo apt-get install phpmyadmin
- sudo a2enmod php7.2
- ```
- Add `Include /etc/phpmyadmin/apache.conf` to end of apache config file:
- ```
- sudo vim /etc/apache2/apache2.conf
- ```
- Uncomment `$cfg['Servers'][$i]['AllowNoPassword'] = TRUE;` to allow login without password.
- ```
- sudo vim /etc/phpmyadmin/config.inc.php
- ```
- **Note**
- If you had error ` count(): Parameter must be an array or an object that implements Countable` when use phpmyadmin you may download latest version and unzip to `/usr/share/phpmyadmin`
- ## PosgreSQL:
- ```
- sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main"
- wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
- sudo apt-get update
- sudo apt-get install postgresql-10
- # Check
- psql --version
- # default port is 5432
- # Login with postgres account (default)
- psql -U postgres
- ```
- ## NginX:
- ```
- wget http://nginx.org/keys/nginx_signing.key
- sudo apt-key add nginx_signing.key
- sudo apt install nginx
- nginx -v
- ```
- ## Install Composer
- install to `~/Programs/scripts` (or whatever)
- ```
- cd ~/Programs/scripts
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
- php composer-setup.php --filename=composer.phar
- php -r "unlink('composer-setup.php');"
- ```
- and then add alias to ZSH
- ```
- echo alias composer=\"~/Programs/scripts/composer.phar\" >> ~/.zshrc
- ```
- or install to /usr/local/bin/composer
- ```
- curl -sS http://getcomposer.org/installer | php -- --filename=composer
- chmod a+x composer
- sudo mv composer /usr/local/bin/composer
- # Check
- composer -V
- ```
- Install `hirak/prestissimo` to make composer install packages faster.
- `composer global require hirak/prestissimo`
- # Install Docker
- https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04
- ```
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- sudo apt-get update
- apt-cache policy docker-ce
- sudo apt-get install -y docker-ce
- # check
- systemctl status docker
- ```
- # Install Git Kraken:
- ```
- cd ~/Downloads
- wget https://release.gitkraken.com/linux/gitkraken-amd64.tar.gz
- tar -xvzf gitkraken-amd64.tar.gz
- ```
- # Install Nodejs and NPM:
- ```
- curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
- sudo apt-get install nodejs
- ```
- # Install Redis
- https://redis.io/download
- https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-redis-on-ubuntu-16-04
- ```
- wget http://download.redis.io/releases/redis-4.0.8.tar.gz
- tar xzf redis-4.0.8.tar.gz
- cd redis-4.0.8
- make
- # run test
- make tests
- ```
- Then add alias `redis-server` and `redis-cli` to _zsh/bash_
- ```
- alias redis-server="/path_to_redis_folder/src/redis-server"
- # default redis port is 6379
- alias redis-cli="/path_to_redis_folder/src/redis-cli"
- ```
- or use PPA
- ```
- sudo add-apt-repository ppa:chris-lea/redis-server
- sudo apt-get update
- sudo apt-get install redis-server
- redis-server --version
- # test
- systemctl start redis-server
- systemctl status redis-server
- redis-cli
- > set test "HugeServer"
- > get test
- ```
- # Install MongoDB
- https://www.howtoforge.com/tutorial/install-mongodb-on-ubuntu-16.04/
- ```
- sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
- echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
- sudo apt-get update
- sudo apt-get install mongodb-org
- ```
- Default account: *mongodb*
- Command:
- ```
- sudo service mongod start/stop/restart
- # default port is 27017
- ```
- Option: install Robo 3T or MongoDB Compass Management Tool
- ```
- # https://robomongo.org/download
- # or
- wget https://downloads.mongodb.com/compass/mongodb-compass_1.6.0_amd64.deb;
- sudo dpkg -i mongodb-compass_1.6.0_amd64.deb;
- DEBUG=* mongodb-compass;
- ```
- # Install Xdebug
- Follow until reach and done step 7 at https://xdebug.org/wizard.php
- Depend on php version. make a file `/etc/php/7.1/mods-available/xdebug.ini`
- ```
- # find xdebug.so path
- # locate xdebug.so
- zend_extension=/path/to/xdebug.so
- xdebug.remote_autostart = 1
- xdebug.remote_host=localhost
- xdebug.remote_enable = 1
- xdebug.remote_connect_back=1
- xdebug.remote_port = 9000
- xdebug.remote_hander = dpgp
- xdebug.remote_mode = req
- xdebug.scream=0
- xdebug.cli_color=1
- xdebug.show_local_vars=1
- ;values: XDEBUG_ECLIPSE, netbeans-xdebug, macgdbp, PHPSTORM
- xdebug.idekey=PHPSTORM
- ;To remove limits for xdebug_var_dump()
- xdebug.var_display_max_depth = 5
- xdebug.var_display_max_children = 256
- xdebug.var_display_max_data = 2048
- ;xdebug.var_display_max_depth = -1
- ;xdebug.var_display_max_children = -1
- ;xdebug.var_display_max_data = -1
- ```
- Now you can enable/disable xdebug if necessary: `sudo phpenmod/phpdismod xdebug`
- If you are using composer, you probably going to want to disable xdebug for CLI: `sudo phpenmod/phpdismod -s cli xdebug`
- To use with PHPSTORM we need more step, said _laravel-project_:
- - Add a server. Go to Settings/Language & Framework/PHP/Servers
- - Add a server: a name (`laravel`), host (`127.0.0.1`), port (`8000` for laravel, `80` for app run on apache), Debugger Xdebug. Select _Use path mappings_, fill _Absolute path on the server_ same value (`/home/tranghv/laravel-project`, `/var/www/laravel-project` on remote) as path to project on machine at project directory (`/home/tranghv/laravel-project`)
- - In menu Run/Edit configuration, add a PHP Web Page with a name (`laravel xdebug`), choose a server in step 2 (`laravel`), Save.
- - In tools bar, choose `laravel xdebug` and turn on listening (phone shape).
- - Set a breakepoint.
- - Go to browser, turn on debugging status in Xdebug extension
- - Start debug.
- # Use SSH key with git
- https://wiki.paparazziuav.org/wiki/Github_manual_for_Ubuntu
- # Install Php-CS-Fixer to `~/Programs/scripts` directory
- ```
- cd ~/Programs/scripts
- wget http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -O php-cs-fixer.phar
- sudo chmod a+x php-cs-fixer.phar
- ```
- And then set an alias to `~/.bashrc` or `~/.zshrc`
- ```
- cat "alias php-cs-fixer=\"php ~/Programs/scripts/php-cs-fixer.phar\"" >> ~/.zshrc
- ```
- use
- ```
- php php-cs-fixer.phar fix --verbose --show-progress=estimating --rules=@Symfony,@PHP70Migration /path/to/dirOrfile
- ```
- OR use PHP CodeSniffer
- ```
- cd ~/Programs/scripts
- curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
- php phpcs.phar -h
- curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar
- php phpcbf.phar -h
- sudo chmod a+x phpcs.phar
- sudo chmod a+x phpcbf.phar
- ```
- # Create virtual host in apache for laravel
- Assumption:
- - domain name `laravel.loc` (don't use domain name `.dev`, `.app` or `.local`)
- - project name laravel
- 1. Change permission
- ```
- sudo chown -R $USER:$USER /var/www/html/laravel
- sudo chgrp -R www-data /var/www/html/laravel/storage /var/www/html/laravel/bootstrap/cache
- # or
- chmod -R 775 /var/www/html/laravel/storage /var/www/html/laravel/bootstrap/cache
- # or
- sudo chown -R www-data:www-data /var/www/html/laravel/storage /var/www/html/laravel/bootstrap/cache
- ```
- 2. Enable `rewrite` module
- ```
- sudo a2enmod rewrite
- ```
- 3. Add address to `hosts` file
- ```
- sudo vim /etc/hosts
- ```
- add this (don't forget `.` at the end of localhost)
- ```
- 127.0.0.1 localhost.
- ::1 localhost.
- fe80::1%lo0 localhost.
- 127.0.0.1 laravel.loc
- ```
- 4. Add virtual host config
- ```
- sudo vim /etc/apache2/sites-available/laravel.loc.conf
- ```
- add this
- ```
- <VirtualHost *:80>
- ServerName laravel.loc
- ServerAlias www.laravel.loc
- DocumentRoot /var/www/html/laravel/public/
- <Directory /var/www/html/laravel/>
- Options Indexes FollowSymLinks
- AllowOverride All
- Require all granted
- </Directory>
- </VirtualHost>
- ```
- 5. Enable site
- ```
- sudo a2ensite laravel.loc.conf
- ```
- This will create symbolic link from `/etc/apache2/sites-enabled/laravel.loc.conf` to `/etc/apache2/sites-available/laravel.loc.conf`
- 6. Disable defautl config and restart server
- ```
- sudo a2dissite 000-default.conf
- sudo systemctl restart apache2
- ```
- # Magento
- Prerequisite: php > 7.0, mariadb > 10.2, composer > 2.0
- 1. Install php modules
- ```
- sudo apt-get install php7.1-mcrypt php7.1-intl php7.1-soap
- ```
- 2. Download magento
- Go to `https://magento.com/tech-resources/download` and choose version
- and then extract to `/var/www/html/magento`
- 3. Change write permission to some folder
- ```
- sudo chmod -R o+w app/etc var pub/media pub/static generated
- ```
- 4. create `magento` table in mariadb with regular permission and `Lock table` permission for user be used in magento.
- 5. Setup virtual host
- - Add `127.0.0.1 magento.loc` to `/etc/hosts` file
- - create `/etc/apache2/sites-available/magento.loc.conf` with content
- ```
- <VirtualHost *:80>
- ServerName magento.loc
- DocumentRoot /var/www/html/magento
- <Directory /var/www/html/magento/>
- Options Indexes FollowSymLinks MultiViews
- AllowOverride All
- Require all granted
- </Directory>
- </VirtualHost>
- ```
- - Disable default apache config, enable `magento.loc.conf`
- ```
- sudo a2dissite 000-default.conf
- sudo a2ensite magento.loc.conf
- sudo a2enmod rewrite
- sudo systemctl restart apache2
- ```
- 6. Go to `http://magento.loc` to continue setup.
- TIPS:
- - Check deploy mode `php bin/magento deploy:mode:show`
- - cache static content `php bin/magento setup:static-content:deploy`
- - set production enviroment `php bin/magento deploy:mode:set production`
- # Java
- ```
- sudo add-apt-repository ppa:webupd8team/java
- sudo apt-get update
- sudo apt install oracle-java8-installer
- ```
- # SonarQube
- Note: SonarQube can't use with MariaDB
- https://www.vultr.com/docs/how-to-install-sonarqube-on-ubuntu-16-04
- # Ruby, Ruby On Rails
- https://gorails.com/setup/ubuntu/16.04
- # ElasticSearch
- 1. Download a .deb file at [https://www.elastic.co/downloads/elasticsearch](https://www.elastic.co/downloads/elasticsearch)
- 1. Install
- ```
- sudo dpkg -i path/to/file.deb
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement