简要记录一下。

环境准备

虚拟机环境

lz@starnight:~$ sudo -i
[sudo] password for lz:
root@starnight:~# cat /etc/issue
Ubuntu 16.04. LTS \n \l

更新系统

root@starnight:~# sudo apt-get update

安装Apache

root@starnight:~# sudo apt-get install apache2
root@starnight:~# apache2 -v
Server version: Apache/2.4. (Ubuntu)
Server built: --18T14::

默认的Web路径:/var/www/html

root@starnight:/var/www/html# pwd
/var/www/html
root@starnight:/var/www/html# ls
index.html

访问本地地址:localhost或127.0.0.1

安装PHP

root@starnight:~# sudo apt-get install php7.
root@starnight:~# php7. -v
PHP 7.0.-0ubuntu0.16.04. (cli) ( NTS )
Copyright (c) - The PHP Group
Zend Engine v3.0.0, Copyright (c) - Zend Technologies
with Zend OPcache v7.0.28-0ubuntu0.16.04., Copyright (c) -, by Zend Technologies
root@starnight:~# sudo apt-get install libapache2-mod-php7.

安装MySQL

root@starnight:~# sudo apt-get install mysql-server

在安装过程中会提示输入/重复密码。

root@starnight:~# sudo apt-get install php7.-mysql

到这里LAMP环境就算是安装成功了。

虚拟目录

如果机器上要部署多个Web项目,可以通过不同端口进行指定。

例如:在Web Root下有个项目helo,我想直接通过ip:port的形式进行访问。

root@starnight:/var/www/html/helo# pwd
/var/www/html/helo
root@starnight:/var/www/html/helo# ls
index.php

这里可以通过配置虚拟目录来实现。

root@starnight:/var/www/html/helo# cat /etc/apache2/ports.conf

在Listen 80添加你想设置的端口,如8080

root@starnight:/var/www/html/helo# cat /etc/apache2/ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/-default.conf Listen
Listen

<IfModule ssl_module>
Listen
</IfModule> <IfModule mod_gnutls.c>
Listen
</IfModule> # vim: syntax=apache ts= sw= sts= sr noet

设置虚拟目录:

root@starnight:/var/www/html/helo# cat /etc/apache2/sites-available/-default.conf 

copy 一份里面原有的内容,只需要更改port和DocumentRoot两项即可(本地环境,不涉及域名的问题,也可以进行相应的修改)

端口设置:8080,路径:/var/www/html/helo

重启apache2服务:

root@starnight:/var/www/html/helo# sudo /etc/init.d/apache2 restart

访问本地ip:port

对,index.php的内容就是那个经典的phpinfo()。

Ubuntu 安装LAMP的更多相关文章

  1. 2019.9.17更换ubuntu的镜像源 ubuntu安装lamp iis安装网站和ftp站

    更换ubuntu的镜像源 /etc/apt/sources.list cp  /etc/apt/sources.list  /etc/apt/sources.list.bak 备份这个文件 vim / ...

  2. ubuntu 安装 lamp 和配置虚拟机

    1:sudo passwd root  #设定root密码 su 切换  exit 退出  ,或者 普通用户下 加sudo  2:sudo apt-get update  #更新软件列表 3:sudo ...

  3. Ubuntu安装LAMP环境(PHP5.6) 以及下载安装phpmyadmin

    参考路径: http://blog.nciaer.com/?p=133 修改apache(2.4.18)的web路径时, 需要将 /etc/apache2/sites-available/000def ...

  4. ubuntu 安装LAMP web 服务器, phpmyadmin 安装后无法打开解决

    安装方法: http://blog.chinaunix.net/uid-26495963-id-3173291.html 在上述文档中需要增加apache 支持mysql 功能. apt-get in ...

  5. ubuntu安装LAMP环境

    1. LAMP 的安装 sudo apt-get install apache2 mysql-server mysql-client php5 php5-gd php5-mysql 由于LAMP大部分 ...

  6. 笔记:Ubuntu安装LAMP环境

    一.更换Ubuntu的镜像源 镜像源路径:/etc/apt/sources.list 备份:cp /etc/apt/sources.list /etc/apt/souces.list.bak 使用阿里 ...

  7. Ubuntu安装LAMP

    1.安装apache2 sudo apt-get install apache2 sudo apt-get install apache2 Apache安装成功后,/var/www/默认作为web的根 ...

  8. ubuntu 安装 lamp

    链接: http://www.cnblogs.com/CheeseZH/p/4694135.html

  9. ubuntu 安装 LAMP环境

    http://jingyan.baidu.com/article/a681b0de36ad683b18434691.html

随机推荐

  1. 【翻译】在Ext JS 6通用应用程序中使用既共享又特定于视图的代码

    原文:Using Both Shared and View-Specific Code in an Ext JS 6 Universal App 在本文,在展示如何编写Ext JS 6通用应用程序代码 ...

  2. pig代码格式上小注意

    1,%default file test.txt 中不要用引号,'' 和""都不行.'file'不会被识别 2,pig判断相等,用==,不是一个=.. 3,pig中只用单引号,不用 ...

  3. Integration between SharePoint 2013 and CRM 2013 (On-Premise)

    具体步骤可见下面的链接 https://community.dynamics.com/crm/b/msdynamicscrmtips/archive/2014/01/27/integration- ...

  4. Uva - 11853 - Paintball

    先判断是否有解,从上到下dfs判断连通性,如果有从顶部到底部连通图,则无解.再判断最北的进出位置,从上边界开始遍历,沿途检查与边界相交的圆.这些圆的左边界的交点中最靠南边的一个就是所有的最北进入位置, ...

  5. TCP的定时器系列 — 保活定时器

    主要内容:保活定时器的实现,TCP_USER_TIMEOUT选项的实现. 内核版本:3.15.2 我的博客:http://blog.csdn.net/zhangskd 原理 HTTP有Keepaliv ...

  6. 【一天一道LeetCode】#64. Minimum Path Sum.md

    一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given a ...

  7. Python学习笔记 - 迭代Iteration

    #!/usr/bin/env python3 # -*- coding: utf-8 -*- d = {'a': 1, 'b': 2, 'c': 3} for key in d: # 默认迭代是key ...

  8. 《java入门第一季》之面向对象接口面试题

    首先,(1)叙述接口的成员特点: /* 接口成员特点 成员变量:只能是常量,默认都是常量,并且是静态的. 默认修饰符:public static final 建议:自己手动给出类似:public st ...

  9. 寻找春天&nbsp;九宫格日记-2014.04.26

    写九宫格日记 总会在听到某一首歌的时候泪流满面:总会在看到某个似曾相识的背影的时候惆怅莫名,总会在嗅到某种香味的时候默默发呆,总会在经过某个地方的时候频频回首.生命有限,不要把它浪费在重复别人的生活上 ...

  10. 查看linux系统是多少位

    . getconf LONG_BIT echo $HOSTTYPE uname -a 这三个是对的 我的是64位