一.
- 含义
LAMP指的Linux(操作系统)、Apache HTTP 服务器,MySQL(有时也指MariaDB,数据库软件)和PHP(有时也是指Perl或Python)的第一个字母,一般用来建立web应用平台。
1.LAMP平台概述
什么是LAMP
目前最为成熟的-种企业网站应用模式, 可提供动态Web站点应用及开发环境
构成组件
Linux、Apache、 MySQL、 PHP/Per/Python
LAMP的优势
成本低廉
可定制、易于开发
方便易用、安全和稳定
目的:搭建LAMP架构,完成一个论坛的搭建
环境
版本:CENTOS7
服务器网络正常
APACHE
一、Apache网站服务
1.Apache简介
(1) Apache起源
源于A Patchy Server,著名的开源Web服务软件
1995年时,发布Apache服务程序的1 .0版本
由Apache软件基金会(ASF) 负责维护
最新的名称为“Apache HTTP Server”
官方站点: ht:/:ttdt .apache.org/
Apache简介2-2
(2)主要特点
开放源代码、跨平台应用(apr帮助跨平台)
支持多种网页编程语言
模块化设计、运行稳定、良好的安全性
(3)软件版本
1.X
目前最高版本是1.3,运行稳定
向下兼容性较好,但缺乏- 些较新的功能
2.X
目前最高版本是2.4.
具有更多的功能特性
与1.X相比,配置管理风格存在较大差异
编译安装httpd服务器
1.解压操作:
[root@localhost ~]# tar zxf httpd-2.4.38.tar.gz -C /usr/src/:讲网上下载的包解压到/usr/src
[root@localhost src]# cd /usr/src/httpd-2.4.38/ 进解压包httpd目录
2.配置编译安装操作
[root@localhost httpd-2.4.38]# ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
//--prefix:指定将httpd服务程序安装到哪个目录;--enable-so:启动动态加载模块支持,开启核心功能模块,使httpd具备扩展功能能力;--enable-rewrite:启用网页地址重写功能,做防盗链,网站优化及目录迁移维护;--enable-charset-lite:启用字符集支持,支持使用各种字符集编码的网页;--enable-cgi:启用CGI脚本程序支持,定义规范,便于扩展网页的应用访问能力。
[root@localhost httpd-2.4.38]# make && make install #编译安装
[root@localhost local]# cd /usr/local/httpd/
3.安装完成 进入/usr/local/httpd/ #httpd的路径
[root@localhost httpd]# ls
bin build cgi-bin conf error htdocs icons include logs man manual modules
bin:存放执行程序文件
conf:存放配置问价
htdoc:存放网页文档
logs:存放日志文件
modules:存放各种模块文件
cgi-bin:存放各种CGI程序文件
APACHE的开启
开启:[root@localhost bin]# ./apachectl
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.lo
caldomain. Set the 'ServerName' directive globally to suppress this message
出现警告,可以忽略 如果要消除,进入配置文件编辑 vim /usr/local/httpd/conf/httpd.conf
202行修改为: ServerName localhost:80 #修改保存后关闭重启后不会出现警告
[root@localhost bin]# ./apachectl -k stop #关闭
[root@localhost bin]# ./apachectl #打开
[root@localhost bin]# ss -lnt #查看端口占用
LISTEN 0 128 [::]:80 #apache默认80端口 成功打开 [::]:*
将编译安装的软件添加进系统服务里
CENTOS6风格
将/usr/local/httpd/bin/apachectl 文件拷贝到 /etc/init.d/ 并改名字为httpd
[root@localhost bin]# cp apachectl /etc/init.d/httpd
#apachectl 是httpd程序的启动脚本文件 /etc/init.d/ 系统服务存放位置
[root@localhost init.d]# vim httpd
在前面添加
#!/bin/bash
# chkconfig 35 85 21
---------------------------
[root@localhost init.d]# chkconfig --add httpd 将httpd添加进系统服务
[root@localhost init.d]# chkconfig --list httpd 查看系统服务列表 httpd
注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。
要列出 systemd 服务,请执行 'systemctl list-unit-files'。
查看在具体 target 启用的服务请执行
'systemctl list-dependencies [target]'。
httpd 0:关 1:关 2:关 3:开 4:关 5:开 6:关
[root@localhost etc]# service httpd start 开启服务
CENTOS7风格
[root@localhost init.d]# mv httpd httpd.bak 在etc/init.d/ 把httpd改为httpd.bak 让系统无法识别之前添加的httpd服务
[root@localhost system]# vim /lib/systemd/system/httpd.service 在里面新建一个文件编辑
escription=The Apache HTTP Server
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/httpd/logs/httpd.pid #写对
ExecStart=/usr/local/httpd/bin/apachectl $OPTIONS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RetartSec=42s
[Install]
WantedBy=graphical.target
[root@localhost system]# systemctl daemon-reload 加载系统服务配置文件
[root@localhost system]# systemctl start httpd
LISTEN 0 128 [::]:80 开启
3.httpd服务的