Advertisement
Guest User

Untitled

a guest
May 15th, 2018
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.60 KB | None | 0 0
  1. Find bookmark question in stackoverflow and askubuntu FIRST (Private).
  2.  
  3. *TIPS:*
  4.  
  5. - to upgrade only a package:
  6.  
  7. ```
  8. sudo apt-get update
  9. sudo apt-get --only-upgrade install <packagename>
  10. ```
  11.  
  12. - Ubuntu distribution version: `lsb_release -sc`
  13.  
  14. # install aptitude for better resolve conflict when install packages
  15.  
  16. ```
  17. sudo apt-get install aptitude
  18. ```
  19.  
  20. # install unity tweak
  21.  
  22. `sudo apt-get install unity-tweak-tool`
  23.  
  24. # Install Git
  25.  
  26. ```
  27. sudo apt-get install git
  28. ```
  29.  
  30. # Install Vim
  31.  
  32. `sudo apt-get install vim`
  33.  
  34. # Install zsh and oh-my-zsh:
  35.  
  36. `sudo apt-get install zsh`
  37.  
  38. Restart terminal, check, set as default:
  39.  
  40. ```shell
  41. zsh --version;
  42. chsh -s $(which zsh)
  43. ```
  44.  
  45. Set default user (user logged in), turn off update in config:
  46.  
  47. `vim ~/.zshrc`
  48.  
  49. ## Install Oh-my-zsh:
  50.  
  51. `sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"`
  52.  
  53. Optional: use agnoster theme: https://github.com/robbyrussell/oh-my-zsh/wiki/themes
  54.  
  55. # Install chrome
  56.  
  57. ```
  58. cd /tmp
  59. wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
  60. sudo dpkg -i google-chrome-stable_current_amd64.deb
  61. sudo apt-get -f install
  62. ```
  63. # Install sublime text:
  64.  
  65. http://tipsonubuntu.com/2017/05/30/install-sublime-text-3-ubuntu-16-04-official-way/
  66.  
  67. ```
  68. wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
  69. echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
  70. # or dev version (paid version)
  71. echo "deb https://download.sublimetext.com/ apt/dev/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
  72.  
  73. sudo apt-get update
  74. sudo apt-get install sublime-text
  75. subl --version
  76. ```
  77.  
  78. # Install vscode
  79.  
  80. ```
  81. curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
  82. sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
  83. sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
  84.  
  85. sudo apt-get update
  86. sudo apt-get install code # or code-insiders
  87. code --version
  88. ```
  89. Update VS Code:
  90. https://github.com/moeenz/vscode-updater
  91.  
  92. # Install LAMPP (or PHP, MySQL/PosgreSQL, Apache/NginX):
  93.  
  94. - Download xampp's setup file and run: `sudo path/to/file/file-name`
  95. - Remove: `sudo rm -rf /opt/lampp`
  96. Default mysql user: root, password: NONE
  97.  
  98. Or install invidually: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04
  99.  
  100. ## Apache:
  101.  
  102. ```
  103. sudo apt-get install apache2
  104. apache2 -v
  105. ```
  106.  
  107. Disable/enable apache2 from startup:
  108.  
  109. ```
  110. sudo update-rc.d apache2 disable/enable
  111. ```
  112.  
  113. Disable/enable apache2 service
  114.  
  115. ```
  116. sudo systemctl disable/enable apache2
  117. ```
  118.  
  119. Start/stop apache2
  120.  
  121. ```
  122. sudo systemctl start/stop apache2
  123. ```
  124.  
  125. Configuration: allow external access in firewall
  126.  
  127. ```
  128. sudo ufw app list
  129. sudo ufw allow in 'Apache Full'
  130. sudo ufw enable
  131. sudo ufw status
  132. ```
  133.  
  134. Open web browser and test. See public address:
  135.  
  136. ```
  137. hostname -I
  138. # or
  139. curl -4 icanhazip.com
  140. ```
  141.  
  142. ## PHP
  143.  
  144. ```
  145. sudo apt-get install software-properties-common
  146. sudo add-apt-repository ppa:ondrej/php
  147. sudo apt-get update
  148. sudo apt-get install php7.2
  149. # packages
  150. 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
  151. ```
  152.  
  153. Suggusted:
  154. 1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman
  155. 2. If you are using apache2, you are advised to add ppa:ondrej/apache2
  156. 3. If you are using nginx, you are advise to add ppa:ondrej/nginx-mainline
  157.    or ppa:ondrej/nginx
  158.  
  159. ## MariaDB
  160.  
  161. ```
  162. sudo apt-get install software-properties-common
  163. sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
  164. sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mirror.delorahosting.com/mariadb/repo/10.2/ubuntu xenial main'
  165.  
  166. sudo apt-get update
  167. sudo apt-get install mariadb-server
  168. # check
  169. mysql -V
  170. sudo systemctl start mariadb/mysql
  171. # default port is 3306
  172. # Login with root account (default)
  173. mysql -u root -p
  174. ```
  175.  
  176. config security: `sudo mysql_secure_installation`
  177.  
  178. ## Phpmyadmin:
  179.  
  180. ```
  181. sudo add-apt-repository ppa:nijel/phpmyadmin
  182. sudo apt-get update
  183. sudo apt-get install phpmyadmin
  184. sudo a2enmod php7.2
  185. ```
  186.  
  187. Add `Include /etc/phpmyadmin/apache.conf` to end of apache config file:
  188.  
  189. ```
  190. sudo vim /etc/apache2/apache2.conf
  191. ```
  192.  
  193. Uncomment `$cfg['Servers'][$i]['AllowNoPassword'] = TRUE;` to allow login without password.
  194.  
  195. ```
  196. sudo vim /etc/phpmyadmin/config.inc.php
  197. ```
  198.  
  199. **Note**
  200.  
  201. 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`
  202.  
  203. ## PosgreSQL:
  204.  
  205. ```
  206. sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main"
  207. wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
  208. sudo apt-get update
  209. sudo apt-get install postgresql-10
  210. # Check
  211. psql --version
  212. # default port is 5432
  213. # Login with postgres account (default)
  214. psql -U postgres
  215. ```
  216.  
  217. ## NginX:
  218.  
  219. ```
  220. wget http://nginx.org/keys/nginx_signing.key
  221. sudo apt-key add nginx_signing.key
  222. sudo apt install nginx
  223. nginx -v
  224. ```
  225.  
  226. ## Install Composer
  227.  
  228. install to `~/Programs/scripts` (or whatever)
  229.  
  230. ```
  231. cd ~/Programs/scripts
  232. php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
  233. php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
  234. php composer-setup.php --filename=composer.phar
  235. php -r "unlink('composer-setup.php');"
  236. ```
  237. and then add alias to ZSH
  238. ```
  239. echo alias composer=\"~/Programs/scripts/composer.phar\" >> ~/.zshrc
  240. ```
  241. or install to /usr/local/bin/composer
  242. ```
  243. curl -sS http://getcomposer.org/installer | php -- --filename=composer
  244. chmod a+x composer
  245. sudo mv composer /usr/local/bin/composer
  246. # Check
  247. composer -V
  248. ```
  249. Install `hirak/prestissimo` to make composer install packages faster.
  250.  
  251. `composer global require hirak/prestissimo`
  252.  
  253. # Install Docker
  254.  
  255. https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04
  256.  
  257. ```
  258. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  259. sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  260. sudo apt-get update
  261. apt-cache policy docker-ce
  262. sudo apt-get install -y docker-ce
  263. # check
  264. systemctl status docker
  265. ```
  266.  
  267. # Install Git Kraken:
  268.  
  269. ```
  270. cd ~/Downloads
  271. wget https://release.gitkraken.com/linux/gitkraken-amd64.tar.gz
  272. tar -xvzf gitkraken-amd64.tar.gz
  273. ```
  274.  
  275. # Install Nodejs and NPM:
  276.  
  277. ```
  278. curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
  279. sudo apt-get install nodejs
  280. ```
  281.  
  282. # Install Redis
  283.  
  284. https://redis.io/download
  285. https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-redis-on-ubuntu-16-04
  286.  
  287. ```
  288. wget http://download.redis.io/releases/redis-4.0.8.tar.gz
  289. tar xzf redis-4.0.8.tar.gz
  290. cd redis-4.0.8
  291. make
  292. # run test
  293. make tests
  294. ```
  295.  
  296. Then add alias `redis-server` and `redis-cli` to _zsh/bash_
  297.  
  298. ```
  299. alias redis-server="/path_to_redis_folder/src/redis-server"
  300. # default redis port is 6379
  301. alias redis-cli="/path_to_redis_folder/src/redis-cli"
  302. ```
  303.  
  304. or use PPA
  305.  
  306. ```
  307. sudo add-apt-repository ppa:chris-lea/redis-server
  308. sudo apt-get update
  309. sudo apt-get install redis-server
  310. redis-server --version
  311. # test
  312. systemctl start redis-server
  313. systemctl status redis-server
  314. redis-cli
  315. > set test "HugeServer"
  316. > get test
  317. ```
  318.  
  319. # Install MongoDB
  320.  
  321. https://www.howtoforge.com/tutorial/install-mongodb-on-ubuntu-16.04/
  322.  
  323. ```
  324. sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
  325. 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
  326. sudo apt-get update
  327. sudo apt-get install mongodb-org
  328. ```
  329.  
  330. Default account: *mongodb*
  331.  
  332. Command:
  333.  
  334. ```
  335. sudo service mongod start/stop/restart
  336. # default port is 27017
  337. ```
  338.  
  339. Option: install Robo 3T or MongoDB Compass Management Tool
  340.  
  341. ```
  342. # https://robomongo.org/download
  343. # or
  344. wget https://downloads.mongodb.com/compass/mongodb-compass_1.6.0_amd64.deb;
  345. sudo dpkg -i mongodb-compass_1.6.0_amd64.deb;
  346. DEBUG=* mongodb-compass;
  347. ```
  348.  
  349. # Install Xdebug
  350.  
  351. Follow until reach and done step 7 at https://xdebug.org/wizard.php
  352. Depend on php version. make a file `/etc/php/7.1/mods-available/xdebug.ini`
  353.  
  354. ```
  355. # find xdebug.so path
  356. # locate xdebug.so
  357. zend_extension=/path/to/xdebug.so
  358.  
  359. xdebug.remote_autostart = 1
  360. xdebug.remote_host=localhost
  361. xdebug.remote_enable = 1
  362. xdebug.remote_connect_back=1
  363. xdebug.remote_port = 9000
  364. xdebug.remote_hander = dpgp
  365. xdebug.remote_mode = req
  366. xdebug.scream=0
  367. xdebug.cli_color=1
  368. xdebug.show_local_vars=1
  369. ;values: XDEBUG_ECLIPSE, netbeans-xdebug, macgdbp, PHPSTORM
  370. xdebug.idekey=PHPSTORM
  371.  
  372. ;To remove limits for xdebug_var_dump()
  373.  
  374. xdebug.var_display_max_depth = 5
  375. xdebug.var_display_max_children = 256
  376. xdebug.var_display_max_data = 2048
  377.  
  378. ;xdebug.var_display_max_depth = -1
  379. ;xdebug.var_display_max_children = -1
  380. ;xdebug.var_display_max_data = -1
  381. ```
  382.  
  383. Now you can enable/disable xdebug if necessary: `sudo phpenmod/phpdismod xdebug`
  384. If you are using composer, you probably going to want to disable xdebug for CLI: `sudo phpenmod/phpdismod -s cli xdebug`
  385.  
  386. To use with PHPSTORM we need more step, said _laravel-project_:
  387.  
  388. - Add a server. Go to Settings/Language & Framework/PHP/Servers
  389. - 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`)
  390. - In menu Run/Edit configuration, add a PHP Web Page with a name (`laravel xdebug`), choose a server in step 2 (`laravel`), Save.
  391. - In tools bar, choose `laravel xdebug` and turn on listening (phone shape).
  392. - Set a breakepoint.
  393. - Go to browser, turn on debugging status in Xdebug extension
  394. - Start debug.
  395.  
  396. # Use SSH key with git
  397.  
  398. https://wiki.paparazziuav.org/wiki/Github_manual_for_Ubuntu
  399.  
  400. # Install Php-CS-Fixer to `~/Programs/scripts` directory
  401.  
  402. ```
  403. cd ~/Programs/scripts
  404. wget http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -O php-cs-fixer.phar
  405. sudo chmod a+x php-cs-fixer.phar
  406. ```
  407. And then set an alias to `~/.bashrc` or `~/.zshrc`
  408. ```
  409. cat "alias php-cs-fixer=\"php ~/Programs/scripts/php-cs-fixer.phar\"" >> ~/.zshrc
  410. ```
  411. use
  412. ```
  413. php php-cs-fixer.phar fix --verbose --show-progress=estimating --rules=@Symfony,@PHP70Migration /path/to/dirOrfile
  414. ```
  415. OR use PHP CodeSniffer
  416. ```
  417. cd ~/Programs/scripts
  418. curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
  419. php phpcs.phar -h
  420. curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar
  421. php phpcbf.phar -h
  422. sudo chmod a+x phpcs.phar
  423. sudo chmod a+x phpcbf.phar
  424. ```
  425.  
  426. # Create virtual host in apache for laravel
  427. Assumption:
  428. - domain name `laravel.loc` (don't use domain name `.dev`, `.app` or `.local`)
  429. - project name laravel
  430. 1. Change permission
  431. ```
  432. sudo chown -R $USER:$USER /var/www/html/laravel
  433.  
  434. sudo chgrp -R www-data /var/www/html/laravel/storage /var/www/html/laravel/bootstrap/cache
  435. # or
  436. chmod -R 775 /var/www/html/laravel/storage /var/www/html/laravel/bootstrap/cache
  437. # or
  438. sudo chown -R www-data:www-data /var/www/html/laravel/storage /var/www/html/laravel/bootstrap/cache
  439. ```
  440.  
  441. 2. Enable `rewrite` module
  442.  
  443. ```
  444. sudo a2enmod rewrite
  445. ```
  446. 3. Add address to `hosts` file
  447. ```
  448. sudo vim /etc/hosts
  449. ```
  450. add this (don't forget `.` at the end of localhost)
  451. ```
  452. 127.0.0.1 localhost.
  453. ::1 localhost.
  454. fe80::1%lo0 localhost.
  455. 127.0.0.1 laravel.loc
  456. ```
  457. 4. Add virtual host config
  458. ```
  459. sudo vim /etc/apache2/sites-available/laravel.loc.conf
  460. ```
  461. add this
  462. ```
  463. <VirtualHost *:80>
  464. ServerName laravel.loc
  465. ServerAlias www.laravel.loc
  466. DocumentRoot /var/www/html/laravel/public/
  467. <Directory /var/www/html/laravel/>
  468. Options Indexes FollowSymLinks
  469. AllowOverride All
  470. Require all granted
  471. </Directory>
  472. </VirtualHost>
  473. ```
  474. 5. Enable site
  475. ```
  476. sudo a2ensite laravel.loc.conf
  477. ```
  478. This will create symbolic link from `/etc/apache2/sites-enabled/laravel.loc.conf` to `/etc/apache2/sites-available/laravel.loc.conf`
  479. 6. Disable defautl config and restart server
  480. ```
  481. sudo a2dissite 000-default.conf
  482. sudo systemctl restart apache2
  483. ```
  484.  
  485. # Magento
  486. Prerequisite: php > 7.0, mariadb > 10.2, composer > 2.0
  487. 1. Install php modules
  488. ```
  489. sudo apt-get install php7.1-mcrypt php7.1-intl php7.1-soap
  490. ```
  491. 2. Download magento
  492. Go to `https://magento.com/tech-resources/download` and choose version
  493. and then extract to `/var/www/html/magento`
  494. 3. Change write permission to some folder
  495. ```
  496. sudo chmod -R o+w app/etc var pub/media pub/static generated
  497. ```
  498. 4. create `magento` table in mariadb with regular permission and `Lock table` permission for user be used in magento.
  499. 5. Setup virtual host
  500. - Add `127.0.0.1 magento.loc` to `/etc/hosts` file
  501. - create `/etc/apache2/sites-available/magento.loc.conf` with content
  502. ```
  503. <VirtualHost *:80>
  504. ServerName magento.loc
  505. DocumentRoot /var/www/html/magento
  506. <Directory /var/www/html/magento/>
  507. Options Indexes FollowSymLinks MultiViews
  508. AllowOverride All
  509. Require all granted
  510. </Directory>
  511. </VirtualHost>
  512. ```
  513. - Disable default apache config, enable `magento.loc.conf`
  514. ```
  515. sudo a2dissite 000-default.conf
  516. sudo a2ensite magento.loc.conf
  517. sudo a2enmod rewrite
  518. sudo systemctl restart apache2
  519. ```
  520. 6. Go to `http://magento.loc` to continue setup.
  521. TIPS:
  522. - Check deploy mode `php bin/magento deploy:mode:show`
  523. - cache static content `php bin/magento setup:static-content:deploy`
  524. - set production enviroment `php bin/magento deploy:mode:set production`
  525.  
  526. # Java
  527. ```
  528. sudo add-apt-repository ppa:webupd8team/java
  529. sudo apt-get update
  530. sudo apt install oracle-java8-installer
  531. ```
  532.  
  533. # SonarQube
  534.  
  535. Note: SonarQube can't use with MariaDB
  536. https://www.vultr.com/docs/how-to-install-sonarqube-on-ubuntu-16-04
  537.  
  538. # Ruby, Ruby On Rails
  539.  
  540. https://gorails.com/setup/ubuntu/16.04
  541.  
  542. # ElasticSearch
  543.  
  544. 1. Download a .deb file at [https://www.elastic.co/downloads/elasticsearch](https://www.elastic.co/downloads/elasticsearch)
  545. 1. Install
  546. ```
  547. sudo dpkg -i path/to/file.deb
  548. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement