文章目录

  • 1. LAMP概述
  • 2. 源码安装步骤
  • 3. Apache
  • 3.1 概述
  • 4.1yum方式搭建LAMP架构
  • 5、 手工编译安装nginx


1. LAMP概述

LAMP架构是目前成熟的企业网站应用模式之一,指的是协同工作的一整台系统和相关软件,能够提供动态web站点服务及其应用开发环境

L:Linux 提供操作系统支持,提供一个环境支持
A:Apache 提供静态页面请求
M:MySQL 持久化保存数据/状态信息
P:PHP 处理动态页面请求

搭建顺序依次为:Linux,Apache,MySQL,PHP

2. 源码安装步骤

开源软件的源代码包一般为TarBall形式,扩展名为“.tar.gz”或“.tar.bz2”,都可以使用tar命令进行解压。

在编译应用程序之前,需要进入源代码目录,对软件的安装目录,功能选择等参数进行配置。

编译的过程主要是根据Makefile文件内的配置信息,将源代码文件进行编译而生成二进制的程序模块,动态链接库,可执行文件等。
配置完成后,只需要在源代码目录中执行“make”命令即可执行编译操作

编译完成后,就可以执行“make install”命令将软件的执行程序,配置文件,帮助文档等相关文件复制到Linux系统中了,也就是应用程序的最后“安装”过程。同样是在源代码目录中执行命令。

3. Apache

3.1 概述

1955年时,发布Apache服务程序的1.0版本
源于A Patchy Server,著名的开源web服务软件
由Apache软件基金会(ASF)负责维护
最新的名称为“Apache HTTP Server”

主要特点:
开放源代码,跨平台应用
支持多种网页编程语言
模块化设计,运行稳定,良好的安全性

4.1yum方式搭建LAMP架构

这里的LAMP架构,我们不采用之前用的手工编译安装,使用yum安装,搭建LAMP架构的服务器IP为14.0.0.27

[root@localhost ~]# yum install httpd httpd-devel -y  ##安装apache服务
[root@localhost ~]# yum install mariadb mariadb-server mariadb-libs mariadb-devel -y   ##安装轻量化数据库包
[root@localhost ~]# systemctl start mariadb.service 
[root@localhost ~]# netstat -ntap | grep 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      15604/mysqld        
[root@localhost ~]# mysql_secure_installation     ##数据库初始化设置
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y        ##设置数据库root密码
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] n        ##是否移除匿名用户
 ... skipping.

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n    ##是否不允许root远程登录
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] n   ##是否删除测试数据库
 ... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y     ##是否重新加载数据库
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[root@localhost ~]# yum install php -y   ##安装php服务

[root@localhost ~]# yum install php-mysql -y   ##安装php数据库

[root@localhost ~]# yum install -y php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-bcmath    ##安装php功能依赖包

[root@localhost ~]# cd /var/www/html/
[root@localhost html]# vim index.php
<?php
  phpinfo();
?>
[root@localhost html]# systemctl restart httpd

源码部署zabbix_php

源码部署zabbix_nginx_02

[root@localhost html]# vim index.php   ##修改php的网页首页,方便观察
<?php
  echo "this is apache web"
?>
[root@localhost html]# systemctl restart httpd

源码部署zabbix_Apache_03

5、 手工编译安装nginx

[root@localhost ~]# hostname nginx
[root@nginx ~]# cd /opt
讲软件包拷贝进来
[root@nginx opt]# ls
[root@nginx opt]# tar zvxf nginx-1.12.2.tar.gz 
[root@nginx opt]# cd nginx-1.12.2/
[root@nginx nginx-1.12.2]# useradd -M -s /sbin/nologin nginx
[root@nginx nginx-1.12.2]#  yum install pcre pcre-devel zlib-devel gcc gcc-c++ -y
[root@nginx nginx-1.12.2]# ./configure    
--prefix=/usr/local/nginx    
--user=nginx    
--group=nginx    
--with-http_stub_status_module 
[root@nginx nginx-1.12.2]# make && make install
[root@nginx nginx-1.12.2]# ln -s /usr/local/nginx/sbin/nginx  /usr/local/sbin
[root@nginx nginx-1.12.2]# vim /etc/init.d/nginx   ##制作service管理脚本
#!/bin/bash
#chkconfig:-  99 20
#description:Nginx Service Control Script
PROG="/usr/local/nginx/sbin/nginx"
PIDF="/usr/local/nginx/logs/nginx.pid"
case "$1" in
 start)
  $PROG
 ;;
stop)
   kill -s QUIT $(cat $PIDF)
 ;;
restart)
 $0 stop
 $0 start
 ;;
reload)
 kill -s HUP $(cat $PIDF)
 ;;
 *)
   echo "Usage:$0{start|stop|restart|reload}"
   exit 1
esac
exit 0

[root@nginx nginx-1.12.2]# chmod +x /etc/init.d/nginx 
[root@nginx nginx-1.12.2]# chkconfig --add /etc/init.d/nginx 
[root@nginx nginx-1.12.2]# yum install elinks -y
[root@nginx nginx-1.12.2]# service nginx start 
[root@nginx nginx-1.12.2]# systemctl stop firewalld
[root@nginx nginx-1.12.2]# setenforce 0
[root@nginx nginx-1.12.2]# elinks 14.0.0.14

源码部署zabbix_php_04

[root@nginx nginx-1.12.2]# vim /usr/local/nginx/conf/nginx.conf
 location ~ \.php$ {
            proxy_pass   http://14.0.0.27;
        }

[root@nginx nginx-1.12.2]# service nginx stop
[root@nginx nginx-1.12.2]# service nginx start

源码部署zabbix_Apache_05


源码部署zabbix_php_06