搭建lamp平台

news2025/7/11 2:42:23

apache安装步骤

  • 检查是否已经rpm安装httpd服务,已安装则卸载服务。
[root@localhost ~]# rpm -e `rpm -qa | grep httpd` --nodeps
  • 开发工具安装

如果编译安装无法执行,可能是开发工具没有安装,执行下面命令即可安装。(如已安装则跳过即可)。

[root@localhost ~]# yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel
  • httpd安装

1. 挂载rpm包的iso镜像。

查看虚拟机使用ISO镜像,设备状态勾选已连接和启动时连接后确定即可。

2. 通过脚本解压tar包并编译安装。

[root@localhost ~]# mkdir /sh

 [root@localhost ~]#  cd /sh

 [root@localhost sh]# vim add.sh

#!/bin/bash

mount /dev/cdrom /media/

tar zxf /media/apr-1.5.2.tar.gz -C /usr/src

cd /usr/src/apr-1.5.2

./configure --prefix=/usr/local/apr && make && make install

tar zxf /media/apr-util-1.5.4.tar.gz -C /usr/src

cd /usr/src/apr-util-1.5.4

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make && make install

yum -y install zlib-*

tar zxf /media/pcre-8.39.tar.gz -C /usr/src

cd /usr/src/pcre-8.39

./configure --prefix=/usr/local/pcre && make && make install

tar zxf /media/openssl-1.0.1u.tar.gz -C /usr/src

cd /usr/src/openssl-1.0.1u

./config -fPIC --prefix=/usr/local/openssl enable-shared && make && make install

保存退出脚本并执行脚本文件,等待脚本执行完成并确认成功。

[root@localhost sh]# sh add.sh

2. 安装Apache主程序。

下面也通过脚本来安装主程序。

[root@localhost sh]# vim httpd.sh

#!/bin/bash

tar zxf /media/httpd-2.4.25.tar.gz -C /usr/src

cd /usr/src/httpd-2.4.25

./configure --prefix=/usr/local/httpd --enable-so --enable-cgi --enable-cgid --enable-ssl --with-ssl=/usr/local/openssl --enable-rewrite --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-mpm=event --enable-proxy --enable-proxy-fcgi --enable-expires --enable-deflate && make && make install

保存退出脚本并执行脚本文件,等待脚本执行完成并确认成功。

  1. 优化链接和添加系统服务。
[root@localhost sh]# ln -s /usr/local/httpd/bin/* /usr/local/bin //链接优化

[root@localhost sh]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd //添加服务

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

第二行添加下面两行命令

# chkconfig: 35 85 15     \\声明服务启动级别,开机启动顺序,关机关闭顺序

# description: apache 2.4.25 \\服务声明,简要信息
[root@localhost sh]# chkconfig --add httpd //添加到系统服务

[root@localhost sh]# chkconfig httpd on //设置开机自启

[root@localhost sh]# systemctl start httpd //开启服务
  1. 查看httpd模块

安装后可以通过下面三行命令查看各项模块。

httpd -V         \\查看版本和已装模块

httpd -l         \\只查看静态编译模块

httpd -M          \\查看所有模块  

  1. 查看mpm配置文件

vim /usr/local/httpd/conf/extra/httpd-mpm.conf

<IfModule mpm_event_module>

StartServers 3 #apache 启动时候默认开始的子进程数

MinSpareThreads 75 #最小空闲数量的工作线程

MaxSpareThreads 250 #最大空闲数量的工作线程

ThreadsPerChild 25 #每个子进程产生的线程数量

MaxRequestWorkers 400 #允许同时的最大接入请求数量

MaxConnectionsPerChild 0 #每个子进程可处理的请求数

</IfModule>

#企业推荐参数

<IfModule mpm_worker_module>

StartServers          2 #推荐设置:小=默认 中=3~5 大=5~10

MaxClients          150 #推荐设置:小=500 中=500~1500 大型=1500~3000

MinSpareThreads      25 #推荐设置:小=默认 中=50~100 大=100~200

MaxSpareThreads      75 #推荐设置:小=默认 中=80~160 大=200~400 ThreadsPerChild      25 #推荐设置:小=默认 中=50~100 大型=100~200

MaxRequestsPerChild   0 #推荐设置:小=10000 中或大=10000~50000(此外,如果MaxClients/ThreadsPerChild大于16,还需额外设置ServerLimit参数,ServerLimit必须大于等于 MaxClients/ThreadsPerChild 的值。)

</IfModule>

  1. 查看apache主页

通过访问http://192.168.1.2可以看到apache默认网站。

 

  1. 使用ab命令进行压力测试

通过上面命令已经启动httpd服务,通过ab工具测试httpd服务,如未安装通过下面命令安装ab命令工具(打开第二台服务器对第一台httpd服务器进行测试)。

[root@localhost ~]# yum -y install httpd-tools

安装完毕后执行下面命令对服务器进行200人并发访问,发出10000个请求。

[root@localhost ~]# ab -c 200 -n 10000 http://192.168.1.2/index.html

This is ApacheBench, Version 2.3 <$Revision: 1430300 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/



Benchmarking 192.168.1.2 (be patient)

Completed 1000 requests

Completed 2000 requests

Completed 3000 requests

Completed 4000 requests

Completed 5000 requests

Completed 6000 requests

Completed 7000 requests

Completed 8000 requests

Completed 9000 requests

Completed 10000 requests

Finished 10000 requests





Server Software:        Apache/2.4.25

Server Hostname:        192.168.1.2

Server Port:            80



Document Path:          /index.html

Document Length:        45 bytes



Concurrency Level:      200

Time taken for tests:   3.803 seconds

Complete requests:      10000

Failed requests:        0

Write errors:           0

Total transferred:      2890000 bytes

HTML transferred:       450000 bytes

Requests per second:    2629.29 [#/sec] (mean)

Time per request:       76.066 [ms] (mean)

Time per request:       0.380 [ms] (mean, across all concurrent requests)

Transfer rate:          742.06 [Kbytes/sec] received



Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0   22 153.7      2    3008

Processing:     8   47  34.1     44     451

Waiting:        4   44  33.0     43     435

Total:         28   69 157.9     46    3057



Percentage of the requests served within a certain time (ms)

  50%     46

  66%     49

  75%     51

  80%     54

  90%     62

  95%     80

  98%    267

  99%   1048

 100%   3057 (longest request)

mysql安装步骤

关于上述已经学会了Apache编译安装,下面将进行MySQL的本地安装。

[root@localhost ~]# mount /dev/cdrom /media

[root@localhost ~]# cd /media/mysql5.6-rpm/

检查确认所需rpm包。

通过执行下面命令进行本地安装rpm包。

[root@localhost ~]# cd /media/mysql5.6-rpm/

[root@localhost mysql5.6-rpm]# rpm -ivh --nodeps --force *.rpm

[root@localhost mysql5.6-rpm]# systemctl start mysqld

[root@localhost mysql5.6-rpm]# systemctl enable mysqld

PHP安装步骤

经过上面的操作lam就已经完成了,下面将进行php的安装。

  • 安装所需工具
  1. 下载epel源并下载所需工具。
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

[root@localhost ~]#  yum -y install  libxml2-devel lzip2-devel libcurl-devel libmcrypt-devel openssl-devel bzip2-devel
  1. 安装libmcrypt加密工具
[root@localhost ~]# tar zxf /media/libmcrypt-2.5.7.tar.gz -C /usr/src

[root@localhost ~]# cd /usr/src/libmcrypt-2.5.7/

[root@localhost libmcrypt-2.5.7]# ./configure --prefix=/usr/local/libmcrypt && make && make install
  1. 安装php
[root@localhost ~]# tar zxf /media/php-5.6.27.tar.gz -C /usr/src

[root@localhost ~]# cd /usr/src/php-5.6.27/

[root@localhost php-5.6.27]# ./configure --prefix=/usr/local/php5.6 --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --enable-fpm --enable-sockets --enable-sysvshm --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --with-mhash --with-mcrypt=/usr/local/libmcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts && make && make install
  1. 提供php配置文件
[root@localhost ~]# cp /usr/src/php-5.6.27/php.ini-production /etc/php.ini

cp:是否覆盖"/etc/php.ini"? yes
  1. 为 php-fpm 提供脚本
[root@localhost ~]# cd /usr/src/php-5.6.27/

[root@localhost php-5.6.27]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

[root@localhost php-5.6.27]# chmod +x /etc/init.d/php-fpm

[root@localhost php-5.6.27]# chkconfig --add php-fpm

[root@localhost php-5.6.27]# chkconfig php-fpm on
  1. 提供 php-fpm 配置文件并编辑
[root@localhost php-5.6.27]# cp /usr/local/php5.6/etc/php-fpm.conf.default /usr/local/php5.6/etc/php-fpm.conf

[root@localhost php-5.6.27]# systemctl start php-fpm
  • 测试Apache与php的静/动分离
  1. 启用Apache服务的代理转发

 通过执行脚本来实现对脚本的编辑。

[root@localhost ~]# cd /sh

[root@localhost sh]# vim add.sh

#!/bin/bash

conf=/usr/local/httpd/conf/httpd.conf

sed -i '116s/^#//' $conf

sed -i '120s/^#//' $conf

sed -i '484s/^#//' $conf

sed -i '397aAddType application/x-httpd-php .php\nAddType application/x-httpd-php-source .phps' $conf

sed -i 's/DirectoryIndex index.html/DirectoryIndex index.php index.html/' $conf

[root@localhost sh]# sh add.sh

[root@localhost sh]# systemctl restart httpd
  1. 配置虚拟主机文件
[root@localhost ~]# vim /usr/local/httpd/conf/extra/httpd-vhosts.conf

删除httpd-vhosts.conf文件中的内容复制下面内容保存并退出即可

<VirtualHost *:80>

 ServerAdmin webmaster@benet.com

 DocumentRoot "/var/www/benet"

 ServerName www.benet.com

 ServerAlias benet.com

 ErrorLog "logs/benet.com-error_log"

 CustomLog "logs/benet.com-access_log" common

 ProxyRequests Off

 ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/benet/$1



<Directory "/var/www/benet">

 Options FollowSymLinks

 AllowOverride None

 Require all granted

</Directory>

</VirtualHost>
  1. 测试

(1)创建mysql用户密码

[root@localhost ~]# mysqladmin -uroot password

New password:

Confirm new password:

[root@localhost ~]# mysql -uroot -p123

mysql> grant all on *.* to testuser@'%' identified by '123456';

Query OK, 0 rows affected (0.00 sec)



mysql> exit

Bye

  1. 创建php测试网页
[root@localhost ~]# mkdir /var/www/benet

[root@localhost ~]# vim /var/www/benet/index.php

<?php

phpinfo();

?>

[root@localhost ~]# vim /var/www/benet/test1.php

<?php

$link=mysql_connect('192.168.1.3','testuser','123456');

if ($link)echo "connection success......";

mysql_close();

?>

重启服务后,使用客户机访问mysql浏览器就可以看到PHP网页了。

[root@localhost ~]# systemctl restart httpd

部署Discuz论坛

  1. 解压Discuz包
[root@localhost ~]# mkdir /data

[root@localhost ~]# cd /data

[root@localhost data]# cp -rp /media/Discuz_X3.3_SC_UTF8.zip /data

[root@localhost data]# unzip Discuz_X3.3_SC_UTF8.zip 

[root@localhost data]# mv upload/ /var/www/benet/bbs/

[root@localhost data]# chmod -R 777 /var/www/benet/bbs
  1. 修改配置文件并重启服务
[root@localhost ~]# sed -i '202s/Off/On/' /etc/php.ini

[root@localhost ~]# service php-fpm restart
  1. 创建bbs库及用户名

下述命令中,bbsdb为库名,runbbs为用户名,192.168.1.3为服务器IP,用户密码为123456。

[root@localhost ~]# mysql -uroot -p123

mysql> create database bbsdb;

Query OK, 1 row affected (0.00 sec)



mysql> grant all on bbsdb.* to runbbs@'192.168.1.3' identified by '123456';

Query OK, 0 rows affected (0.00 sec)
  1. 安装

安装discuz论坛,访问http://192.168.1.3/bbs

通过安装向导单击我同意,第二页检查安装环境,如无误点击下方下一步,选择全新安装单击下一步。按照下图填写用户名密码,需要注意的是,如客户端为本机需要把localhost改为服务器IP。

 

 

 

访问http://192.168.1.3/bbs即可登录。

访问http://192.168.1.3/bbs/admin.php可以访问论坛后台。

输入管理员密码后就可以看到后台页面了,管理员可以根据自己的需求修改添加等一系列操作。

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/5668.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【springboot进阶】优雅使用 MapStruct 进行类复制

项目中经常会遇到这样的一个情况&#xff1a;从数据库读取到数据&#xff0c;并不是直接返回给前端做展示的&#xff0c;还需要字段的加工&#xff0c;例如记录的时间戳是不需要的、一些敏感数据更是不能等等。传统的做法就是创建一个新的类&#xff0c;然后写一堆的get/set方法…

数据结构【队列】

文章目录&#xff08;一&#xff09;队列定义&#xff08;二&#xff09;队列实现&#xff08;1&#xff09;创建结构体&#xff08;2&#xff09;具体函数实现及解析1.1 初始化队列1.2入队列1.3出队列1.4取队首元素1.5取队尾元素1.6返回队列个数1.7判断是否为空1.8销毁队列&am…

springCloud的 consul的下载与安装

下载地址&#xff1a;Install | Consul | HashiCorp Developer 下载自己需要使用的版本 下载后会有一个exe 文件通过cmd 命令行来执行这个exe 文件consul agent -dev -client0.0.0.0 出现此页面后执行8500 端口 请求地址&#xff1a;http://127.0.0.1:8500/ 出现此页面说明启…

黑苹果入门:必备工具篇

以下给大家汇总的这些软件工具都是我们在安装使用黑苹果过程中可能会用到的&#xff0c;至于使用方法&#xff0c;在这里我就不做过多介绍了。 本次只提供软件下载地址&#xff0c;不提供使用方法&#xff0c;不知道如何使用软件工具的童鞋&#xff0c;可以在百度翻翻相关教程…

第5章 C语言高级的库函数

文章目录文档配套视频讲解链接地址第05章 C库函数5.1 assert.h 断言库5.2 ctype.h 测试和映射字符5.3 math.h 数学库5.4 stdlib.h 标准库1. 字符串转整数、浮点数2. strtod 把字符串中的数字转换成浮点数并返回数字的下一个字符的位置3. strtol 字符串转整数4. strtoul 字符串转…

vue3 antd多级动态菜单(二)后台管理系统(两种方法过滤有无子菜单children)

vue3 antd 多级动态菜单&#xff08;精修版本&#xff09; 两种方法实现对children的筛选相关文章推送&#xff08;供参考&#xff09;场景复现实现效果解决方法hasChildren与noChilren函数过滤v-if v-else判断有无children【推荐】&#x1f525;两种方法公用代码sunmmary下期预…

ESP32 入门笔记06: WIFI时钟 + FreeRTOS+《两只老虎》 (ESP32 for Arduino IDE)

ESP32FreeRTOS Esp32 模块中已经提供了 FreeRTOS&#xff08;实时操作系统&#xff09;固件。 FreeRTOS有助于提高系统性能和管理模块的资源。FreeRTOS允许用户处理多项任务&#xff0c;如测量传感器读数&#xff0c;发出网络请求&#xff0c;控制电机速度等&#xff0c;所有…

靶向肿瘤代谢,助力攻克癌症

肿瘤代谢的简介 肿瘤代谢的起源在于奥托沃伯格 (Otto Warburg) 的假设&#xff0c;他也因发现线粒体呼吸链复合物 IV 而获得 1931 年诺贝尔生理学或医学奖。Warburg 观察到&#xff0c;与正常组织相比&#xff0c;体外癌组织切片使用大量葡萄糖生成乳酸 (即使在有氧的情况下也是…

SBT10100VDC-ASEMI低压降贴片肖特基二极管SBT10100VDC

编辑-Z SBT10100VDC在TO-263封装里采用的2个芯片&#xff0c;其尺寸都是62MIL&#xff0c;是一款低压降贴片肖特基二极管。SBT10100VDC的浪涌电流Ifsm为150A&#xff0c;漏电流(Ir)为4uA&#xff0c;其工作时耐温度范围为-65~150摄氏度。SBT10100VDC采用金属硅芯片材质&#x…

QScintilla代码跳转时indicator工作不正确的问题

首先看我这几个文章&#xff0c;知道一下indicator是什么&#xff0c;以及上下文&#xff1a; https://biao2488890051.blog.csdn.net/article/details/126798996?spm1001.2014.3001.5502 目标&#xff1a; 我现在要做按住 ctrl 鼠标左键点击释放 发生函数/变量的 定义/声明…

Pandas中你一定要掌握的时间序列相关高级功能

&#x1f4a1; 作者&#xff1a;韩信子ShowMeAI &#x1f4d8; 数据分析实战系列&#xff1a;https://www.showmeai.tech/tutorials/40 &#x1f4d8; 本文地址&#xff1a;https://www.showmeai.tech/article-detail/389 &#x1f4e2; 声明&#xff1a;版权所有&#xff0c;转…

ceph浅谈

总谈 ceph简介 用上ceph&#xff0c;多台机器的磁盘空间在一起了&#xff0c;在一台机器上就可以看到使用所有空间。 还可以保存多份安全备份 存储先ceph&#xff0c;自我管理修复&#xff0c;跨机房&#xff0c;节点越多&#xff0c;并行化&#xff0c;论上&#xff0c;节点越…

【虚幻引擎UE】UE5 实现相机录制视频并导出(C++调用外部exe)

说明: 该功能暂不支持导出声音。 由于OpenCV3和UE5不太兼容,因此考虑制作外部exe实现视频合成。 一、创建渲染目标 二、创建Actor加场景捕获组件2D 三、创建UE5内的C++代码 1、实现 SavePicToFile 导出图片蓝图函数 .cpp文件 // Fill out your copyright notice in the De…

数字集成电路设计(二、Verilog HDL基础知识)

文章目录1. 语言要素1.1 空白符1.2 注释符1.3 标识符1.3.1 转义标识符1.4 关键字1.5 数值1.5.1 整数及其表示方式1.5.2 实数及其表示方式1.5.3 字符串及其表示方式2. 数据类型2.1 物理数据类型2.1.1 连线型2.1.2 寄存器型2.2 连线型和寄存器型数据类型的声明2.2.1 连线型数据类…

深入了解海豚调度DolphinScheduler

深入了解海豚调度DolphinScheduler一、海豚调度介绍二、海豚调度特性三、建议配置四、名词解释五、模块介绍六、功能介绍1.项目首页2.工作流定义3.工作流实例4.任务实例5.任务定义七、任务类型1.SQL2.SPARK节点3.Apache Zeppelin八、集群部署1.前置准备工作2.准备 DolphinSched…

实现注册与登录模块

目录 1、加载依赖 2、实现jwt工具类jwtUtil类 3、实现config.filter.JwtAuthenticationTokenFilter类 4、配置config.SecurityConfig类 5、创建后端api之前对数据库进行修改 6、写API一共需要的三个地方 7、实现三个接口 8、验证用户登录用API调试 9、https://jwt.io/解…

MySQL表的增删查改(CRUD)

文章目录前言一、新增数据二、查询数据全列查询指定列查询表达式查询指定别名查询去重查询排序查询条件查询分页查询三、修改数据四、删除数据前言 CRUD代表: 增加(create) ,查询(retrieve) ,更新(update) ,删除(delete) 单词首字母。 一、新增数据 SQL使用insert关键字来表…

二叉搜索树、红黑树详解、红黑树高的应用、TreeMap的应用(图文详解)-Kotlin版本代码

二叉搜索树 何为二叉搜索树&#xff1f; 二叉搜索树是一种特殊的二叉树&#xff0c;它的左子节点总是小于或等于根节点&#xff0c;而右子节点 总是大于或等于根节点。 如下图&#xff0c;即是一颗二叉搜索树。 对于二叉搜索树来说&#xff0c;中序遍历可以遍历按照节点值…

【JavaSE】重载和重写

前言&#xff1a; 作者简介&#xff1a;爱吃大白菜1132 人生格言:纸上得来终觉浅&#xff0c;绝知此事要躬行 如果文章知识点有错误的地方不吝赐教&#xff0c;和大家一起学习&#xff0c;一起进步&#xff01; 如果觉得博主文章还不错的话&#xff0c;希望三连支持&#xff01…

python--敲击木鱼积累功德小项目(更新版(2))

前言&#xff1a;前几天上课闲着没事写了一个python敲击木鱼积累功德的小项目&#xff0c;当时纯粹就是写着玩&#xff0c;回顾一下鼠标事件的东西还记不记得&#xff0c;发现这个博客的点赞和收藏量还挺高的&#xff0c;我当时也没有把它当回事&#xff0c;后面也有很多人问怎…