


I bought the wrong movie ticket and had to watch it with tears in my eyes - LAMP setup & Linux basics, movie tickets-lamp
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

PHP remains important in modern web development, especially in content management and e-commerce platforms. 1) PHP has a rich ecosystem and strong framework support, such as Laravel and Symfony. 2) Performance optimization can be achieved through OPcache and Nginx. 3) PHP8.0 introduces JIT compiler to improve performance. 4) Cloud-native applications are deployed through Docker and Kubernetes to improve flexibility and scalability.

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP and Python each have their own advantages and are suitable for different scenarios. 1.PHP is suitable for web development and provides built-in web servers and rich function libraries. 2. Python is suitable for data science and machine learning, with concise syntax and a powerful standard library. When choosing, it should be decided based on project requirements.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

The reasons why PHP is the preferred technology stack for many websites include its ease of use, strong community support, and widespread use. 1) Easy to learn and use, suitable for beginners. 2) Have a huge developer community and rich resources. 3) Widely used in WordPress, Drupal and other platforms. 4) Integrate tightly with web servers to simplify development deployment.

PHP remains a powerful and widely used tool in modern programming, especially in the field of web development. 1) PHP is easy to use and seamlessly integrated with databases, and is the first choice for many developers. 2) It supports dynamic content generation and object-oriented programming, suitable for quickly creating and maintaining websites. 3) PHP's performance can be improved by caching and optimizing database queries, and its extensive community and rich ecosystem make it still important in today's technology stack.

In PHP, weak references are implemented through the WeakReference class and will not prevent the garbage collector from reclaiming objects. Weak references are suitable for scenarios such as caching systems and event listeners. It should be noted that it cannot guarantee the survival of objects and that garbage collection may be delayed.

The \_\_invoke method allows objects to be called like functions. 1. Define the \_\_invoke method so that the object can be called. 2. When using the $obj(...) syntax, PHP will execute the \_\_invoke method. 3. Suitable for scenarios such as logging and calculator, improving code flexibility and readability.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Chinese version
Chinese version, very easy to use