Table of Contents
再不写,我怕就再也不写了-LAMP基础,也不-lamp基础
Home php教程 php手册 再不写,我怕就再也不写了-LAMP基础,也不-lamp基础

再不写,我怕就再也不写了-LAMP基础,也不-lamp基础

Jun 13, 2016 am 08:50 AM
Write Base

再不写,我怕就再也不写了-LAMP基础,也不-lamp基础

  hi

经历了4天大餐的洗礼,整个人都思密达了。。。昨天的懒,是没有原因的懒,总之就是该提笔了亲

1、Ubuntu下的LAMP配置

-----Ubuntu基础知识-----

----管理员权限

出于安全,Ubuntu不推荐使用root账户远程登录-强制使用其他普通账户

由于普通账户没有超级管理员权限,默认情况下又不能使用root账户登录(远程等),所以需要用到这么两条命令

su(Switch User)切换到超级管理员

sudo(Switch User and DO)以超级管理员身份执行

两者是有本质区别的-前者是“老大”(root)出马,必须用root密码,直到exit才退出;后者是“小弟”请求老大给予准许,并且是临时的权限,密码只用普通的就行

----预备知识

liang@liang-andy:~             $

用户名@主机名:当期目录 用户类型标记

其中,$表示普通用户,#表示超级管理员

---

liang@liang-andy:~$ pwd
/home/liang
~表示现在正处于当前用户的个人文件夹中,pwd命令可以给出实际目录

---

下面演示这两个命令:修改root密码

liang@liang-andy:~$ sudo passwd root
[sudo] password for liang:
输入新的 UNIX 密码:
重新输入新的 UNIX 密码:
passwd:已成功更新密码
liang@liang-andy:~$
然后是su

liang@liang-andy:~$ su
密码:
root@liang-andy:/home/liang#
注意看目录路径已经变了,还有就是#

----apt-get软件安装工具

主要作用就是获取软件列表apt-get update和软件安装apt-get install

----其他必要命令学习

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

---

名称 : ls
  
  使用权限 : 所有使用者
  
  使用方式 : ls [-alrtAFR] [name...]
  
  说明 : 显示指定工作目录下之内容(列出目前工作目录所含之档案及子目录)。
  
  参数 :
  
  -a 显示所有档案及目录 (ls内定将档案名或目录名称开头为"."的视为隐藏档,不会列出)
  -l 除档案名称外,亦将档案型态、权限、拥有者、档案大小等资讯详细列出
  -r 将档案以相反次序显示(原定依英文字母次序)
  -t 将档案依建立时间之先后次序列出
  -A 同 -a ,但不列出 "." (目前目录) 及 ".." (父目录)
  -F 在列出的档案名称后加一符号;例如可执行档则加 "*", 目录则加 "/"
  -R 若目录下有档案,则以下之档案亦皆依序列出
  
  范例:
  列出目前工作目录下所有名称是 s 开头的档案,愈新的排愈后面 :
   ls -ltr s*
  
  将 /bin 目录以下所有目录及档案详细资料列出 :
   ls -lR /bin
  
  列出目前工作目录下所有档案及目录;目录于名称后加 "/", 可执行档于名称后加 "*" :
   ls -AF

---

ll会列出该文件下的所有文件信息,包括隐藏的文件,而ls -l只列出显式文件,说明这两个命令还是不等同的!

---

  指令名称 : ln
  
  使用权限 : 所有使用者
  
  使用方式 : ln [options] source dist,其中 option 的格式为 :
  
  [-bdfinsvF] [-S backup-suffix] [-V {numbered,existing,simple}]
  [--help] [--version] [--]
   说明 : Linux/Unix 档案系统中,有所谓的连结(link),我们可以将其视为档案的别名,而连结又可分为两种 : 硬连结(hard link)与软连结(symbolic link),硬连结的意思是一个档案可以有多个名称,而软连结的方式则是产生一个特殊的档案,该档案的内容是指向另一个档案的位置。硬连结是存在同一个档 案系统中,而软连结却可以跨越不同的档案系统。
  ln source dist 是产生一个连结(dist)到 source,至于使用硬连结或软链结则由参数决定。
  
  不论是硬连结或软链结都不会将原本的档案复制一份,只会占用非常少量的磁碟空间。
  
  参数 :
  
   -f : 链结时先将与 dist 同档名的档案删除-d : 允许系统管理者硬链结自己的目录-i : 在删除与 dist 同档名的档案时先进行询问-n : 在进行软连结时,将 dist 视为一般的档案-s : 进行软链结(symbolic link)-v : 在连结之前显示其档名-b : 将在链结时会被覆写或删除的档案进行备份-S SUFFIX : 将备份的档案都加上 SUFFIX 的字尾-V METHOD : 指定备份的方式--help : 显示辅助说明--version : 显示版本
  范例 :
  将档案 yy 产生一个 symbolic link : zz
   ln -s yy zz
  
  将档案 yy 产生一个 hard link : zz
   ln yy xx

---

  名称 : cd
  
  使用权限 : 所有使用者
  
  使用方式 : cd [dirName]
  
  说明 : 变换工作目录至 dirName。 其中 dirName 表示法可为绝对路径或相对路径。若目录名称省略,则变换至使用者的 home directory (也就是刚 login 时所在的目录)。
  
  另外,"~" 也表示为 home directory 的意思,"." 则是表示目前所在的目录,".." 则表示目前目录位置的上一层目录。
  
  范例 : 跳到 /usr/bin/ :
   cd /usr/bin
  
  跳到自己的 home directory :
   cd ~
  
  跳到目前目录的上上两层 :
   cd ../..
  
   cd - 返回进入当前目录前所在目录

 

 

名称:cp
  
  使用权限:所有使用者
  
  使用方式:
  
  cp [options] source dest
  cp [options] source... directory
  
  说明:将一个档案拷贝至另一档案,或将数个档案拷贝至另一目录。 (copy)
  
  参数:
  
  -a 尽可能将档案状态、权限等资料都照原状予以复制。
  -r 若 source 中含有目录名,则将目录下之档案亦皆依序拷贝至目的地。
  -f 若目的地已经有相同档名的档案存在,则在复制前先予以删除再行复制。
  范例:
  将档案 aaa 复制(已存在),并命名为 bbb :
   cp aaa bbb

       也就是 sudo cp document_A document_B
  
  将所有的C语言程序拷贝至 Finished 子目录中 :
   cp *.c Finished

---

  名称:mv
  
  使用权限:所有使用者
  
  使用方式:
  
  mv [options] source dest
  mv [options] source... directory
  说明:将一个档案移至另一档案,或将数个档案移至另一目录。
  参数:-i 若目的地已有同名档案,则先询问是否覆盖旧档。
  
  范例:
  
  将档案 aaa 更名为 bbb :
   mv aaa bbb
  
  将所有的C语言程序移至 Finished 子目录中 :
   mv -i *.c

---

  名称:rm
  
  使用权限:所有使用者
  
  使用方式:rm [options] name...
  
  说明:删除档案及目录。
  
  参数:
  
  -i 删除前逐一询问确认。
  -f 即使原档案属性设为唯读,亦直接删除,无需逐一确认。
  -r 将目录及以下之档案亦逐一删除。
  范例:
  删除所有C语言程序档;删除前逐一询问确认 :
   rm -i *.c
  
  将 Finished 子目录及子目录中所有档案删除 :
   rm -r Finished

---

  名称: mkdir
  
  使用权限:于目前目录有适当权限的所有使用者
  
  使用方式:mkdir [-p] dirName
  
  说明:建立名称为 dirName 之子目录。
  
  参数:-p 确保目录名称存在,不存在的就建一个。
  
  范例:
  
  在工作目录下,建立一个名为 AAA 的子目录 :
   mkdir AAA
  
  在工作目录下的 BBB 目录中,建立一个名为 Test 的子目录。若 BBB 目录原本不存在,则建立一个。(注:本例若不加 -p,且原本 BBB目录不存在,则产生错误。)
   mkdir -p BBB/Test

---

  名称:rmdir
  
  使用权限:于目前目录有适当权限的所有使用者
  
  使用方式: rmdir [-p] dirName
  
  说明: 删除空的目录。
  
  参数: -p 是当子目录被删除后使它也成为空目录的话,则顺便一并删除。
  
  范例:
  
  将工作目录下,名为 AAA 的子目录删除 :
   rmdir AAA
  
  在工作目录下的 BBB 目录中,删除名为 Test 的子目录。若 Test 删除后,BBB 目录成为空目录,则 BBB 亦予删除。
   rmdir -p BBB/Test

---

chmod----改变一个或多个文件的存取模式(mode)   chmod [options] mode files   只能文件属主或特权用户才能使用该功能来改变文件存取模式。mode可以是数字形式或以who opcode permission形式表示。who是可选的,默认是a(所有用户)。只能选择一个opcode(操作码)。可指定多个mode,以逗号分开。   options:   -c,--changes 只输出被改变文件的信息   -f,--silent,--quiet 当chmod不能改变文件模式时,不通知文件的用户   --help 输出帮助信息。   -R,--recursive 可递归遍历子目录,把修改应到目录下所有文件和子目录   --reference=filename 参照filename的权限来设置权限   -v,--verbose 无论修改是否成功,输出每个文件的信息   --version 输出版本信息。   who   u 用户   g   o 其它   a 所有用户(默认)   opcode   + 增加权限   - 删除权限   = 重新分配权限   permission   r   w   x 执行   s 设置用户(或组)的ID号   t 设置粘着位(sticky bit),防止文件或目录被非属主删除   u 用户的当前权限   g 组的当前权限   o 其他用户的当前权限   作为选择,我们多数用三位八进制数字的形式来表示权限,第一位指定属主的权限,第二位指定组权限,第三位指定其他用户的权限,每位通过4(读)、2(写)、1(执行)三种数值的和来确定权限。如6(4+2)代表有读写权,7(4+2+1)有读、写和执行的权限。   还可设置第四位,它位于三位权限序列的前面,第四位数字取值是4,2,1,代表意思如下:   4,执行时设置用户ID,用于授权给基于文件属主的进程,而不是给创建此进程的用户。   2,执行时设置用户组ID,用于授权给基于文件所在组的进程,而不是基于创建此进程的用户。   1,设置粘着位。   实例:   $ chmod u+x file                      给file的属主增加执行权限 $ chmod 751 file                      给file的属主分配读、写、执行(7)的权限,给file的所在组分配读、执行(5)的权限,给其他用户分配执行(1)的权限 $ chmod u=rwx,g=rx,o=x file      上例的另一种形式 $ chmod =r file                     为所有用户分配读权限 $ chmod 444 file                   同上例 $ chmod a-wx,a+r   file          同上例 $ chmod -R u+r directory           递归地给directory目录下所有文件和子目录的属主分配读的权限 $ chmod 4755                            设置用ID,给属主分配读、写和执行权限,给组和其他用户分配读、执行的权限。

-----搭建LAMP环境-----

----用apt-get安装Apache MySQL PHP

apt-get有个特性,就是安装东西会把相关的一些东西一起装

---

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

安装apache,然后输入密码(普通用户)以及y,输入以下命令,表示安装成功
liang@liang-andy:~$ apache2 -v
Server version: Apache/2.4.7 (Ubuntu)
Server built:   Oct 14 2015 14:18:49
然后输入ifconfig得到ip地址

(我这里是)192.168.1.100得到It works页面验证成功
---

安装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
然后加载/检查php5.load这个php实现对apache2操作的模块(先不管为什么,先这么干就行)
liang@liang-andy:~$ cat /etc/apache2/mods-enabled/php5.load
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
---

安装MySQL

liang@liang-andy:~$ sudo apt-get install mysql-server
这个不需要验证版本,但同样要检查php操作mysql的模块

liang@liang-andy:~$ cat /etc/php5/mods-available/mysql.ini
cat: /etc/php5/conf.d/mysql.ini: 没有那个文件或目录

注意,这里我用的Ubuntu是14ls的版本,12的cat目录是不一样的/etc/php5/conf.d/mysql.ini

这里,由于php默认不安装mysql的拓展,所以需要手动安装

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
这样就可以了,然后重启mysql以及apache2

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

一次性安装:上面是分过程,下面一条给出一次性安装

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

----创建phpinfo探针

先装vim

sudo apt-get install vim

再切换到php的www文件夹,用cd命令

cd /var/www/html(14.4版本)

然后在这里创建一个php文件

sudo vim info.php

写php代码

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

phpinfo();
然后esc键,输入:wq保存退出

http://192.168.1.100/info.php 浏览器输入验证结果

 

 

Linux原来如此但疼,不写了,明天见

 

 

 

 

 

 

 

 

 

 

 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP Basics Tutorial: From Beginner to Master PHP Basics Tutorial: From Beginner to Master Jun 18, 2023 am 09:43 AM

PHP is a widely used open source server-side scripting language that can handle all tasks in web development. PHP is widely used in web development, especially for its excellent performance in dynamic data processing, so it is loved and used by many developers. In this article, we will explain the basics of PHP step by step to help beginners from getting started to becoming proficient. 1. Basic syntax PHP is an interpreted language whose code is similar to HTML, CSS and JavaScript. Every PHP statement ends with a semicolon; Note

PHP file reading and writing tutorial: Master the basic reading and writing methods PHP file reading and writing tutorial: Master the basic reading and writing methods Sep 06, 2023 pm 02:34 PM

PHP File Reading and Writing Tutorial: Mastering Basic Reading and Writing Methods Introduction PHP is a scripting language widely used in Web development. Its file reading and writing operations are very flexible and powerful. This tutorial will introduce you to commonly used file reading and writing methods in PHP, and provide some practical code examples to help readers quickly master these techniques. 1. File reading 1. Use the file_get_contents() function to read the entire file content<?php$file_path="exam

Can I learn Linux from scratch? What do I need to learn? Can I learn Linux from scratch? What do I need to learn? Feb 19, 2024 pm 12:57 PM

If you want to work in the IT industry, but do you want to learn programming, which technology should you choose? Of course it is Linux operation and maintenance. Linux is a very popular technology on the market, with a wide range of applications and good employment prospects, and is liked by many people. So the question is, can I learn Linux operation and maintenance with zero basic knowledge? In the server market, Linux system has a market share of up to 80% because of its advantages such as stability, security, free open source, efficiency and convenience. From this, it can be seen that Linux applications are very popular. Extensive. Whether now or in the future, learning Linux is a very good choice. As for whether it is possible to learn from scratch? My answer is of course. Oldboy Education Linux face-to-face class is specially designed for people with zero basic knowledge

Introduction to PHP Basics: How to use the echo function to output text content Introduction to PHP Basics: How to use the echo function to output text content Jul 30, 2023 pm 05:38 PM

Basic introduction to PHP: How to use the echo function to output text content. In PHP programming, you often need to output some text content to a web page. In this case, you can use the echo function. This article will introduce how to use the echo function to output text content and provide some sample code. Before starting, first make sure you have installed PHP and configured the running environment. If PHP is not installed yet, you can download the latest stable version from the PHP official website (https://www.php.net).

Learn the basics of Go language variables Learn the basics of Go language variables Mar 22, 2024 pm 09:39 PM

Go language is a statically typed, compiled language developed by Google. Its concise and efficient features have attracted widespread attention and love from developers. In the process of learning the Go language, mastering the basic knowledge of variables is a crucial step. This article will explain basic knowledge such as the definition, assignment, and type inference of variables in the Go language through specific code examples to help readers better understand and master these knowledge points. In the Go language, you can use the keyword var to define a variable, which is the format of the var variable name variable type.

Detailed explanation of C language functions: basic to advanced, comprehensive analysis of the use of functions Detailed explanation of C language functions: basic to advanced, comprehensive analysis of the use of functions Feb 18, 2024 pm 02:25 PM

C language function encyclopedia: from basic to advanced, detailed explanation of how to use functions, specific code examples are required Introduction: C language is a widely used programming language, and its powerful functions and flexibility make it the first choice of many developers. In C language, function is an important concept. It can combine a piece of code into an independent module, improving the reusability and maintainability of the code. This article will introduce the use of C language functions from the basics and gradually advance to help readers master the skills of function writing. 1. Definition and calling of functions in C

PHP study notes: Basics of object-oriented programming PHP study notes: Basics of object-oriented programming Oct 09, 2023 pm 12:46 PM

PHP study notes: Basics of object-oriented programming, specific code examples are required Introduction: Object-Oriented Programming (OOP for short) is a programming way of thinking that decomposes the problem into multiple objects and defines the interaction between objects. to solve complex programming problems. As a powerful programming language, PHP also supports object-oriented programming. This article will introduce the basic concepts and common syntax of object-oriented programming in PHP, and provide specific code examples. kind

PHP study notes: basic syntax and variable definition PHP study notes: basic syntax and variable definition Oct 09, 2023 am 08:03 AM

PHP study notes: basic syntax and variable definition In today's Internet era, PHP (Hypertext Preprocessor), as a widely used server scripting language, is favored by more and more developers. This article will introduce you to the basic syntax of PHP and the definition of variables, and provide specific code examples to help beginners better understand and master it. 1. Basic syntax of PHP Markings of PHP code In PHP code, we often use "<?php" and "?&

See all articles