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', '');
网友评论