广告
返回顶部
首页 > 资讯 > 数据库 >源码编译安装LAMP环境
  • 260
分享到

源码编译安装LAMP环境

2024-04-02 19:04:59 260人浏览 薄情痞子
摘要

1、请描述一次完整的Http请求处理过程;2、httpd所支持的处理模型有哪些,他们的分别使用于哪些环境。3、源码编译安装LAMP环境(基于Wordpress程序),并写出详细的安装、配置、测试过程。4、建

1、请描述一次完整的Http请求处理过程;

2、httpd所支持的处理模型有哪些,他们的分别使用于哪些环境。

3、源码编译安装LAMP环境(基于Wordpress程序),并写出详细的安装、配置、测试过程。

4、建立httpd服务器(基于编译的方式进行),要求:

     提供两个基于名称的虚拟主机:

   (a)www1.stuX.com,页面文件目录为/WEB/vhosts/www1;错误日志为/var/log/httpd/www1.err,访问日志为/var/log/httpd/www1.access;

   (b)www2.stuX.com,页面文件目录为/web/vhosts/www2;错误日志为/var/log/httpd/www2.err,访问日志为/var/log/httpd/www2.access;

   (c)为两个虚拟主机建立各自的主页文件index.html,内容分别为其对应的主机名;

   (d)通过www1.stuX.com/server-status输出httpd工作状态相关信息,且只允许提供帐号密码才能访问(status:status);

5、为第4题中的第2个虚拟主机提供https服务,使得用户可以通过https安全的访问此web站点;

  (1)要求使用证书认证,证书中要求使用的国家(CN)、州(HA)、城市(ZZ)和组织(MageEdu);

  (2)设置部门为Ops,主机名为www2.stuX.com,邮件为admin@stuX.com;

6、在LAMP架构中,请分别以PHP编译成httpd模块形式和php以fpm工作为独立守护进程的方式来支持httpd,列出详细的过程。

1.一次完整的http请求处理过程:

         (1)建立或处理连接:接收请求或拒绝请求;

         (2)接收请求:接收来自于网络上的主机请求报文中对某特定资源的一次请求的过程;

         (3)处理请求:对请求报文进行解析,获取客户端请求的资源及请求方法等相关信息;

         (4)访问资源:获取请求报文中请求的资源;

         (5)构建响应报文:

         (6)发送响应报文:

         (7)记录日志:

2.httpd所支持的处理模型有哪些,他们的分别使用于哪些环境。

         prefork:多进程模型,每个进程响应一个请求;

                   一个主进程:负责生成子进程及回收子进程;负责创建套接字;负责接收请求,并将其派发给某子进程进行处理;

                   n个子进程:每个子进程处理一个请求;

                   工作模型:会预先生成几个空闲进程,随时等待用于响应用户请求;最大空闲和最小空闲

         worker:多进程多线程模型,每线程处理一个用户请求;

                   一个主进程:负责生成子进程;负责创建套接字;负责接收请求,并将其派发给某子进程进行处理;

                   多个子进程:每个子进程负责生成多个线程;

                   每个线程:负责响应用户请求;

                   并发响应数量:m*n

                            m:子进程数量

                            n:每个子进程所能创建的最大线程数量;

         event:事件驱动模型,多进程模型,每个进程响应多个请求;

                   一个主进程 :负责生成子进程;负责创建套接字;负责接收请求,并将其派发给某子进程进行处理;

                   子进程:基于事件驱动机制直接响应多个请求;

3.源码编译安装LAMP环境(基于wordpress程序),并写出详细的安装、配置、测试过程。

         以Centos6.5环境安装httpd2.4.9,php5.4.26,通用二进制mariadb5.5.36,具体安装如下:

         (1).编译安装httpd2.4.9

         安装httpd-2.4,依赖于apr-1.4+,apr-util-1.4+, [apr-iconv],  apr: apacheportable runtime

         首先安装开发环境包组:DevelopmentTools, Server PlatfORM Development    开发程序包:pcre-devel

         [root@localhost~]# yum groupinstall 服务器平台开发    开发工具

         [root@localhostdylan]# tar -xjvf apr-1.5.0.tar.bz2

         [root@localhostdylan]# cd apr-1.5.0

         [root@localhostapr-1.5.0]# ./configure --prefix=/usr/local/apr

         [root@localhostapr-1.5.0]# make && make install                              ###安装apr-1.5.0

         [root@localhostdylan]# tar -xjvf apr-util-1.5.3.tar.bz2

         [root@localhostdylan]# cd apr-util-1.5.3

         [root@localhostapr-util-1.5.3]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

         [root@localhostapr-util-1.5.3]# make && make install                       ###安装apr-util-1.5.3

         ###解压httpd

         [root@localhostdylan]# tar -xjvf httpd-2.4.9.tar.bz2

         [root@localhostdylan]# cd httpd-2.4.9

         ###安装必备包

         [root@localhosthttpd-2.4.9]# yum install openssl openssl-devle pcre pcre-devel -y

         [root@localhosthttpd-2.4.9]# ./configure --prefix=/usr/local/apache24--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=prefork

         [root@localhosthttpd-2.4.9]# make && make install                            ###安装httpd-2.4.9

         ###编译安装完成后把apachectl命令路径加入PATH中

         [root@localhost/]# vim /etc/profile.d/httpd.sh

         exportPATH=/usr/local/apache24/bin:$PATH                                         ###添加环境变量

        

         (2).通用二进制格式安装mariadb-5.5.36-linux-x86_64.tar.gz

         首先准备数据目录:

         [root@localhost/]# mkdir -pv /mydata/data

         [root@localhost/]# groupadd -r -g 306 Mysql                                        ###添加mysql

         [root@localhost/]# useradd -r -g 306 -u 306 mysql                                ###添加mysql用户

         [root@localhost/]# chown -R mysql.mysql /mydata/data/                     

         安装配置

         [root@localhost/]# tar xf mariadb-5.5.36-linux-x86_64.tar.gz -C /usr/local/                                     ###解压至/usr/local目录

         [root@localhost/]#  cd /usr/local/

         [root@localhostlocal]# ln -sv mariadb-5.5.36-linux-x86_64/ mysql       ###链接至mysql目录

         [root@localhostlocal]# cd /usr/local/mysql/

         [root@localhostmysql]# chown -R root:mysql       .

         define('DB_NAME','wpdb');

        

         define('DB_USER','wp');

        

         define('DB_PASSWORD','wordpress');

        

         define('DB_HOST','192.168.0.113');

         [root@localhostwordpress]# apachectl restart

打开页面显示

源码编译安装LAMP环境

填入信息后显示

源码编译安装LAMP环境

至此,安装完成。

 

4、建立httpd服务器(基于编译的方式进行),要求: 提供两个基于名称的虚拟主机:

   (a)www1.stuX.com,页面文件目录为/web/vhosts/www1;错误日志为/var/log/httpd/www1.err,访问日志为/var/log/httpd/www1.access;

   (b)www2.stuX.com,页面文件目录为/web/vhosts/www2;错误日志为/var/log/httpd/www2.err,访问日志为/var/log/httpd/www2.access;

   (c)为两个虚拟主机建立各自的主页文件index.html,内容分别为其对应的主机名;

   (d)通过www1.stuX.com/server-status输出httpd工作状态相关信息,且只允许提供帐号密码才能访问(status:status);

[root@localhost ~]# mkdir -pv/web/vhosts/{www1,www2}                          ###创建文件目录

[root@localhost ~]# mkdir -pv/var/log/httpd

[root@localhost ~]# echo"<h2>www1.stuX.com</h2>" > /web/vhosts/www1/index.html                   ###主页文件内容

[root@localhost ~]# echo"<h2>www2.stuX.com</h2>" > /web/vhosts/www2/index.html

[root@localhost ~]# vim/etc/httpd24/httpd.conf

#DocumentRoot"/usr/local/apache24/htdocs"                                                  ###注释中心主机

Include /etc/httpd24/extra/vhost.conf                                                               ###添加配置文件

[root@localhost ~]# vim/etc/httpd24/extra/vhost.conf                                    ###配置虚拟主机

<VirtualHost 192.168.0.113:80>    

         ServerNamewww1.stux.com

         DocumentRoot"/web/vhosts/www1"

         ErrorLog"/var/log/httpd/www1.err"

         CustomLog"/var/log/httpd/www1.access" combined

         <Directory"/web/vhosts/www1">

                   OptionsNone

                   AllowOverrideNone

                   Requireall granted

 

         </Directory>

         <Location/server-status>

                   SetHandlerserver-status

                   AuthTypeBasic

                   AuthName"Enter username and password"

                   AuthUserFile"/etc/httpd24/.htpasswd"

                   Requireuser status

         </Location>

</VirtualHost>

 

 

<VirtualHost 192.168.0.113:80>    

         ServerNamewww2.stux.com

         DocumentRoot"/web/vhosts/www2"

         ErrorLog"/var/log/httpd/www2.err"

         CustomLog"/var/log/httpd/www2.access" combined

         <Directory"/web/vhosts/www2">

                   OptionsNone

                   AllowOverrideNone

                   Requireall granted

         </Directory>

</VirtualHost>

[root@localhost ~]# htpasswd -c -m/etc/httpd24/.htpasswd status             ###生成认证文件,第一次加-c

New password:

Re-type new password:

Adding password for user status

[root@localhost ~]# httpd –t                                             ###测试配置文件

Syntax OK

[root@localhost ~]# apachectl restart                               ###重启服务

测试:

需配置hosts文件  添加192.168.0.113   www1.stux.com

                                                 192.168.0.113   www2.stux.com

源码编译安装LAMP环境

源码编译安装LAMP环境

 

测试status

源码编译安装LAMP环境

源码编译安装LAMP环境

总结:编译安装的2.4虚拟主机配置文件与2.2有所区别

对于基于IP的访问控制做了修改,不再支持使用order, allow, deny这些机制,而是统一使用require进行

基于主机名的虚拟主机不再需要NameVirtualHost指令

注意:任意目录下的页面只有显式授权才能被访问;

5、为第4题中的第2个虚拟主机提供https服务,使得用户可以通过https安全的访问此web站点;

  (1)要求使用证书认证,证书中要求使用的国家(CN)、州(HA)、城市(ZZ)和组织(MageEdu);

  (2)设置部门为Ops,主机名为www2.stuX.com,邮件为admin@stuX.com;

###测试用,CA与httpd位于同一主机

###首先,创建私有CA,在服务器创建证书签署请求以及CA签证

[root@localhost ~]# rpm -q openssl

openssl-1.0.1e-57.el6.x86_64

[root@localhost ~]# (umask 077;opensslgenrsa -out /etc/pki/CA/private/cakey.pem 4096)                 ###创建私钥

Generating RSA private key, 4096 bit longmodulus

..........................................................................................

...................................................................................................................++...++

e is 65537 (0x10001)

[root@localhost ~]# openssl req -new -x509-key /etc/pki/CA/private/cakey.pem -out /etc/pk    ###生成自签证书

i/CA/cacert.pem -days 3650You are about tobe asked to enter information that will be incorporated

into your certificate request.

What you are about to enter is what iscalled a Distinguished Name or a DN.

There are quite a few fields but you canleave some blank

For some fields there will be a defaultvalue,

If you enter '.', the field will be leftblank.

-----

Country Name (2 letter code) [XX]:CN

State or Province Name (full name) []:HA

Locality Name (eg, city) [Default City]:ZZ

Organization Name (eg, company) [DefaultCompany Ltd]:MageEdu

Organizational Unit Name (eg, section)[]:Ops

Common Name (eg, your name or your server'shostname) []:ca.stuX.com

Email Address []:admin@stuX.com

[root@localhost ~]# touch/etc/pki/CA/index.txt                                     ###为CA提供辅助文件

[root@localhost ~]# echo 01>/etc/pki/CA/serial

[root@localhost ~]# mkdir /etc/httpd24/ssl

[root@localhost ~]# cd /etc/httpd24/ssl/

[root@localhost ssl]# (umask 077;opensslgenrsa -out /etc/httpd24/ssl/httpd.key 2048)             ###httpd主机生成私钥

Generating RSA private key, 2048 bit longmodulus

.........+++

.................+++

e is 65537 (0x10001)

###httpd生成证书签署请求

[root@localhost ssl]# openssl req -new -key/etc/httpd24/ssl/httpd.key -out /etc/httpd24/ssl/httpd.csr -days 365

You are about to be asked to enterinformation that will be incorporated

into your certificate request.

What you are about to enter is what iscalled a Distinguished Name or a DN.

There are quite a few fields but you canleave some blank

For some fields there will be a defaultvalue,

If you enter '.', the field will be leftblank.

-----

Country Name (2 letter code) [XX]:CN

State or Province Name (full name) []:HA

Locality Name (eg, city) [Default City]:ZZ

Organization Name (eg, company) [DefaultCompany Ltd]:MageEdu

Organizational Unit Name (eg, section)[]:Ops

Common Name (eg, your name or your server'shostname) []:www2.stuX.com

Email Address []:admin@stuX.com

 

Please enter the following 'extra'attributes

to be sent with your certificate request

A challenge password []:

An optional company name []:

###因同属一台主机测试,故直接签署证书

[root@localhost ssl]# openssl ca -in/etc/httpd24/ssl/httpd.csr -out /etc/pki/CA/certs/httpd.crt -days 365UsinGConfiguration from /etc/pki/tls/openssl.cnf

Check that the request matches thesignature

Signature ok

Certificate Details:

       Serial Number: 1 (0x1)

       Validity

           Not Before: Jun 26 08:04:53 2017 GMT

           Not After : Jun 26 08:04:53 2018 GMT

       Subject:

           countryName               = CN

           stateOrProvinceName       = HA

           organizationName          =MageEdu

           organizationalUnitName    = Ops

           commonName                =www2.stuX.com

           emailAddress              =admin@stuX.com

       X509v3 extensions:

           X509v3 Basic Constraints:

                CA:FALSE

           Netscape Comment:

                OpenSSL Generated Certificate

           X509v3 Subject Key Identifier:

                9B:20:A6:09:86:E1:F2:05:94:D7:ED:33:57:D2:A1:FE:95:C9:3F:47

           X509v3 Authority Key Identifier:

               keyid:85:26:25:F4:82:7C:86:25:B1:73:B0:C5:57:24:41:86:81:2A:24:FA

 

Certificate is to be certified until Jun 2608:04:53 2018 GMT (365 days)

Sign the certificate? [y/n]:y

 

 

1 out of 1 certificate requests certified,commit? [y/n]y

Write out database with 1 new entries

Data Base Updated

[root@localhost ssl]# cp/etc/pki/CA/certs/httpd.crt /etc/httpd24/ssl/       ###将证书发给httpd

###配置httpd支持使用ssl及使用的证书

[root@localhost ssl]# vim/etc/httpd24/httpd.conf                          ###编辑httpd配置文件

Include /etc/httpd24/extra/httpd-ssl.conf                                       ###启用ssl配置文件,去掉#

LoadModule ssl_module modules/mod_ssl.so                                 ###启用ssl模快,去掉#

[root@localhost ssl]# vim/etc/httpd24/extra/httpd-ssl.conf            ###编辑ssl配置文件

<VirtualHost _default_:443>

DocumentRoot "/web/vhosts/www2"

ServerName www2.stuX.com

ServerAdmin you@example.com

ErrorLog"/var/log/httpd/www2.ssl.err"

SSLEngine on

SSLCertificateFile"/etc/httpd24/ssl/httpd.crt"                                         ###证书路径

SSLCertificateKeyFile"/etc/httpd24/ssl/httpd.key"                                  ###私钥路径

<Directory"/web/vhosts/www2">

       OPtions None

       AllowOverride   None

       Require all granted

</Directory>

</VirtualHost>

TransferLog"/var/log/httpd/www2.ssl.access"

[root@localhost ssl]# httpd -t                                                                 ###测试出现错误

AH00526: Syntax error on line 73 of/etc/httpd24/extra/httpd-ssl.conf:

SSLSessionCache: 'shmcb' session cache notsupported (known names: ). Maybe you need to lo

ad the appropriate socache module(mod_socache_shmcb?).

[root@localhost ssl]# vim/etc/httpd24/httpd.conf

LoadModule socache_shmcb_modulemodules/mod_socache_shmcb.so    ###启用此模块,去掉#

[root@localhost ssl]# httpd -t

Syntax OK

[root@localhost ssl]# apachectl restart

测试

[root@localhost ~]# vim /etc/host                                                                                               ###编辑hosts文件添加httpd主机Ip

192.168.0.113 www2.stuX.com

[root@localhost ~]# openssl s_client-connect www2.stuX.com:443

6、在LAMP架构中,请分别以php编译成httpd模块形式和php以fpm工作为独立守护进程的方式来支持httpd,列出详细的过程。(下一篇博客详细介绍)


您可能感兴趣的文档:

--结束END--

本文标题: 源码编译安装LAMP环境

本文链接: https://www.lsjlt.com/news/39020.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • 源码编译安装LAMP环境
    1、请描述一次完整的http请求处理过程;2、httpd所支持的处理模型有哪些,他们的分别使用于哪些环境。3、源码编译安装LAMP环境(基于wordpress程序),并写出详细的安装、配置、测试过程。4、建...
    99+
    2022-10-18
  • 源码安装LAMP环境+yii2框架
    当有些新增的软件版本出现,而你想要进行尝试使用,但是在本地用yum安装却不能满足你的需求时, 那么朋友,你需要和我一样用源码安装的形式来达成你的目的。因为开发的同事想要一个Apache 2.4.25 + M...
    99+
    2022-10-18
  • LAMP纯源码编译安装日志
    一.LAMP构架的安装与经验技巧(源码安装好处。是便于管理,可以选定参数,可以使用新版本)相关软件列表:# ls /soft/ | grep -E "*.gz|*.zip|*.xz|*.bz2" ...
    99+
    2022-10-18
  • PHP:CentOS Linux环境下源码编译安装PHP8.0
    系统环境 cat /etc/redhat-releaseCentOS Linux release 7.5.1804 (Core) 查看可用版本 https://www.php.net/releases...
    99+
    2023-09-14
    linux 服务器 运维
  • Ubuntu环境源码编译安装xdebug的方法
    本文实例讲述了Ubuntu环境源码编译安装xdebug的方法。分享给大家供大家参考,具体如下: 前面介绍了Ubuntu环境编译安装php和Nginx的方法,这里再来讲解一下源码编译安装xdebug的方法。 下载并解压xd...
    99+
    2022-06-04
    Ubuntu 源码 编译安装 xdebug
  • LAMP编译安装
    安装之前首先要安装所需的依赖库,将httpd mysql php等所需要的源码包上传到主机,或者wget 方式直接下载 上传方式和wget下载不作介绍,其中有些依赖是可以编译安装或者yum安装,并且这里依赖...
    99+
    2022-10-18
  • 基于CentOS 6.8平台最新源代码包编译安装LAMP环境搭建(Apache+MySQL+PHP)
    部署环境系统:CentOS 6.8 x86_64Apache:2.4.23MySQL:5.7.14PHP:7.0.10apr:1.5.2apr-util:1.5.4boost:1.59.0cmake:3.6...
    99+
    2022-10-18
  • LAMP编译安装1
    ...
    99+
    2022-10-18
  • 编译安装zabbix3.2,LAMP
    编译安装zabbix方式1.1 环境准备系统环境:redhat 6.6 64位mysql-5.6.34php-5.6.28zabbix-3.2.1配置前先关闭iptables和SELINUX,避免安装过程中...
    99+
    2022-10-18
  • 怎么在CentOS 7.4环境下源码编译安装postgreSQL 11.4
    本篇内容介绍了“怎么在CentOS 7.4环境下源码编译安装postgreSQL 11.4”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希...
    99+
    2022-10-18
  • Linux环境下, 源码编译安装详解 (编译CMake 3.15 和 gcc 5.3.0 为例)
    一. 源码编译安装详解 (待补充)二. 安装CMake 3.151. 查看操作系统版本[root@mysql80 local]# cat /etc/redhat-releaseCentOS ...
    99+
    2023-06-05
  • 源码包搭建LAMP环境
    第一步 1、安装编译工具 gcc*    安装数据库编译工具  cmake   bison   yum -y ins...
    99+
    2022-10-18
  • centos7 LAMP环境安装zabbix3.0
    zabbix3.0要求的PHP、数据库、Apache/Nginx的版本参考:zabbix3.0对PHP、数据库、nginx/apache版本要求参考:https://www.zabbix.com/docum...
    99+
    2022-10-18
  • 编译安装lamp-1(mysql)
    lamp分层机制:用户--[httpd协议]--apache--[fastCGI协议]--php--[mysql协议]--mysql分层优势:Apache php和mysql都是CPU密集型的服务,分层可以...
    99+
    2022-10-18
  • Centos 6.5编译安装LAMP
    一、前言1、环境说明基础环境Linux+Apache+MySQL+PHPlinux:6.5Apache 2.2.12mysql:5.6.17php:5.5.122、部署说明php安装目录:/usr/loca...
    99+
    2022-10-18
  • LAMP 编译安装 +wordpress+discuz
    #软件下载#开源博客Wordpress    下载地址:https://cn.wordpress.org/wordpress-4.7.4-zh_CN.tar.gz#PHP 7  ...
    99+
    2022-10-18
  • PHP源码编译安装
    目录 编译环境编译过程运行配置运行环境1. 创建php.ini文件2. 创建 php-fpm.conf文件3. 创建 www.conf文件4. 配置连接socket为文件(可选)5. 配置ng...
    99+
    2023-09-21
    php sqlite ubuntu
  • 源码编译安装mysql5.7.18
    #yum install -y gcc-c++ cmake vim ncurses-devel wget#useradd mysql -s /home/nologin#mkdir /soft/my...
    99+
    2022-10-18
  • MySQL源码编译安装
    1、安装cmake-2.8.10.2.tar.gz以root用户进入shell#tar -zxvf  cmake-2.8.10.2.tar.gz#cd cmake-2.8.10.2#./confi...
    99+
    2022-10-18
  • 源码编译安装MySQL8.0.20
    2 源码编译安装的相关知识 2.1 make与configure make是一个编译的命令,会在当前的目录下寻找Makefile这个文件,Makefile文件记录了源代码如何编译的详细信息。而configure是由软件开发商编写的一个检测程...
    99+
    2017-08-02
    源码编译安装MySQL8.0.20
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作