hi
I never mentioned that my roommate had a birthday treat last Friday. We had a good time eating and drinking at Longhu, and we talked about it on the way back. We agreed to watch the last blockbuster movie of the year together this week, The Martian. Who knew that I had bad eyesight and bought the movie at the wrong time. . . I moved up my Saturday appointment to this afternoon, madan, I couldn’t even send it off, so I had to go and see it
1. LAMP
-----Building a LAMP environment (2)-----
----Add common extensions to PHP
Go to the Internet to find the gd and curl commands. This is too long
liang@liang-andy:~$ sudo apt-get install php5-gd curl libcurl3-dev php5-curl
It takes a bit long
To verify, you must first restart the apache2 service, and then go to the probe file mentioned last time, that is, check if there is anything in phpinfo
----filezilla
ssh tool, manage server files
-----LAMP environment configuration optimization (1)-----
----LAMP environment file overview
Common sense
/etc--Ubuntu system configuration file directory. Generally, the configuration files of software installed through the apt-get command are here
LAMP is here too
/etc/apache2
/etc/mysql
/etc/php5
----Detailed explanation of environment files
---
Open the apache2 file list first
liang@liang-andy:~$ cd /etc/apache2
liang@liang-andy:/etc/apache2$ ll
Total usage 96
drwxr-xr-x 8 root root 4096 11 November 23 19:08 ./
drwxr-xr-x 134 root root 12288 November 25 12:37 ../
-rw-r--r-- 1 root root 7115 January 7 2014 apache2. conf
drwxr-xr-x 2 root root 4096 November 23 19:08 conf-available/
drwxr-xr-x 2 root root 4096 November 23 19:08 conf-enabled/
-rw -r--r-- 1 root root 1782 January 3 2014 envvars
-rw-r--r-- 1 root root 31063 January 3 2014 magic
drwxr-xr-x 2 root root 12288 11 November 23 19:21 mods-available/
drwxr-xr-x 2 root root 4096 November 23 19:21 mods-enabled/
-rw-r--r-- 1 root root 320 January 7 2014 ports.conf
drwxr-xr-x 2 root root 4096 November 23 19:08 sites-available/
drwxr-xr-x 2 root root 4096 November 23 19:08 sites-enabled/
There is apache.conf in apache2, which is the general entrance of the configuration file. It can include many other configuration files - it is more flexible to configure, and the total file is not very big
Core configuration: mods-*** apache module; sites-*** virtual host
***You can use available (available) and enabled (enabled) (see the last column of the command above for details)
Use the ln -s command to make a soft connection between enabled and avaliable. It is equivalent to saying that the module itself is like a light, and the command is a switch
---
mysql and php
The core are my.cnf and php.ini
More details later
2. Linux basics
The environment is centOS6 in the virtual machine VM and the ssh tool xshell5
Shortcut key, ctrl l
-----Common Linux commands (1)-----
We need to master about 6 or 70, and there may be a total of 200 used in the future
[root@andy ~]#
User@hostname ~Current location (folder) #Super user prompt $Normal user prompt
Note that the user in Linux is not admin; the default host name is localhost; ~ means /root, abbreviated as home
[root@andy ~]# cd /root address is unchanged
The home directory of ordinary users is the secondary address
----Command format
Command [options] [parameters]
Note that individual commands do not follow this format; multiple options can be written together, such as -au; there are simplified options and complete options, such as -a and -all
---ls: Query files in the directory
ls [] [files and directories]
-a all Show all files, including hidden files
-l long displays detailed information, also known as long format
-d direct directory attribute
-h human displays the size that humans can understand
-i innode
[root@andy ~]# ls -al
Total usage 80
dr-xr-x---. 2 root root 4096 November 25 05:06 .
dr-xr-xr -x. 24 root root 4096 November 26 03:41 ..
-rw-------. 1 root root 1272 November 25 03:55 anaconda-ks.cfg
-rw-- -----. 1 root root 183 November 25 05:06 .bash_history
-rw-r--r--. 1 root root 18 May 20 2009 .bash_logout
-rw-r-- r--. 1 root root 176 May 20 2009 .bash_profile
-rw-r--r--. 1 root root 176 Sep 23 2004 .bashrc
-rw-r--r--. 1 root root 100 September 23 2004 .cshrc
-rw-r--r--. 1 root root 26420 November 25 03:55 install.log
-rw-r--r--. 1 root root 7572 November 25 03:52 install.log.syslog
-rw-r--r--. 1 root root 129 December 4 2004 .tcshrc
-rw------. 1 root root 768 November 25 04:20 .viminfo
--ll command, which is ls -l
--About long format
--First column, permissions
-rw-r--r-- refers to permissions; the default is 10 digits.
-Indicates the file type (-file d directory | soft link file) - there are 7 types in total. Others are rarely used, so ignore them for now. They are system special files. General users don’t need to worry about them. If you want to see them
[root@andy ~]# ls -l /dev/
The next 9 digits, every 3 are in a group, representing the u owner of the file, the group to which g belongs, and o other people's three identities (the file and the permissions regulations of the three)
(Linux user group is a set of users with the same permissions)
r read, w write, x execute (these are the three basic permissions)
For example, rw-u has read and write permissions on it
--dot "."
Represents ACL permissions
--Number 1
Reference Count
--root root
Owner and group
--Number
File size in bytes, use the -h option
[root@andy ~]# ls -lh
Total usage 44K
-rw-------. 1 root root 1.3K November 25 03:55 anaconda-ks.cfg
-rw-r--r--. 1 root root 26K November 25 03:55 install.log
-rw-r--r--. 1 root root 7.4K November 25 03:52 install. log.syslog
--Date
Last modification time
--Finally,
File name
File names starting with "." are hidden files
-- -d
Look at the permissions of the directory itself
-- -i
Display i node, id number
----File processing commands
Create directories and files
---Directory processing commands & file processing commands
Directories are also files, please clarify them first.
--Create directory: mkdir
make directory
mkdir -p [directory name]
-p creates recursively, which means that if you want to create a multi-level directory, create it recursively
[root@andy ~]# mkdir -p japan/cangls
---Switch directory: cd
cd [directory]
It’s very simple. You can switch to many levels or one level. You don’t need to enter the directory and just go back to the directory
-Simplified operation
cd or cd ~ Home (~ originally represents the home directory)
cd .. Return to the previous directory
cd - enter the last directory
cd . Enter the current directory
[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 ~]#
--
Relative paths and absolute paths
[root@andy ~]# cd ../usr/local/src
[root@andy src]# cd ../usr/local/src
-bash: cd: ../usr /local/src: No such file or directory
[root@andy src]# cd /usr/local/src
[root@andy src]# cd /usr/local/src
[root@ andy src]#
Relative path means cd relative to the current location
The absolute path is to start from the root directory, which is troublesome but reliable, suitable for beginners
--About the tab key
Complete the command and directory, press the key twice, the judgment is correct
--Query the directory location: pwd
Use directly
--Delete empty directories: rmdir
remove empty directory
rmdir [directory]
[root@andy ~]# rmdir bols
[root@andy ~]# rmdir japan
rmdir: Failed to delete "japan": Directory is not empty
So it’s not easy to use, just know it
--Delete files or directories: rm
remove
[root@andy ~]# rm japan
rm: Unable to delete "japan": It is a directory
[root@andy ~]# rm -r japan
rm: Whether to enter the directory "japan" "? y
rm: Delete the directory "japan/cangls"? y^Hn^H^H^H
rm: Delete directory "japan"? n
[root@andy ~]# rm -rf japan
[root@andy ~]# ls -l
Total usage 44
-rw-------. 1 root root 1272 November 25 03:55 anaconda-ks.cfg
-rw-r--r--. 1 root root 26420 November 25 03:55 install.log
-rw-r--r-- . 1 root root 7572 November 25 03:52 install.log.syslog
[root@andy ~]#
rm -rf [directory]
If you delete directly with -rf, it will be deleted directly without asking any questions, so use it with caution, it may even delete the entire system
-r delete directory
-f force
--Copy: cp
copy
-r copy directory
-p -d
-a is equivalent to -rpd
So just use cp, cp -a, make sure the copies are the same, time and so on
--Cut or rename: mv
move
Note that there are no options for cutting
--Common directory functions
[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
Switch to the root directory first/
These are first-level directories
bin and sbin, as well as bin and sbin under usr, are all system saving commands
/boot startup directory, saves the user’s startup data
/dev special file storage directory, do not touch it
/etc The default configuration file of the system, which will be changed frequently in the future
/home is the home directory of ordinary users, /root is the home directory of super users
/lib function library warehouse
misc media mnt empty directory, used for mounting, for connecting to other devices, you can set it yourself
proc sys cannot be operated directly, it is the drive letter of the memory
/tmp temporary directory
/usr system resource directory
/var saves the system variable document directory
In short, just put whatever you want in the home directory and /tmp
---Link command: ln
link
ln -s [source file] [destination file]
-s soft soft link
Note: the fundamental purpose of creating a link is to act as a daily shortcut
--hard link
Basically, it can be understood as different access points/names for the same file (imagine the front and back doors of the same classroom)
has the same i-node and storage block; if you delete one of them, you can still use
The disadvantage is that it cannot span partitions and cannot target directories
[root@andy ~]# ln /root/anaconda-ks.cfg /tmp/ana.hard
[root@andy ~]# ll
Total usage 48
-rw--- ----. 2 root root 1272 November 25 03:55 anaconda-ks.cfg
-rw-r--r--. 1 root root 26420 November 25 03:55 install.log
- rw-r--r--. 1 root root 7572 November 25 03:52 install.log.syslog
drwxr-xr-x. 3 root root 4096 November 26 04:55 japan
[root@ andy ~]# ll /tmp
Total usage 92
-rw-------. 1 root root 1272 November 26 04:55 ana
-rw-------. 2 root root 1272 November 25 03:55 ana.hard
drwxr-xr-x. 3 root root 4096 November 26 04:56 japan
-rw-------. 1 root root 81920 November 26 04:40 whatis.2kxNR9
-rw-------. 1 root root 0 November 25 03:32 yum.log
It’s basically invisible, except for the reference count of 1; but you can see the i-node number
[root@andy ~]# ls -li
Total usage 48
135177 -rw-------. 2 root root 1273 November 26 05:32 anaconda-ks.cfg
130564 -rw-r--r--. 1 root root 26420 November 25 03:55 install.log
130565 -rw-r--r--. 1 root root 7572 November 25 03:52 install .log.syslog
135180 drwxr-xr-x. 3 root root 4096 November 26 04:55 japan
[root@andy ~]# ls -li /tmp
Total usage 92
550003 -rw-------. 1 root root 1272 November 26 04:55 ana
135177 -rw-------. 2 root root 1273 November 26 05:32 ana.hard
550005 drwxr-xr-x. 3 root root 4096 November 26 04:56 japan
550004 -rw-------. 1 root root 81920 November 26 04:40 whatis.2kxNR9
522243 -rw-------. 1 root root 0 November 25 03:32 yum.log
If a file is deleted, the reference count will change back to 1
However, it is not recommended to create hard links: many restrictions; relatively hidden, only i nodes - soft links are recommended~
--soft link
Equivalent to windows shortcut
It has its own i-node and block, but the data block only stores the file name and i-node number of the source file, and there is no actual file data (similar to a treasure map stored)
The permissions of soft links are all lrwxrwxrwx
Delete the source file and the soft link will become invalid (it is said to be a shortcut)
Modify one and the other will also change
[root@andy ~]# cp -a anaconda-ks.cfg /root/japan
[root@andy ~]# ln -s /root/japan/anaconda-ks.cfg /tmp/an. soft
[root@andy ~]# ll
Total usage 48
-rw-------. 2 root root 1273 November 26 05:32 anaconda-ks.cfg
- rw-r--r--. 1 root root 26420 November 25 03:55 install.log
-rw-r--r--. 1 root root 7572 November 25 03:52 install.log.syslog
drwxr-xr-x. 3 root root 4096 November 26 05:43 japan
[root@andy ~]# ll /tmp
Total usage 92
-rw------ -. 1 root root 1272 November 26 04:55 ana
-rw-------. 2 root root 1273 November 26 05:32 ana.hard
lrwxrwxrwx. 1 root root 27 November 26 05:44 an.soft -> /root/japan/anaconda-ks.cfg
drwxr-xr-x. 3 root root 4096 November 26 04:56 japan
-rw----- --. 1 root root 81920 November 26 04:40 whatis.2kxNR9
-rw-------. 1 root root 0 November 25 03:32 yum.log
[root@andy ~ ]# ll -i /tmp
Total usage 92
550003 -rw-------. 1 root root 1272 November 26 04:55 ana
135177 -rw------. -. 2 root root 1273 November 26 05:32 ana.hard
533111 lrwxrwxrwx. 1 root root 27 November 26 05:44 an.soft -> /root/japan/anaconda-ks.cfg
550005 drwxr-xr-x. 3 root root 4096 November 26 04:56 japan
550004 -rw-------. 1 root root 81920 November 26 04:40 whatis.2kxNR9
522243 - rw-------. 1 root root 0 November 25 03:32 yum.log
[root@andy ~]# ll -i
Total usage 48
135177 -rw--- ----. 2 root root 1273 November 26 05:32 anaconda-ks.cfg
130564 -rw-r--r--. 1 root root 26420 November 25 03:55 install.log
130565 -rw-r--r--. 1 root root 7572 November 25 03:52 install.log.syslog
135180 drwxr-xr-x. 3 root root 4096 November 26 05:43 japan
Note a few points, i node, permissions, file name
In addition, in soft links, the source file must have an absolute path, otherwise an error may be reported
I wrote few examples myself, everyone should practice more
See you tomorrow