Do not write, I fear will never write-lamp Foundation, nor-lamp basic _php tutorial

Source: Internet
Author: User
Tags parent directory php mysql phpinfo

Do not write, I fear will never write the-lamp Foundation, nor-lamp Foundation


Hi

After 4 days of baptism of the feast, the whole people think of the secret Tatsu ... Yesterday's lazy, there is no reason for lazy, in short, is the pen to the pro

1. Lamp Configuration under Ubuntu

Basic knowledge of-----ubuntu-----

----Administrator Privileges

For security reasons, Ubuntu does not recommend using the root account for remote logins-forcing the use of other regular accounts

Since the normal account does not have Super Administrator privileges, by default it is not possible to log in with the root account (remote, etc.), so two commands are required

SU (switch User) switch to Super Administrator

sudo (Switch User and do) as a super administrator

There is an essential difference between the two-the former is the "Boss" (root), must use the root password, until exit to exit, the latter is the "younger brother" request the boss to give permission, and is temporary permission, the password only with ordinary on the line

----Preparatory knowledge

Liang@liang-andy:~ $

User name @ Host Name: Current directory user type tag

where $ represents a normal user, #表示超级管理员

---

liang@liang-andy:~$ pwd
/home/liang
~ indicates that it is now in the current user's personal folder, the PWD command can give the actual directory

---

These two commands are shown below: Modifying the root password

liang@liang-andy:~$ sudo passwd root
[sudo] password for Liang:
Enter a new UNIX password:
Re-enter the new UNIX password:
passwd: Password has been successfully updated
liang@liang-andy:~$
Then the SU

liang@liang-andy:~$ su
Password:
root@liang-andy:/home/liang#
Note that the directory path has changed, and there is a #

----Apt-get Software Installation Tool

The main function is to get the software list apt-get update and software installation Apt-get install

Learn----Other necessary commands

http://itlab.idcquan.com/linux/special/linuxcom/

---

Name: ls
  
Usage rights: All users
  
How to use: ls [-ALRTAFR] [name ...]
  
Description: Displays the contents of the specified working directory (lists the files and subdirectories included in the current working directory).
  
Parameters:
  
-a displays all files and directories (LS default starts the file name or directory name as ".") As hidden files, not listed)
-L In addition to the file name, but also the file type, permissions, owners, file size and other information detailed list
-R Displays the files in reverse order (originally alphabetical order)
-T lists the files in the order of establishment time
-A with-a, but not listed "." (current directory) and ".." (Parent directory)
-F adds a symbol after the listed file name, such as an executable file with "*" and a "/" in the directory.
-R If there is a file under the catalogue, the following files are also listed
  
Example:
Lists all files under the current working directory whose names are S, and the newer the following:
Ls-ltr s*
  
List all directories and archive details below the/bin directory:
Ls-lr/bin
  
List all the files and directories under the current working directory; add "/" to the name, and the executable file after the name with "*":
Ls-af

---

LL will list all the file information under the file, including the hidden files, while ls-l only lists the explicit files, stating that the two commands are still not equivalent!

---

Directive Name: LN
  
Usage rights: All users
  
How to use: ln [options] Source dist, where option is in the format:
  
[-BDFINSVF] [-S Backup-suffix] [-v {numbered,existing,simple}]
[--help] [--version] [--]
Note: In the Linux/unix file system, there is a so-called link, we can consider it as the alias of the file, and the link can be divided into two types: Hard link and soft link (symbolic link), hard link means that a file can have multiple names, The soft-link approach is to produce a special file with the content of the file pointing to the location of another file. Hard links exist in the same file system, while soft links can span different file systems.
LN Source Dist is the generation of a link (dist) to the source, and the use of a hard or soft link is determined by the parameter.
  
Whether a hard link or a soft link will not copy the original file, it will only occupy a very small amount of disk space.
  
Parameters:
  
-F: The link will first delete the file with the Dist file-D: Allow the System Manager to hard-link their own directory-I: When deleting the file with the dist file with the first query-N: In the soft link, the dist as a generic file-s: Soft link (symbolic lin K)-V: Displays its file name before the link-B: Files that will be overwritten or deleted at the end of the link are backed up by the-s SUFFIX: Add the backed up file with SUFFIX's tail-V method: Specify how the Backup--help: Display Auxiliary description--version: Display version This
Example:
The file yy produces a symbolic link:zz
Ln-s yy ZZ
  
To create a hard link:zz file yy
ln yy XX

---

Name: CD
  
Usage rights: All users
  
How to use: CD [DirName]
  
Description: Transform the working directory to DirName. Where dirName notation can be either an absolute path or a relative path. If the directory name is omitted, it is transformed to the user's home directory (that is, the directory where login was first).
  
In addition, "~" is also expressed as the meaning of home directory, "." is the current directory, "." indicates the current directory location of the previous level directory.
  
Example: Jump to/usr/bin/:
Cd/usr/bin
  
Jump to your home directory:
CD ~
  
Jump to the top two of the current directory:
Cd.. /..
  
CD-Returns the directory in front of the current directory

Name: CP
  
Usage rights: All users
  
How to use:
  
CP [Options] Source Dest
CP [options] source ... directory
  
Note: Copy one file to another file, or copy several files to another directory. (copy)
  
Parameters:
  
-A as far as possible file status, permissions and other information are reproduced as original.
-R If the source contains a directory name, the files under the directory are also copied to the destination.
-F If a destination already has a file with the same file name, it should be deleted before copying.
Example:
Copy the file AAA (already present) and name the BBB:
CP AAA BBB

Also known as sudo cp document_a Document_b
  
Copy all C-language programs to the finished subdirectory:
CP *.c finished

---

Name: MV
  
Usage rights: All users
  
How to use:
  
MV [options] Source Dest
MV [options] Source ... directory
Note: Move one file to another file, or move several files to another directory.
Parameter:-I if the destination already has the same name file, first ask whether overwrite the old file.
  
Example:
  
Rename file aaa to BBB:
MV AAA BBB
  
Move all C language programs to the finished subdirectory:
Mv-i *.c

---

Name: RM
  
Usage rights: All users
  
How to use: RM [options] name ...
  
Description: Delete files and directories.
  
Parameters:
  
-I ask for confirmation before deleting.
-F Even if the original file attribute is set to read-only, it is deleted directly without confirmation.
-R the directory and the following files are also deleted.
Example:
Delete all C language files; Ask for confirmation before deleting:
Rm-i *.c
  
Delete all the files in the finished subdirectory and subdirectories:
Rm-r finished

---

Name: mkdir
  
Usage rights: All users with appropriate permissions to the current directory
  
Mode of Use: mkdir [-P] DirName
  
Description: Create a subdirectory named DirName.
  
Parameter:-p ensure that the directory name exists and that it does not exist.
  
Example:
  
Under working directory, create a subdirectory called AAA:
mkdir AAA
  
In the BBB directory under the working directory, create a subdirectory named Test. If the BBB directory does not already exist, create one. (Note: If this example does not add-p and the original BBB directory does not exist, an error is generated.) )
Mkdir-p Bbb/test

---

Name: RmDir
  
Usage rights: All users with appropriate permissions to the current directory
  
Mode of Use: rmdir [-P] DirName
  
Description: Delete the empty directory.
  
Parameter:-P is deleted when the subdirectory is deleted and the directory becomes empty.
  
Example:
  
Delete the subdirectory named AAA under the working directory:
RmDir AAA
  
In the BBB directory under the working directory, delete the subdirectory named Test. If the BBB directory becomes an empty directory after the Test is deleted, BBB is also deleted.
Rmdir-p Bbb/test

---

chmod----Changing the access mode of one or more files (mode) chmod [options] mode files This feature can only be used by a file owner or a privileged user to change the file access mode. Mode can be expressed in digital form or in the form of who opcode permission. Who is optional and the default is a (all users). Only one opcode (opcode) can be selected. Multiple mode can be specified, separated by commas. Options: -c,--changes only the information of the changed file is output -f,--silent,--quiet users who do not notify the file when chmod cannot change the file mode --help output help information. -r,--recursive recursively traverse subdirectories to modify all files and subdirectories in the directory --reference=filename to set permissions by referencing the permissions of the filename -v,--verbose output information for each file, regardless of whether the modification was successful --version output version information. W.H.O. u User g Group o other a all Users (default) opcode + Increase Permissions - Delete Permissions = Reassign Permissions Permission R Read W Write x Execution s set the ID number of the user (or group) T set the sticky bit (sticky bit) to prevent files or directories from being deleted by the non-owner u user's current permissions g Current permissions for the group o Current permissions for other users as a choice, most of us represent permissions in the form of three-bit octal digits, the first one specifying the permissions of the master, the second specifying the group permissions, and the third specifying the permissions of the other user, each of which is determined by 4 (read), 2 (write), 1 (executed), and three numeric values. If 6 (4+2) represents a read-write right, 7 (4+2+1) has read, write, and execute permissions. You can also set the fourth bit, which is in front of the three-bit permission sequence, and the fourth digit value is 4,2,1, which means the following: 4, the user ID is set at execution time, and is used to authorize the file owner-based process instead of the user who created the process. 2, when executed, sets the user group ID, which is used to authorize the process based on the group of files, rather than on the user who created the process. 1, set the sticky bit. Example: $ chmod u+x file adds execute permission to the owner of file $ chmod 751 file assigns read, write, execute (7) permissions to the owner of file, assigns read, execute (5) permissions to the group where the file resides, and assigns permissions to other users to execute (1) $ chmod Another form of the example on U=rwx,g=rx,o=x file $ chmod =r file to assign Read permissions to all users $ chmod 444 file above example $ chmod a-wx,a+r file above example $ chmod-r u+r directory recursively reads permissions for the owner of all files and subdirectories in directory directory $ chmod 4755 sets the ID to assign read, write, and execute permissions to the owner, assigning read and Execute permissions to the group and other users.

-----Build Lamp Environment-----

----Installing Apache MySQL PHP with Apt-get

Apt-get has a feature, is that the installation of things will be related to some of the things together to install

---

liang@liang-andy:~$ sudo apt-get install apache2

Install Apache, then enter the password (normal user) and Y, and enter the following command to indicate that the installation was successful
liang@liang-andy:~$ apache2-v
Server version:apache/2.4.7 (Ubuntu)
Server built:oct 14 2015 14:18:49
Then enter ifconfig to get the IP address

(I am here) 192.168.1.100 Get It works page validation success
---

Install PHP

liang@liang-andy:~$ sudo apt-get install php5
liang@liang-andy:~$ php5-v
PHP 5.5.9-1ubuntu4.14 (CLI) (built:oct 28 2015 01:32:13)
Copyright (c) 1997-2014 the PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
With Zend Opcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
Then load/check php5.load this PHP implementation of the apache2 operation of the module (first, regardless of why, first do so)
liang@liang-andy:~$ Cat/etc/apache2/mods-enabled/php5.load
LoadModule php5_module/usr/lib/apache2/modules/libphp5.so
---

Install MySQL

liang@liang-andy:~$ sudo apt-get install Mysql-server
This does not need to verify the version, but also to check PHP operation MySQL Module

liang@liang-andy:~$ Cat/etc/php5/mods-available/mysql.ini
Cat:/etc/php5/conf.d/mysql.ini: No file or directory

Note that the Ubuntu I use here is the 14LS version, and the 12 cat directory is not the same/etc/php5/conf.d/mysql.ini

This is because PHP does not install MySQL extension by default, so it needs to be installed manually

liang@liang-andy:~$ sudo apt-get install Php5-mysql
liang@liang-andy:~$ Cat/etc/php5/mods-available/mysql.ini
; Configuration for PHP MySQL module
; Priority=20
Extension=mysql.so
This will do it, then restart MySQL and apache2

liang@liang-andy:~$ sudo service MySQL restart
liang@liang-andy:~$ sudo service apache2 restart
---

One-time installation: The above is a sub-process, the following a single-time installation

sudo apt-get install apache2 php5 mysql-server php5-mysql

----Creating Phpinfo Probes

First install Vim

sudo apt-get install vim

Then switch to the PHP www folder, using the CD command

Cd/var/www/html (Version 14.4)

Then create a PHP file here

sudo vim info.php

Write PHP code

echo mysql_connect (' localhost ', ' root ', ' hanhan123 ')? ' Hoho ': ' WTF ';

Phpinfo ();
Then the ESC key, enter: Wq Save exit

http://192.168.1.100/info.php Browser Input Validation results

Linux so it hurts, I don't write it, I'll see you tomorrow

http://www.bkjia.com/PHPjc/1074253.html www.bkjia.com true http://www.bkjia.com/PHPjc/1074253.html techarticle Do not write, I am afraid will never write the-lamp Foundation, nor-lamp Basic hi experienced the baptism of 4 days feast, the whole people think of the secret Tatsu ... Yesterday's lazy, is no reason lazy, in short ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.