note_21.4.1_LAMP

LAMP:

httpd:接收用户的web请求;静态资源则直接响应;动态资源为php脚本,对此类资源的请求将交由php来运行;
php:运行php程序;
MariaDB:数据管理系统;

httpd与php结合的方式:
    FastCGI 
    modules (把php编译成为httpd的模块)
        MPM:
            prefork: libphp5.so
            event, worker: libphp5-zts.so

安装lamp:

CentOS 6: httpd, php, mysql-server, php-mysql
    # service httpd  start
    # service  mysqld  start
CentOS 7: httpd, php, php-mysql, mariadb-server
    # systemctl  start  httpd.service
    # systemctl  start  mariadb.service

php:

脚本语言解释器
配置文件:/etc/php.ini, /etc/php.d/*.ini

配置文件在php解释器启动时被读取,因此,对配置文件的修改如何生效?
Modules:重启httpd服务;
FastCGI:重启php-fpm服务;

ini:
    [foo]:Section Header
    directive = value
                        
    php.ini的核心配置选项文档:  http://php.net/manual/zh/ini.core.php
    php.ini配置选项列表:http://php.net/manual/zh/ini.list.php
                        
<?php 
    ...php code...
?>

MariaDB

主要有两类程序文件
Client: mysql, mysqldump, mysqladmin
Server:mysqld, mysqld_safe, mysqld_multi

MySQL的命令行客户端程序:mysql
        -u 
        -h
        -p
                
命令的种类:
    客户端命令:
        mysql> help
    服务端命令:
                
        支持SQL语句对数据管理:
            DDL,DML
                DDL: CREATE, ALTER, DROP, SHOW
                DML: INSERT, DELETE,SELECT, UPDATE
                            
        授权能远程的连接用户:
            mysql> GRANT  ALL  PRIVILEGES  ON  db_name.tbl_name TO  username@host  IDENTIFIED BY 'password'; 

php测试代码

<?php
    phpinfo();
?>

php连接mysql的测试代码:

<?php
    $conn = mysql_connect('172.16.100.67','testuser','testpass');
    if ($conn) 
        echo "OK";
    else
        echo "Failure";
?>  

实践作业:部署lamp,以虚拟主机安装wordpress, phpwind, discuz;

下载wordpress

[root@localhost ~]# wget -O /tmp/wordpress.tar.gz https://cn.wordpress.org/latest-zh_CN.tar.gz
--2019-04-11 22:49:12--  https://cn.wordpress.org/latest-zh_CN.tar.gz
Resolving cn.wordpress.org (cn.wordpress.org)... 198.143.164.252
Connecting to cn.wordpress.org (cn.wordpress.org)|198.143.164.252|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11098483 (11M) [application/octet-stream]
Saving to: ‘/tmp/wordpress.tar.gz’

100%[=================================================================================================>] 11,098,483  1.30MB/s   in 11s    

2019-04-11 22:49:24 (1000 KB/s) - ‘/tmp/wordpress.tar.gz’ saved [11098483/11098483]

解包

[root@localhost ~]# tar xf /tmp/wordpress.tar.gz 

[root@localhost ~]# cp -a wordpress/ /var/www/html/blog

创建wordpress数据库

[root@localhost ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE wordpress
    -> ;
Query OK, 1 row affected (0.00 sec)

配置wordpress和httpd

[root@localhost ~]# ls /var/www/html/blog/
index.php    wp-activate.php     wp-comments-post.php  wp-cron.php        wp-load.php   wp-settings.php   xmlrpc.php
license.txt  wp-admin            wp-config-sample.php  wp-includes        wp-login.php  wp-signup.php
readme.html  wp-blog-header.php  wp-content            wp-links-opml.php  wp-mail.php   wp-trackback.php
[root@localhost ~]# cp /var/www/html/blog/wp-config-sample.php /var/www/html/blog/wp-config.php
[root@localhost ~]# vim /var/www/html/blog/wp-config.php

wp-config.php

/** WordPress数据库的名称 */
define('DB_NAME', 'wordpress');

/** MySQL数据库用户名 */
define('DB_USER', 'wpuser');

/** MySQL数据库密码 */
define('DB_PASSWORD', 'wppass');

/** MySQL主机 */
define('DB_HOST', '192.168.0.103');

/** 创建数据表时默认的文字编码 */
define('DB_CHARSET', 'utf8');

/** 数据库整理类型。如不确定请勿更改 */
define('DB_COLLATE', '');

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 1.LAMP介绍  LAM(M)P:L: linuxA: apache (httpd)M: mysql, mar...
    尛尛大尹阅读 4,778评论 0 1
  • 一、LAMP环境的介绍 1.LAMP环境的重要性 思索许久,最终还是决定写一篇详细的LAMP的源码编译安装的实验文...
    endmoon阅读 7,666评论 4 26
  • 1 概述 LAMP 目前在CentOS6不支持php-fpm的安装,安装高版本的数据库在centos6上也需要通过...
    ghbsunny阅读 3,294评论 0 0
  • 虽然我不是第一次部署LAMP,但是还是踩到了坑,我使用的云服务器是阿里云的Centos7.3 64位,感觉使用Ce...
    追逐_e6cf阅读 4,545评论 0 1
  • LAMP介绍php详细使用CentOS 7环境下部署phpmyadminCentOS 7环境下部署wordpres...
    哈喽别样阅读 1,801评论 0 0

友情链接更多精彩内容