hi

没说过,上周五室友过生请客,在龙湖里吃嗨了喝爽了,回去的路上侃侃而谈。说好的这周一起去看年内最后的大片,火星救援的,谁知道老子眼神不好,买错了电影的时间。。。把周六的约定提前到了今儿个下午,madan,送都送不出去,只有敲班去看了

1、LAMP

-----搭建LAMP环境(二)-----

----给PHP添加常用拓展

gd以及curl,命令去网上找好了,这个太长了

liang@liang-andy:~$ sudo apt-get install php5-gd curl libcurl3-dev php5-curl
时间也有点长

验证的话,要先重启apache2服务,然后去上次说的那个探针文件中看,也就是看看phpinfo中有米有

----filezilla

ssh工具,管理服务器文件

-----LAMP环境配置优化(一)-----

----LAMP环境文件概述

常识

/etc--Ubuntu系统配置文件目录,一般通过apt-get命令安装的软件的配置文件都在这里

LAMP也在这里

/etc/apache2

/etc/mysql

/etc/php5

----环境文件详解

---

先打开apache2文件列表

liang@liang-andy:~$ cd /etc/apache2
liang@liang-andy:/etc/apache2$ ll
总用量 96
drwxr-xr-x   8 root root  4096 11月 23 19:08 ./
drwxr-xr-x 134 root root 12288 11月 25 12:37 ../
-rw-r--r--   1 root root  7115  1月  7  2014 apache2.conf
drwxr-xr-x   2 root root  4096 11月 23 19:08 conf-available/
drwxr-xr-x   2 root root  4096 11月 23 19:08 conf-enabled/
-rw-r--r--   1 root root  1782  1月  3  2014 envvars
-rw-r--r--   1 root root 31063  1月  3  2014 magic
drwxr-xr-x   2 root root 12288 11月 23 19:21 mods-available/
drwxr-xr-x   2 root root  4096 11月 23 19:21 mods-enabled/
-rw-r--r--   1 root root   320  1月  7  2014 ports.conf
drwxr-xr-x   2 root root  4096 11月 23 19:08 sites-available/
drwxr-xr-x   2 root root  4096 11月 23 19:08 sites-enabled/

apache2中有apache.conf,算是配置文件的总入口,可以include很多其他的配置文件——配置起来更灵活,而且总文件不是很大

核心配置:mods-*** apache模块;sites-*** 虚拟主机

***可以用avaliable(可用的)和enabled(已启用的)(具体看上面的命令最后那一列)

enabled与avaliable之间用ln -s命令进行软连接。等于说,模块本身就像是灯,然后命令是开关

---

mysql和php

核心分别是my.cnf以及php.ini

以后详述

2、Linux基础

环境为虚拟机VM中的centOS6以及ssh工具xshell5

快捷键,ctrl+l

-----Linux常用命令(一)-----

我们需要掌握的大概6、70个,以后一共用到的可能会有200个

[root@andy ~]#

用户@主机名 ~当前所在位置(文件夹)#超级用户提示符 $普通用户提示符

注意,linux中的用户不是admin;默认的主机名是localhost;~表示/root,简称家 

[root@andy ~]# cd /root 地址是不变的

普通用户的家目录是二级地址

----命令格式

命令 [选项] [参数]

注意,个别命令不遵守这样的格式;多个选项可以写在一起,比如-au;有简化选项和完整选项,比如-a和-all

---ls:查询目录中文件

ls [] [文件和目录]

-a all 显示所有文件,包括隐藏文件

-l long 显示详细信息,也称为长格式

-d direct 目录属性

-h human 显示人能看懂的大小

-i innode

[root@andy ~]# ls -al
总用量 80
dr-xr-x---. 2 root root 4096 11月 25 05:06 .
dr-xr-xr-x. 24 root root 4096 11月 26 03:41 ..
-rw-------. 1 root root 1272 11月 25 03:55 anaconda-ks.cfg
-rw-------. 1 root root 183 11月 25 05:06 .bash_history
-rw-r--r--. 1 root root 18 5月 20 2009 .bash_logout
-rw-r--r--. 1 root root 176 5月 20 2009 .bash_profile
-rw-r--r--. 1 root root 176 9月 23 2004 .bashrc
-rw-r--r--. 1 root root 100 9月 23 2004 .cshrc
-rw-r--r--. 1 root root 26420 11月 25 03:55 install.log
-rw-r--r--. 1 root root 7572 11月 25 03:52 install.log.syslog
-rw-r--r--. 1 root root 129 12月 4 2004 .tcshrc
-rw-------. 1 root root 768 11月 25 04:20 .viminfo

--ll命令,就是ls -l

--关于长格式

--第一列,权限

-rw-r--r-- 是指权限;默认是10位。

-表示文件类型(-文件 d目录 |软链接文件)——总共有7种,其他用的少,先不管,是系统特殊文件,一般用户不用管,想看的话

[root@andy ~]# ls -l /dev/

后面9位,每3个是一组,分别代表文件的u所有者,g所属组,o其他人三个身份(该文件与三者的权限规定)

(Linux用户组是有相同权限的用户集)

r读,w写,x执行(基本权限就这么三个)

比如rw- u对它具有读写权限

--点儿“.”

代表ACL权限

--数字1

引用计数

--root root

所有者和所属组

--数字

文件大小,单位是字节,用-h选项

[root@andy ~]# ls -lh
总用量 44K
-rw-------. 1 root root 1.3K 11月 25 03:55 anaconda-ks.cfg
-rw-r--r--. 1 root root 26K 11月 25 03:55 install.log
-rw-r--r--. 1 root root 7.4K 11月 25 03:52 install.log.syslog

--日期

最后一次修改时间

--最后、

文件名

文件名以“.”开头的是隐藏文件

-- -d

看目录本身的权限

-- -i

显示i节点,id号

----文件处理命令

建立目录,建立文件啊

---目录处理命令&文件处理命令

目录也是文件,先明确下再。

--建立目录:mkdir

make directory

mkdir -p [目录名]

-p 递归创建,意思就是如果要创建多级目录,要递归创建

[root@andy ~]# mkdir -p japan/cangls

---切换所在目录:cd

cd [目录]

很简单,即可以切很多级,也可以切一级,不输入目录,就直接回家目录

-简化操作

cd 或 cd ~ 回家(~本来就代表家目录)

cd .. 返回上一级目录

cd - 进入上一次目录

cd . 进入当前目录

[root@andy ~]#
[root@andy ~]# cd /etc
[root@andy etc]# cd sysconfig
[root@andy sysconfig]# cd..
-bash: cd..: command not found
[root@andy sysconfig]# cd ..
[root@andy etc]# cd -
/etc/sysconfig
[root@andy sysconfig]# cd ~
[root@andy ~]#

--

相对路径和绝对路径

[root@andy ~]# cd ../usr/local/src
[root@andy src]# cd ../usr/local/src
-bash: cd: ../usr/local/src: 没有那个文件或目录
[root@andy src]# cd /usr/local/src
[root@andy src]# cd /usr/local/src
[root@andy src]#

相对路径,就是相对当前位置来cd

绝对路径,就是从根目录开始找,麻烦但可靠,适合初学者

--关于tab键

补全命令和目录,按键两次,判断正确

--查询所在目录位置:pwd

直接用

--删除空目录:rmdir

remove empty directory

rmdir [目录]

[root@andy ~]# rmdir bols
[root@andy ~]# rmdir japan
rmdir: 删除 "japan" 失败: 目录非空

所以不好用,知道就好

--删除文件或目录:rm

remove

[root@andy ~]# rm japan
rm: 无法删除"japan": 是一个目录
[root@andy ~]# rm -r japan
rm:是否进入目录"japan"? y
rm:是否删除目录 "japan/cangls"?y^Hn^H^H^H
rm:是否删除目录 "japan"?n
[root@andy ~]# rm -rf japan
[root@andy ~]# ls -l
总用量 44
-rw-------. 1 root root 1272 11月 25 03:55 anaconda-ks.cfg
-rw-r--r--. 1 root root 26420 11月 25 03:55 install.log
-rw-r--r--. 1 root root 7572 11月 25 03:52 install.log.syslog
[root@andy ~]#

rm -rf [目录]

如果直接用-rf删除,就没有提问,直接删除了,所以小心使用,甚至有可能把整个系统删除

-r 删除目录

-f 强制

--复制:cp

copy

-r 复制目录

-p -d

-a 相当于-rpd

所以用cp就,cp -a,确保复制的都一样,时间啊什么的

--剪切或改名:mv

move

注意,剪切不加选项

--常见目录作用

[root@andy ~]# cd /
[root@andy /]# ls
bin boot cgroup dev etc home lib lost+found media misc mnt net opt proc root sbin selinux srv sys tmp usr var

先切换到根目录/

这些都是一级目录

bin和sbin,以及usr下的bin和sbin下的都是保存系统命令

/boot 启动目录,保存用户的启动数据

/dev 特殊文件保存目录,不要乱动

/etc 系统的默认的配置文件,以后会经常动的

/home 普通用户的家目录,  /root 超级用户的家目录

/lib 函数库仓库

misc media mnt 空目录,用于挂载,外接其他设备的,自己设定用

proc sys 不能直接操作,是内存的盘符

/tmp 临时目录

/usr 系统资源目录

/var 保存系统可变文档目录

总之,在家目录和/tmp下随便放东西

---链接命令:ln

link

ln -s [源文件] [目标文件]

-s soft 软链接

注意一点:创建链接的根本目的,就是相当于平时的快捷方式

--硬链接

基本上可以理解为,同一个文件的不同的接入点/名字(想象为同一个教室的前后门)

具有同样的i节点和存储block块;删除其中一个,还是可以用

缺点在于,不能跨分区,不能针对目录

[root@andy ~]# ln /root/anaconda-ks.cfg /tmp/ana.hard
[root@andy ~]# ll
总用量 48
-rw-------. 2 root root 1272 11月 25 03:55 anaconda-ks.cfg
-rw-r--r--. 1 root root 26420 11月 25 03:55 install.log
-rw-r--r--. 1 root root 7572 11月 25 03:52 install.log.syslog
drwxr-xr-x. 3 root root 4096 11月 26 04:55 japan
[root@andy ~]# ll /tmp
总用量 92
-rw-------. 1 root root 1272 11月 26 04:55 ana
-rw-------. 2 root root 1272 11月 25 03:55 ana.hard
drwxr-xr-x. 3 root root 4096 11月 26 04:56 japan
-rw-------. 1 root root 81920 11月 26 04:40 whatis.2kxNR9
-rw-------. 1 root root 0 11月 25 03:32 yum.log

基本上是看不出来的,除了引用计数+1了;不过可以看i节点号

[root@andy ~]# ls -li
总用量 48
135177 -rw-------. 2 root root 1273 11月 26 05:32 anaconda-ks.cfg
130564 -rw-r--r--. 1 root root 26420 11月 25 03:55 install.log
130565 -rw-r--r--. 1 root root 7572 11月 25 03:52 install.log.syslog
135180 drwxr-xr-x. 3 root root 4096 11月 26 04:55 japan
[root@andy ~]# ls -li /tmp
总用量 92
550003 -rw-------. 1 root root 1272 11月 26 04:55 ana
135177 -rw-------. 2 root root 1273 11月 26 05:32 ana.hard
550005 drwxr-xr-x. 3 root root 4096 11月 26 04:56 japan
550004 -rw-------. 1 root root 81920 11月 26 04:40 whatis.2kxNR9
522243 -rw-------. 1 root root 0 11月 25 03:32 yum.log
如果删除了某一个文件,引用计数会变回1

但,不推荐创建硬链接:限制多;比较隐蔽,仅i节点——推荐用软~

--软链接

相当于windows的快捷方式

拥有自己的i节点和block块,但是数据块中只保存源文件的文件名和i节点号,没有实际的文件数据(类似存储的是个藏宝图)

软链接的权限都是lrwxrwxrwx

删除源文件,软链接失效(都说是快捷方式了)

修改某一个,另一个也会变

[root@andy ~]# cp -a anaconda-ks.cfg /root/japan
[root@andy ~]# ln -s /root/japan/anaconda-ks.cfg /tmp/an.soft
[root@andy ~]# ll
总用量 48
-rw-------. 2 root root 1273 11月 26 05:32 anaconda-ks.cfg
-rw-r--r--. 1 root root 26420 11月 25 03:55 install.log
-rw-r--r--. 1 root root 7572 11月 25 03:52 install.log.syslog
drwxr-xr-x. 3 root root 4096 11月 26 05:43 japan
[root@andy ~]# ll /tmp
总用量 92
-rw-------. 1 root root 1272 11月 26 04:55 ana
-rw-------. 2 root root 1273 11月 26 05:32 ana.hard
lrwxrwxrwx. 1 root root 27 11月 26 05:44 an.soft -> /root/japan/anaconda-ks.cfg
drwxr-xr-x. 3 root root 4096 11月 26 04:56 japan
-rw-------. 1 root root 81920 11月 26 04:40 whatis.2kxNR9
-rw-------. 1 root root 0 11月 25 03:32 yum.log
[root@andy ~]# ll -i /tmp
总用量 92
550003 -rw-------. 1 root root 1272 11月 26 04:55 ana
135177 -rw-------. 2 root root 1273 11月 26 05:32 ana.hard
533111 lrwxrwxrwx. 1 root root 27 11月 26 05:44 an.soft -> /root/japan/anaconda-ks.cfg
550005 drwxr-xr-x. 3 root root 4096 11月 26 04:56 japan
550004 -rw-------. 1 root root 81920 11月 26 04:40 whatis.2kxNR9
522243 -rw-------. 1 root root 0 11月 25 03:32 yum.log
[root@andy ~]# ll -i
总用量 48
135177 -rw-------. 2 root root 1273 11月 26 05:32 anaconda-ks.cfg
130564 -rw-r--r--. 1 root root 26420 11月 25 03:55 install.log
130565 -rw-r--r--. 1 root root 7572 11月 25 03:52 install.log.syslog
135180 drwxr-xr-x. 3 root root 4096 11月 26 05:43 japan

注意几点,i节点,权限,文件名

另外,软链接中,源文件一定要写绝对路径,否则可能会报错

我自己写的例子少,大家多练习

明天见

买错的电影票,含着泪也得看-LAMP搭建&Linux基础的更多相关文章

  1. 阿里云服务器部署php的laravel项目,在阿里云买ECS 搭建 Linux+Nginx+Mysql+PHP环境的

    在阿里云买ECS的时候选择自己习惯的镜像系统,我一般都是使用Linux Ubuntu,所以,以下的配置都是在Ubuntu 14.04稳定支持版的环境中搭建Linux+Nginx+Mysql+PHP环境 ...

  2. 导入文件 服务器报错,有可能是 开发时候是window 服务器是linux,两个系统的文件系统的/和\是相反的,要注意这块

    导入文件 服务器报错,有可能是 开发时候是window 服务器是linux,两个系统的文件系统的/和\是相反的,要注意这块

  3. SSD接口详解,再也不会买错固态硬盘了

    http://stor.51cto.com/art/201808/582349.htm 硬盘知识科普中,我们提到了SSD的发展史虽短,但是种类和协议比HDD不知道多到哪里去了.因此,本期小编就通过接口 ...

  4. 【Linux基础】mount报错:mount.nfs: Remote I/O error

    问题描述:mount 报错:mount.nfs: Remote I/O error 挂载时需要指明版本,由于NFS服务器有多个版本,V2.V3.V4.而且各版本同时运行,因此挂载时需要说明版本号. 由 ...

  5. 一看便知linux下mysql报错ERROR 1044: Access denied for user: '@localhost' to database 'mysql'

    错误信息:ERROR 1044: Access denied for user: '@localhost' to database 'mysql' linux下解决方案: mysql> use ...

  6. MyBatis操作指南-搭建项目基础环境(基于Java API)含log4j2配置

  7. MyBatis操作指南-搭建项目基础环境(基于XML)含log4j配置

  8. 买了本Delphi面向对象编程思想,正在看,产生些问题。

    1:第33页说,Delphi通过调用类的一个构造函数来建立一个对象的实例,对象至少有一个create()的构造函数,使用时候写MyObject:=TmyObject.create即可.   但是第37 ...

  9. [k8s]kube-dns/dashboard排错历险记(含sa加载用法/集群搭建)

    kube-dns原理 参考: 组件架构看这个就够了 http://cizixs.com/2017/04/11/kubernetes-intro-kube-dns 设置细节看这个就够了 http://b ...

随机推荐

  1. netmiko初窥

    paramiko 和 pexpect在笔记里被跳过 因为,他们都可以被netmiko所取代,不想在他们身上浪费太多时间 补一个地方就是,如果用paramiko遇到了connection莫名自己关闭的情 ...

  2. JavaScript中数组的增删改查

                                               数组的增加 ary.push()   向数组末尾添加元素,返回的是添加后新数组的长度,原有数组改变 ary.uns ...

  3. HTML中input标签的alt属性和title属性的比较

    经常用到这两个属性,但是一直没有总结他们的区别.现在我对他们两个的用法做一下总结: 相同点:他们都会飘出一个小浮层,显示文本内容. 不同点: 1.alt只能是元素的属性,而title即可以是元素的属性 ...

  4. 【初探移动前端开发05】jQuery Mobile (下)

    前言 继续我们移动端的学习,今天到了List相关了. 本文例子请使用手机查看 List列表 在移动设备平台下,由于移动设备屏幕比较小,我们又是用手在上面点击的触屏方式,传统的列表模式在手机上就不太友好 ...

  5. php随机生成指定长度的字符串 可以固定数字 字母 混合

    php 生成随机字符串 可以指定是纯数字 还是纯字母 或者混合的. 可以指定长度的. function rand_zifu($what,$number){ $string=''; for($i = 1 ...

  6. SAP中数字计算时溢出捕获

    CLEAR:g_vol. CATCH SYSTEM-EXCEPTIONS arithmetic_errors = OTHERS = . g_vol = gwa_input-laeng * gwa_in ...

  7. Snort - manual 笔记(一)

    Chapter 1 Snort Overview This manual is based on Writing Snort Rules by Martin Roesch and further wo ...

  8. SharePoint 2013 直接给AD 组赋权限后,AD组里的用户还是登陆不了SharePoint,提示没有权限

    直接给一个all person的AD组赋了个read权限,然后将一个名为“all beijing”的组加到all person组里,但是all beijing组里的人却不能登录sharepoint,提 ...

  9. NSNotificationCenter应用总结

    通常我们在 iOS 中发生什么事件时该做什么是由 Delegate 实现的,例如 View 加载完后会触发 viewDidLoad.  Apple 还为我们提供了另一种通知响应方式,那就是 NSNot ...

  10. java url方法解释

    java 的url类中有很多get方法 以下是获取值的意义 // 首先先看一下wikipedia上关于url的一个描述 //Every HTTP URL conforms to the syntax ...