Ubuntu 16.04 Build Lamp development environment

Source: Internet
Author: User
Tags hmac install php md5 phpinfo sha1 install django pip install django

1.

Http://www.linuxidc.com/Linux/2016-10/136327.htm

2.

After installing the Ubuntu16.04, it is a blank Ubuntu. My goal is to build a lamp environment, and by the way, a Python django environment.

Basic Settings 1. Configure the network environment

The administrator assigns a static IP, so further configuration of the network environment is required

  • Configure DNS: Upper-Right network connection, edit link, wired connection 1->ipv4 settings->dns server:202.112.80.106-> Save

  • Login Gateway : For campus network users, login gateway to access the external network

  • Test :ping www.baidu.com

2. Set the root password

sudo passwd

  • switch to root user : su or su -su root

  • switch to normal user : su 用户名 orlogout

3. Update the source

sudo apt-get update

The files saved by the source are:/etc/apt/sources.list

Install common software 1. Ssh

sudo apt-get install openssh-server

  • View status :service ssh status/start/stop/restart

  • Or:/etc/init.d/ssh status/start/stop/retsrt

  • In fact, the service command executes the/ETC/INIT.D script, which is the same function

2.Vim

sudo apt-get install vim

3.Tree

sudo apt-get install tree

4.Git

sudo apt-get install git

Build LAMP1. Install Apache

sudo apt-get install apache2

  • Test : Browser Access http://Ubuntu的IP , the It works! Web page appears.

  • View 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

  • View the status of the listening port : netstat -tunpl ornetstat -tap

3. Install PHP

sudo apt-get install php7.0

  • Test :php7.0 -v

4. Install additional modules

sudo apt-get install libapache2-mod-php7.0
sudo apt-get install php7.0-mysql

  • Restart Service

    • service apache2 restart

    • service mysql restart

  • Test Apache can parse PHP

    • vim /var/www/html/phpinfo.php

    • The file reads:<?php echo phpinfo();?>

    • Browser access: http://ubuntu地址/phpinfo.php , the PHP version page appears

5. Modify Permissions

sudo chmod 777 /var/www

6. Installing phpMyAdmin

sudo apt-get install phpmyadmin

  • Install : Select Apache2, click OK. The next option is to configure the database and enter the password.

  • To Create a phpmyadmin shortcut :sudo ln -s /usr/share/phpmyadmin /var/www/html

  • To enable the Apache mod_rewrite module :sudo a2enmod rewrite

  • Restart Service :

    • service php7.0-fpm restart

    • service apache2 restart

  • Test : Browser access:http://ubuntu地址/phpmyadmin

7. Configure Apache

vim /etc/apache2/apache2.conf

  • Add :

  • AddType application/x-httpd-php .php .htm .html

  • AddDefaultCharset UTF-8

  • Restart 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

FAQ 1. Secure SSH Client Connection error
  • error : Algorithm negotiation failed

  • Resolve :

    • Modify the configuration file for sshd:   vim/etc/ssh/sshd_config

    • In the configuration file, add: /p>

    ciphers Aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour, Blowfish-cbc,cast128-cbcmacs hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,hmac-sha1-96, Hmac-md5-96kexalgorithms 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 S SHD service:   service ssh restart

2.Xshell or Xftp Chinese garbled
  • Xshell: End-of-file, properties---->utf-8>

  • xftp: Options----Properties, file--with UTF-8 encoding

3. Error installing MySQL
    • Error :

The following packages have unsatisfied dependencies:
Mysql-client: Dependent: mysql-client-5.5 But it will not be installed
Mysql-server: Dependent: mysql-server-5.5 But it will not be installed
E: The error cannot be corrected because you require certain packages to remain current, that is, they destroy the dependencies between the software packages.

    • Solution : Two Solutions

      1. Use Ubuntu's own download source, do not use other sources (such as NetEase)

      2. Manual Installation

      • Download MySQL:http://dev.mysql.com/downloads/mysql/

      • Uploading to Ubuntu using the FTP tool

      • Extract:tar -xvf mysql-server_5.7.13-1ubuntu16.04_i386.deb-bundle.tar

      • Installation:

      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

workaround : 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. Installing the Django Super-times error
  • Solve

  • To set the timeout period:sudo pip install django --default-timeout 100

  • Or use a different download source:pip install web.py -i

6. Installation Mysql-python Error
  • Error :EnvironmentError: mysql_config not found

  • Solution :

  • sudo apt-get install libmysqld-dev

  • Install Mysql-python:pip install MySQL-python

7. Updating the Python library

pip install --upgrade 库名

This article permanently updates the link address : http://www.linuxidc.com/Linux/2016-10/136327.htm

Ubuntu 16.04 Build Lamp development environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.