Dev-environment conf in Ubuntu 16 / 18

ubuntu-desktop

Basic: Install Ubuntu 16.04 / 18.04 LTS

Download Ubuntu mirror ( can use domestic mirror station, e.g. tsinghua)
https://mirrors.tuna.tsinghua.edu.cn/ubuntu-releases/

Install Ubuntu iso in VIRTUAL MACHINE ( VMware ) or REAL MACHINE

Switch download site into China ( thanks to the Great Fire Wall - smile.jpg). I choose aliyun's site.

source-download-site

Add Chinese Language Support in Language Support

Input command line # ibus-setup to enter ibus setting interface. Pinyin mode > add Chinese-Pinyin.

Restart Ubuntu, and then add ibus pinyin for Chinese input

ibus-pinyin

For the user of Ubuntu 16, if you find that when you choose a part of text and after clicking the chosen text, it'll disappear. This problem can be solved by ibus-setup.

# ibus-setup

Disable the option Embed preedit text in application window, which can fix this problem.

It you are using Ubuntu 18, just choose intelligent-pinyin instead of ibus-pinyin.

1 Apache

Login Terminal with ROOT identity

$ sudo su

Install apache server

# apt-get install apache2

Then you can open http://localhost or http://127.0.0.1 in Chrome. If showing a successful test page, apache works well.

apache-ubuntu

2 MySQL

Before installing MySQL, please ensure supported platform of the MySQL database

https://www.mysql.com/support/supportedplatforms/database.html

supported-platform

Install MySQL in Ubuntu16

# apt-get install mysql-server mysql-client

Set the root's password of MySQL in the pop-up window.

Install MySQL in Ubuntu18

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

# mysql_secure_installation

mysql > SELECT user,authentication_string,plugin,host FROM mysql.user;
mysql > ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
mysql > FLUSH PRIVILEGES;

mysql> set global validate_password_policy=0;
mysql> SHOW VARIABLES LIKE 'validate_password%';

Configure MySQL UTF8 coding, the same in Ubuntu16 and Ubuntu18

Set the MySQL coding to uft8. Vim mysql.cnf

# vim /etc/mysql/conf.d/mysql.cnf

###Add under [mysql]###
default-character-set=utf8

Vim mysqld.cnf

# vim /etc/mysql/mysql.conf.d/mysqld.cnf

###Add under [mysqld]###
character-set-server=utf8

Restart MySQL service and check if setting is successful.

# systemctl restart mysql
# mysql -uroot -p
mysql > show variables like '%character%';

All Values are uft8 ( successful )

mysql-coding

3 PHP

Ubuntu 18.04 will install PHP7 by default.

Installation

Install php and apache-php lib

# apt-get install php libapache2-mod-php

Install php extend ( My project need php-mysql, php-curl, php-xml )

# apt-get install php-gd php-mysql php-curl php-xml

PHP File Upload Configure

Find php.ini and open it:

file_uploads = on ; Whether to allow HTTP file uploads. Default ON
upload_tmp_dir ; Temporary directory for HTTP uploaded files (will use system default if not specified)
upload_max_filesize = 2M ; Maximum allowed size for uploaded files. Default value = 2M
post_max_size = 8M ; Maximum size of POST data that PHP will accept. Default value = 8M

Generally, we can upload file whose size is no more than 8M by setting up these four parameters also with normal network situation. However, if we need to upload >8M size files, we'd better configure these:

max_execution_time = 30 ; Maximum execution time of each script, in seconds. Default value = 30
max_input_time = 60 ; Maximum amount of time each script may spend parsing request data. Default Value = -1 (Unlimited)
memory_limit = 8m ; Maximum amount of memory a script may consume.

Restart apache service

# systemctl restart apache2

4 Configure Java Environment ( oracle )

Add ppa source

# add-apt-repository ppa:webupd8team/java
# apt-get update

Install oracle-java-installer

# apt-get install oracle-java8-installer

Set system default jdk

# update-java-alternatives -s java-8-oracle

Test java installation

# java -version
# javac -version

5 Python Switching Configure

If you are using Ubuntu13, you can install python3 (python2 has been already installed by default on Ubuntu16)

# apt-get install python3

If you are using Ubuntu18, your system has already installed py3 but not py2. Therefore, we can install py2 for probable future demand.

# apt-get install pyhton

python-usr-bin

Configure python-switching environment by Ubuntu update-alternatives

# update-alternatives --list python

If you get update-alternatives: error: no alternatives for python message, that means the alternative version of python has not been recognized by command update-alternatives. If we want to solve this problem, we need to put python2 and python3 in update-alternatives:

# update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
# update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2

The meaning of parameters of --install command

--install <link> <name> <path> <priority>

List alternative version of python

# update-alternatives --list python
/usr/bin/python2.7
/usr/bin/python3.5

Choose the version of python

# update-alternatives --config python

Check python version

# python --version

Other useful command: Remove the configuration of update-alternatives

# update-alternatives --remove-all python
# ln -s /usr/bin/<python2.7|python3.5> /usr/bin/python

python extension

# sudo apt-get install python3-pip
# pip3 install PyMySQL

6 Tools for Developing

All software in the Form 1 below can be installed in Ubuntu Software, really convenient, just searching the names of these APPs.

NamesDescriptionVersion
Intellij IDEA CommunityJava IDE2018.3.4
Pycharm CEPython IDE2018.3.4
Sublime Texttext editing3176
Chromlumweb browser71.0.3578.98
Workbenchvisual management to MySQL Database
Android Studioandroid development IDE

Form 1 Software list

mysql-workbench

7 Trouble Shoot

( 1 ) Cannot update Ubuntu 16.04 LTS to 18.04 LTS for the python3 error

# do-release-upgrade

Checking package manager

Can not upgrade 

Your python3 install is corrupted. Please fix the '/usr/bin/python3' 
symlink.

See in https://askubuntu.com/questions/1104192/unable-to-upgrade-to-ubuntu-18-04-from-ubuntu-17-10

Need to keep /usr/bin/python directly point to /usr/bin/python3.5 without update-alternatives.

8 Notes for Some Commands

//mysql
mysqldump -u -p <database> > example.sql
mysql -u -p <database> < example.sql

//ssh and sftp
ssh <ip>
sftp <ip>
get
put
cd,lcd
ls,lls
pwd,lpwd

//apt-get
apt-get install
apt-get remove

//other
do-release-upgrade
strace

//chmod, chown
chmod -R 777 <dictionary>               //change file's permission
chmod 777 <file>
chown -R <user>:<user group> <folder>   //change file's owner

//systemctl
systemctl restart apache2
systemctl restart mysql
systemctl restart networking //hosts file

//tar
tar -xzvf example.tar.gz             //x-unpack and z-decompress, v-show info, f-file name
tar -czvf newName.tar.gz folderName  //c-pack and z-compress
tar -cvf newName.tar folderName      //c-pack not z-compress

//git
git clone
git rm -r --cached <folderName/Filename>
git commit -m 'Add you own description'
git add .    #. can match all pattern of files
git pull origin master 
git push -u origin master 
发表新评论