After installing Ubuntu16.04, it is a blank Ubuntu. My purpose is to build a LAMP environment, and by the way a Python Django environment.
basic settings
1. Configure the network environment
The administrator has assigned a static IP, so it is necessary to further configure the network environment
Configure DNS: upper right corner network connection->edit link->wired connection 1->IPv4 settings->DNS server: 202.112.80.106->save
Login gateway: For campus network users, only by logging in to the gateway can access the external network
Test: ping www.baidu.com
2. Set the root password
sudo passwd
Switch to root user: su or su - or su root
Switch to normal user: su username or logout
3. Update source
sudo apt-get update
The source saved file is: /etc/apt/sources.list
Install common software
1.SSH
sudo apt-get install openssh-server
Check the status: service ssh status/start/stop/restart
或:/etc/init.d/ssh status/start/stop/retsrt
In fact, the service command is to execute the /etc/init.d script, and the functions of the two are the same
2.Vim
sudo apt-get install vim
3.Tree
“
sudo apt-get install tree
4.Git
sudo apt-get install git
Build LAMP
1. Install Apache
sudo apt-get install apache2
Test: The browser accesses the IP of http://Ubuntu , and the It Works! webpage appears.
Check the status: service apache2 status/start/stop/restart
Web directory: /var/www
Installation directory: /etc/apache2/
Global configuration: /etc/apache2/apache2.conf
Listening port: /etc/apache2/ports.conf
Virtual host: /etc/apache2/sites-enabled/000-default.conf
2. Install MySQL
sudo apt-get install mysql-server mysql-client
Test: mysql -u root -p
View status: service mysql status/start/stop/retart
Check the listening port: netstat -tunpl or netstat -tap
3. Install PHP
sudo apt-get install php7.0
Test: php7.0 -v
4. Install other modules
sudo apt-get install libapache2-mod-php7.0
sudo apt-get install php7.0-mysql
restart the service
service apache2 restart
service mysql restart
Test whether Apache can parse PHP
vim /var/www/html/phpinfo.php
The file writes:
Browser access: http://ubuntu address/phpinfo.php, the PHP Version page appears
5. Modify permissions
sudo chmod 777 /var/www
6. Install phpMyAdmin
sudo apt-get install phpmyadmin
Installation: Select apache2 and click OK. The next option is to configure the database and enter a password.
Create phpMyAdmin shortcut: sudo ln -s /usr/share/phpmyadmin /var/www/html
Enable Apachemod_rewrite module: sudo a2enmod rewrite
Restart the service:
service php7.0-fpm restart
service apache2 restart
Test: Browser access: http://ubuntu address/phpmyadmin
7. Configure Apache
vim /etc/apache2/apache2.conf
Add to:
AddType application/x-httpd-php .php .htm .html
AddDefaultCharset UTF-8
Restart the Apache service
install python package
1.pip
sudo apt-get install python-pip
2.Django
pip install django
Test: import django
3.MySQL-python
pip install MySQL-python
Test: import MySQLdb
common problem
1. Secure SSH Client connection error
错误:algorithm negotiation failed
solve:
Modify the sshd configuration file: vim /etc/ssh/sshd_config
In the configuration file add:
Ciphers aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour,blowfish-cbc,cast128-cbc
MACs hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,hmac-sha1-96,hmac-md5-96
KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,[email protected]
Restart the sshd service: service ssh restart
2. Xshell or Xftp Chinese garbled characters
Xshell: File->Properties->Terminal->Encoding->UTF-8>
Xftp: File -> Properties -> Options -> Check Use UTF-8 encoding
3. Error installing MySQL
mistake:
The following packages have unmet dependencies:
mysql-client : Depends: mysql-client-5.5 but it will not be installed
mysql-server : depends on: mysql-server-5.5 but it will not be installed
E: The bug cannot be fixed because you require some packages to remain as they are, that is, they break dependencies between packages.
Solution: Two workarounds
Use the download source that comes with Ubuntu, do not use other sources (such as NetEase)
Manual installation
Download MySQL: http://dev.mysql.com/downloads/mysql/
Upload to Ubuntu using FTP tool
Release: tar -xvf mysql-server_5.7.13-1ubuntu16.04_i386.deb-bundle.tar
Install:
sudo dpkg -i libmysqlclient20_5.7.15-1ubuntu16.04_amd64.deb libmysqlclient-dev_5.7.15-1ubuntu16.04_amd64.deb libmysqld-dev_5.7.15-1ubuntu16.04_amd64.deb mysql-common_5.7.15-1ubuntu16.04_amd64.deb mysql-community-source_5.7.15-1ubuntu16.04_amd64.deb mysql-community-client_5.7.15-1ubuntu16.04_amd64.deb mysql-client_5.7.15-1ubuntu16.04_amd64.deb mysql-community-server_5.7.15-1ubuntu16.04_amd64.deb mysql-server_5.7.15-1ubuntu16.04_amd64.deb
4. Error installing pip
Solution: You can use the following command instead:
sudo apt-get install python-pip python-dev build-essential
sudo pip install –upgrade pip
sudo pip install –upgrade virtualenv
5. Error when installing Django
solve
Set timeout: sudo pip install django --default-timeout 100
Or use another download source: pip install web.py -i
6. Error when installing MySQL-python
错误:EnvironmentError: mysql_config not found
solve:
sudo apt-get install libmysqld-dev
Install MySQL-python: pip install MySQL-python
7. Update the Python library
pip install –upgrade 库名
This article permanently updates the link address: http://www.linuxidc.com/Linux/2016-10/136327.htm