zoukankan      html  css  js  c++  java
  • 买错的电影票,含着泪也得看-LAMP搭建&Linux基础

     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节点,权限,文件名

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

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

    明天见

  • 相关阅读:
    Powerful Bash-style command line editing for cmd.exe
    VBA Code for Word Navigation Pane 【failed】 view-showheading-method-word
    network lab simulator
    Global Git ignore
    hosts 持续更新
    TC Hangs when using quick search extended on win10 (1703)
    mybatis缓存机制
    web网上书店总结(jsp+servlet)
    Spring AOP之多切面运行顺序
    C语言实现蛇形矩阵
  • 原文地址:https://www.cnblogs.com/andy1202go/p/4994314.html
Copyright © 2011-2022 走看看