马哥教育网络21期+第十二周练习博客上

1、请描述一次完整的http请求处理过程;
(1)建立或处理连接:接受请求或拒绝请求
(2)如果接受请求:
    并发访问响应模型:
        单进程I/O结构:启动一个进程处理用户请求,而且一次只处理一个,多个请求被串行响应;
        多进程I/O结构:并行启动多个进程,每个进程响应一个请求;
        复用I/O结构:一个进程生成N个线程,每个线程响应一个用户请求;
(3)处理请求:对请求的报文进行解析,并获取请求的资源及请求方法等相关信息;
(4)访问资源:获取请求报文中请求的资源;
(5)构建响应报文
(6)发送响应报文
(7)记录日志

2、httpd所支持的处理模型有哪些,他们的分别使用于哪些环境。
httpd所支持的处理模型有:prefork,worker,event
prefork:多进程模型,每个进程响应一个请求;
    一个主进程:负责生成n个子进程,子进程也称为工作进程,每个子进程处理一个用户请求,即便没有用户请求,也会预先生成多个空闲进程,等待客户请求(最大不超过1024个)
wokrer:多线程模型:,每个线程响应一个请求;一个主进程生成多个子进程,每个子进程负责生多个线程,每个线程响应一个请求
event:事件驱动模型,每个线程响应n个请求,一个主进程,生成m个子进程,每个进程直接n个请求
httpd-2.2:event为测试使用
httpd-2.4:event可生产中使用
3、源码编译安装LAMP环境(基于wordpress程序),并写出详细的安装、配置、测试过程。
 LAMP编译安装 #
LAMP编译安装,目前CentOS7操作系统上可以使用yum进行安装,在CentOS6上需要编译安装
CentOS6 http-2.2主要安装的,编译安装LAMP需要http-2.4进行编译安装
    linux上需要准备编译安装的环境:
    包组(CentOS 6):
    Server Platform Development
    Development Tools
http-2.4需要较新版本的apr和apr-util
1,编译安装apr
需要下载:apr-1.5.2 (1).tar.bz2,apr-util-1.5.4.tar.bz2

~]# tar xf apr-1.5.2\ \(1\).tar.bz2 
~]# cd apr-1.5.2
]# ./configure --prefix=/usr/local/apr
]# make && make install
编译安装apr-util-1.5.4.tar.bz2
]# tar xf apr-util-1.5.4.tar.bz2
]# cd apr-util-1.5.4
]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr(告知程序依据那个apr进行编译安装)
]# make && make install
好了这里就安装好了apr和apr-util了

安装http-2.4
1,httpd-2.4编译安装需要依赖pcre-devel软件包,使用yum install进行安装
]# tar xf httpd-2.4.23.tar.bz2 
]# cd httpd-2.4.23
]# ./configure --prefix=/usr/local/apache(程序安装路径) --sysconfdir=/etc/httpd24(程序配置文件) --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=all --with-mpm=event
]# make && make install
配置服务类脚本
]# cd /etc/rc.d/init.d/
]# cp httpd httpd24
编辑httpd24的配置文件修改文件路径
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd/httpd24.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd24}
将服务加入
]# chkconfig --add httpd24
]# chkconfig --list httpd24
httpd24         0:off   1:off   2:off   3:off   4:off   5:off   6:off
将httpd命令定义到新的httpd24下
]# . /etc/profile.d/httpd.sh 
]# cat /etc/profile.d/httpd.sh
export PATH=/usr/local/apache/bin:$PATH
重读配置文件
]# . /etc/profile.d/httpd.sh
]# hash
hits    command
 1  /usr/local/apache/bin/httpd


编译安装mariadb
先将下载好的软件包进行解压缩
]# tar xf mariadb-5.5.32-linux-x86_64.tar.gz 
]# cp mariadb-5.5.32-linux-x86_64 /usr/local/ -a
创建连接为mysql
]# ln -sv mariadb-5.5.32-linux-x86_64/ mysql
创建属组:]# groupadd -r -g 306 mysql
创建用户:]# useradd -r -g 306 -u 306 mysql
修改此文件中的属主为root,属组为mysql
]# chown root:mysql ./*
新建磁盘分区用于数据库的使用
这里使用的逻辑磁盘分区的方法
使用fdisk /dev/sda 创建一个20G的磁盘空间
使用t将磁盘修改类型为8e
先建立pv
]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
建立vg
]# vgs
VG       #PV #LV #SN Attr   VSize  VFree
VolGroup   1   3   0 wz--n- 59.99g    0 
[root@localhost mysql]# vgcreate myvg /dev/sda3 
Volume group "myvg" successfully created
创建lv
]# lvcreate -L 10G -n mydata myvg
Logical volume "mydata" created.
这里使用xfs文件系统
先使用yum install xfsprogs
加载模块文件
]# modprobe xfs
]# modinfo xfs
filename:       /lib/modules/2.6.32-642.4.2.el6.x86_64/kernel/fs/xfs/xfs.ko
license:        GPL
description:    SGI XFS with ACLs, security attributes, large block/inode numbers, no debug enabled
author:         Silicon Graphics, Inc.
srcversion:     67725EF8353DC29370566C8
depends:        exportfs
vermagic:       2.6.32-642.4.2.el6.x86_64 SMP mod_unload modversions 
对磁盘进行格式化
]# mkfs.xfs /dev/myvg/mydata 
meta-data=/dev/myvg/mydata       isize=256    agcount=4, agsize=655360 blks
         =                       sectsz=512   attr=2, projid32bit=0
data     =                       bsize=4096   blocks=2621440, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

编辑/etc/fstab文件是其开启自动挂载文件
/dev/myvg/mydata        /mydata                 xfs     defaults        0 0
新建一个目录用户存放mydata数据
查看需要编译安装的配置文件
[root@localhost mysql]# scripts/mysql_install_db --help
]# scripts/mysql_install_db --user=mysql(指定用户) --datadir=/mydata/data/(初始化数据放入到那个文件夹)
启动mysql需要使用一个服务脚本
[root@localhost support-files]# ls
binary-configure   magic                   my-medium.cnf        mysql.server
config.huge.ini    my-huge.cnf             my-small.cnf         ndb-config-2-node.ini
config.medium.ini  my-innodb-heavy-4G.cnf  mysqld_multi.server  SELinux
config.small.ini   my-large.cnf            mysql-log-rotate     solaris
]# cp mysql.server /etc/rc.d/init.d/mysqld
将服务加入到chkconfig 
[root@localhost support-files]# chkconfig --add mysqld
[root@localhost support-files]# chkconfig --list mysqld
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off

配置文件查找次序:
/etc/my.cnf --> /etc/mysql/my.cnf --> --default-extra-file=/PATH/TO/CONF_FILE --> ~/.my.cnf

这里如果需要将mysql命令加入到bash变量中永久有效有2中方法
在/etc/profile的export下面加入一行
export PATH=/usr/local/mysql/bin:$PATH
使用source /etc/profile
如需要对个人生效
在~/.bash_profile中加入
export PATH=/usr/local/mysql/bin:$PATH
source ~/.bash_profile

这里在mysql第一次运作时需要对用户权限等进行一次修改
mysql_secure_installation:安全初始化
初始化完成之后
[root@localhost ~]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 5.5.32-MariaDB-log MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

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

MariaDB [(none)]> user mysql
    -> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'user mysql' at line 1
MariaDB [(none)]> 
MariaDB [(none)]> 
MariaDB [(none)]> 
MariaDB [(none)]> use mysql;
Database changed
MariaDB [mysql]> SELECT User,Host,Password FROM user;
+------+-----------------------+-------------------------------------------+
| User | Host                  | Password                                  |
+------+-----------------------+-------------------------------------------+
| root | localhost             | *17C5214AB2227D33B7976A03E25B9D7AD58913AD |
| root | localhost.localdomain | *17C5214AB2227D33B7976A03E25B9D7AD58913AD |
| root | 127.0.0.1             | *17C5214AB2227D33B7976A03E25B9D7AD58913AD |
| root | ::1                   | *17C5214AB2227D33B7976A03E25B9D7AD58913AD |
+------+-----------------------+-------------------------------------------+
4 rows in set (0.00 sec)


编译安装PHP
将下载好的php软件包进行解压缩
]# tar xf php-5.5.38.tar.bz2 
]# cd php-5.5.38
解决好软件依赖关系
请配置好yum源(系统安装源及epel源)后执行如下命令:
]# yum -y groupinstall "Desktop Platform Development" 
]# yum -y install bzip2-devel libmcrypt-devel libxml2-devel
然后进行编译安装
]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml  --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs (将php编译为http模块)--with-mcrypt
(加解密库)  --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2  --enable-maintainer-zts(支持apache work或event功能)
这里等待编译完成,这里要记住httpd默认是不支持php模块的,需要在httpd的文件中加入
    AddType application/x-httpd-php  .php
     AddType application/x-httpd-php-source  .phps
定位至DirectoryIndex index.html 
修改为:
DirectoryIndex  index.php  index.html

查看http配置文件发现模块文件有
LoadModule php5_module        modules/libphp5.so
找到AddType加入上诉语句
为php提供配置文件
]# cp php.ini-production /etc/php.ini
我的测试文件为:
]# cat  index.php 
<?php
 $counn=mysql_connect('127.0.0.1','root','Pa$$w0rd01!');
  if($counn)
   echo "OK";
  else
   echo "NOT OK";
  mysql_close();
  phpinfo();
?>

建立数据库:  
建立用户名和登录地址与密码
> GRANT ALL ON wpdb.* TO 'wpuser'@'172.16.0.44' IDENTIFIED BY 'wppasswd';
建立数据库:
> CREATE DATABASE wpdb;

原创文章,作者:wostop,如若转载,请注明出处:http://www.178linux.com/51799

(0)
wostopwostop
上一篇 2016-10-17 08:36
下一篇 2016-10-17 08:36

相关推荐

  • linux上的组管理

    上一次我们谈了CentOS上的用户管理,现在我们再来谈下CentOS上的用户组管理。 groupadd创建一个新的组 用法如下: groupadd [选项] groupname 常用选项: -f 强制添加一个组(这个组可能已经存在系统中) -g 指定组的id; -r 创建系统工作组(系统工作组的组ID小于500) -K 覆盖配置文件/ect/log…

    Linux干货 2017-04-09
  • LInux 网络及相关进程作业管理

    马哥教育网络班23期+第四周课堂练习 Linux 网络及相关进程作业管理 一、概述 1.1 简介: 进入Linux学习第四周,这一周讲的知识点非常的多,也特别的碎,感觉这一周的内容掌握起来有很大的难度,主要是要记的命令很多,包括yum 的一些安装的命令,配置yum 源,相关的网络的命令和参数,还有就是进程管理和作业管理中的相关工具的使用,最后还讲了bash脚…

    Linux干货 2016-10-24
  • liunx性能监控工具总结

    1.uptime 1)显示的信息:显示当前时间,系统已启动的时间,当前在线人数,系统平均负载(1分钟、5分钟、10分钟的平均负载,一般不会超过1) 2)系统平均负载:指在特定时间间隔内运行队列中的平均进程数。 3)如果每个CPU内核的当前活动进程数不大于3的话,那么系统的性能良好。如果每个CPU内核的任务数大于5,那么这台及其的性能有严重问题 4)ruguo…

    Linux干货 2016-09-09
  • SQL Server 2012 故障转移群集最佳实践

    一、Windows server  2012 系统主域的安装配置 功能介绍:  SQL Server 故障转移群集在网络上显示为一台计算机上的单个 SQL Server 实例。在群集内部,一次只有一个节点拥有群集资源组,满足针对该故障转移群集实例的所有客户端请求。在出现故障(硬件故障、操作系统故障、应用程序或服务故障)或进行计划升级时,组…

    Linux干货 2015-10-27
  • shell脚本总结

    shell脚本简要总结 脚本调试 bash -n /path/to/some_script检测脚本中的语法错误 bash -x /path/to/some_script调试执行 变量 环境变量 变量声明、赋值:export name=VALUEdeclare -x name=VALUE 变量引用:$name, ${name} 显示所有环境变量: export…

    Linux干货 2016-08-21
  • Linux系统shell脚本

                                          &n…

    系统运维 2016-09-01

评论列表(1条)

  • 马哥教育
    马哥教育 2016-10-24 22:55

    请认真对待每一次作业中要求的细节,因为它很可能就是你工作中遗漏且真正让你无法找到正解真正原因