Ubuntu16.04搭建LAMP开发环境

虚拟机上安装好Ubuntu16.04后,是一台空白的Ubuntu。我的目的是搭建LAMP环境,顺便搭一个Python Django环境。


基本设置

1.配置网络环境

管理员给分配了一个静态IP,所以还需要进一步配置网络环境

  • 配置DNS:右上角网络连接->编辑链接->有线连接1->IPv4设置->DNS服务器:202.112.80.106->保存

  • 登陆网关:对于校园网用户来说,登陆网关才能访问外网

  • 测试ping www.baidu.com

2.设置root密码

sudo passwd

  • 切换到root用户susu -su root

  • 切换到普通用户su 用户名logout

3.更新源

sudo apt-get update

源保存的文件为:/etc/apt/sources.list


安装常用软件

1.SSH

sudo apt-get install openssh-server

  • 查看状态service ssh status/start/stop/restart

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

  • 实际上,service命令就是执行/etc/init.d脚本,二者功能是一样的

2.Vim

sudo apt-get install vim

3.Tree

sudo apt-get install tree

4.Git

sudo apt-get install git


搭建LAMP

1.安装Apache

sudo apt-get install apache2

  • 测试: 浏览器访问http://Ubuntu的IP,出现It Works!网页。

  • 查看状态service apache2 status/start/stop/restart

  • Web目录/var/www

  • 安装目录/etc/apache2/

  • 全局配置/etc/apache2/apache2.conf

  • 监听端口/etc/apache2/ports.conf

  • 虚拟主机/etc/apache2/sites-enabled/000-default.conf

2.安装MySQL

sudo apt-get install mysql-server mysql-client

  • 测试mysql -u root -p

  • 查看状态service mysql status/start/stop/retart

  • 查看监听端口的情况netstat -tunplnetstat -tap

3.安装PHP

sudo apt-get install php7.0

  • 测试php7.0 -v

4.安装其他模块

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

sudo apt-get install php7.0-mysql

  • 重启服务

    • service apache2 restart

    • service mysql restart

  • 测试Apache能否解析PHP

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

    • 文件中写:<?php echo phpinfo();?>

    • 浏览器访问:http://ubuntu地址/phpinfo.php,出现PHP Version网页

5.修改权限

sudo chmod 777 /var/www

6.安装phpMyAdmin

sudo apt-get install phpmyadmin

  • 安装:选择apache2,点击确定。下一步选择是要配置数据库,并输入密码。

  • 创建phpMyAdmin快捷方式sudo ln -s /usr/share/phpmyadmin /var/www/html

  • 启用Apache mod_rewrite模块sudo a2enmod rewrite

  • 重启服务

    • service php7.0-fpm restart

    • service apache2 restart

  • 测试:浏览器访问:http://ubuntu地址/phpmyadmin

7.配置Apache

vim /etc/apache2/apache2.conf

  • 添加

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

  • AddDefaultCharset UTF-8

  • 重启Apache服务


安装python包

1.pip

sudo apt-get install python-pip

2.Django

pip install django

测试import django

##3.MySQL-python

pip install MySQL-python

测试import MySQLdb


常见问题

1.Secure SSH Client连接出错

  • 错误:algorithm negotiation failed

  • 解决

    • 修改sshd的配置文件: vim /etc/ssh/sshd_config

    • 在配置文件中添加:

    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,umac-64@openssh.com,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,curve25519-sha256@libssh.org
    • 重启sshd服务: service ssh restart

2.Xshell或Xftp中文乱码

  • Xshell:文件->属性->终端->编码->UTF-8>

  • Xftp:文件->属性->选项->选中使用UTF-8编码

3.安装MySQL出错

  • 错误

下列软件包有未满足的依赖关系:

mysql-client : 依赖: mysql-client-5.5 但是它将不会被安装

mysql-server : 依赖: mysql-server-5.5 但是它将不会被安装

E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。

  • 解决:两种解决方法

    1. 使用Ubuntu自带的下载源,不要使用其他源(如网易)

    2. 手动安装

    • 下载MySQL:http://dev.mysql.com/downloads/mysql/

    • 使用FTP工具上传到Ubuntu

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

    • 安装:

    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.安装pip出错

解决:可改用如下命令:

sudo apt-get install python-pip python-dev build-essential

sudo pip install --upgrade pip

sudo pip install --upgrade virtualenv

5.安装Django超时报错

  • 解决

  • 设置超时时间:sudo pip install django --default-timeout 100

  • 或者使用其他下载源:pip install web.py -i http://pypi.douban.com/simple

6.安装MySQL-python报错

  • 错误EnvironmentError: mysql_config not found

  • 解决

  • sudo apt-get install libmysqld-dev

  • 安装MySQL-python:pip install MySQL-python

7.更新Python库

pip install --upgrade 库名

Ubuntu16.04搭建LAMP开发环境的更多相关文章

  1. Ubuntu16.04搭建各种开发环境的IDE: QT5 , CodeBlocks ,eclipse-cdt, PyCharm

    搭建Ubuntu下C/C++以及Python的集成开发环境,采用双系统(Win7+Ubuntu)的Ubuntu16.04-LTS系统, 关于双系统的搭建可以参考下面博客(图文十分详细):https:/ ...

  2. Ubuntu 16.04搭建LAMP开发环境

    基本设置 1.配置网络环境 管理员给分配了一个静态IP,所以还需要进一步配置网络环境 配置DNS:右上角网络连接->编辑链接->有线连接1->IPv4设置->DNS服务器:20 ...

  3. 阿里云学生服务器搭建网站-Ubuntu16.04安装php开发环境

    阿里云学生服务器搭建网站(2)-Ubuntu16.04安装php开发环境  优秀博文:https://www.linuxidc.com/Linux/2016-10/136327.htm https:/ ...

  4. Ubuntu 12.04 搭建Android开发环境

    Ubuntu 12.04 搭建Android开发环境 2013/7/29 Linux环境下搭建Android开发环境 大部分开发人员可能都在Windows下做开发,可能是感觉在Windows下比较方便 ...

  5. 【转】一步一步教你在Ubuntu12.04搭建gstreamer开发环境

    原文网址:http://blog.csdn.net/xsl1990/article/details/8333062 闲得蛋疼    无聊寂寞冷    随便写写弄弄 看到网上蛮多搭建gstreamer开 ...

  6. ubuntu16.04 Golang语言开发环境搭建

    golang即go语言是跨平台的语言,适用于windows 和linux平台,下面介绍linux平台下ubuntu16.04系统下的开发环境搭建过程. 一.安装开发必备环境 执行下面命令分别安装git ...

  7. Ubuntu16.04安装后开发环境配置和常用软件安装

    Ubuntu16.04安装后1.安装常用软件搜狗输入法+编辑器Atom+浏览器Chome+视频播放器vlc+图像编辑器GIMP Image Editor安装+视频录制软件RcordMyDesktop安 ...

  8. Fedora下搭建LAMP开发环境

    LAMP是Linux + Apache + MySQL +PHP/Python的缩写,是一组常用来搭建动态网站服务器的开源软件.它们本身都是各自独立的程序,但是因为开源并且常放在一起使用,所以拥有了越 ...

  9. Ubuntu16.04的PHP开发环境配置

    \3c a { text-decoration: none } 自从换了php开发之后发现还是开源语言才是长久之道,开发环境搭建方便,支持的平台也多,性能也好,考虑到这些,其他一些不如意也就不足为虑了 ...

随机推荐

  1. git回滚到指定commit

    一次性commit好多文件,push上去之后,发现工程不可用,只能回滚,上网搜索回滚办法,下边这个是自己亲试的,特别好使: 操作步骤: 1.git checkout the_branch 2.git ...

  2. 4,版本控制git --忽略特殊文件

    有些时候,你必须把某些文件放到Git工作目录中,但又不能提交它们,比如保存了数据库密码的配置文件啦,等等,每次git status都会显示Untracked files ...,有强迫症的童鞋心里肯定 ...

  3. 9.5web service基础知识

    Web服务基础 用户访问网站的基本流程 我们每天都会用web客户端上网,浏览器就是一个web客户端,例如谷歌浏览器,以及火狐浏览器等. 当我们输入www.oldboyedu.com/时候,很快就能看到 ...

  4. Win7更换锁屏和开机画面

    技术交流群:233513714 每次开机被Windows千年不变的开机画面和锁屏画面丑到的小伙伴们可以看过来,通过简单的几步就可以改掉系统默认的开机画面. 1.首先Windows+r键输入regedi ...

  5. android 管理Touch事件

    The onInterceptTouchEvent() method gives a parent the chance to see any touch event before its child ...

  6. 剑指Offer - 九度1366 - 栈的压入、弹出序列

    剑指Offer - 九度1366 - 栈的压入.弹出序列2014-02-05 20:41 题目描述: 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序.假设压入栈的所 ...

  7. day06_03 购物车讲解01

    1.0 思路 1.1 列表嵌套 # name1 = ['mac','book','bike','kindle'] a = [[1,2,3],'alex',(2,3,4)] print(a[0]) #& ...

  8. NGUI-UIProgressBar,UIScrollBar,UISlider

    UIProgressBar是UIScrollBar和UISlider的基类 1.先来看下UIProgressBar(进度条)的使用 层次: progressBar的Inspector视图: 而fore ...

  9. php 报错 Cannot modify header information

    在用CI 开发微信公众号的时候出现下面这么个问题,网上看了一圈解决办法是:把报错的文件用editplus另存为utf-8. Severity: Warning Message: Cannot modi ...

  10. SPOJ 364 Pocket Money 简单DP

    跟矩阵链乘同类型的题…… 输出用%llu不是%I64u…… 几组数据: 141+2*4+3*4+5*00*5*6+7*3+23+0+6+7+0+44*5+7*1*1+12*0+3*4*0+5*6+7+ ...