lamt

LAMT架构的部署

环境

系统主机名IP 安装的服务
redhat 8192.168.236.131httpd mysql tamcat
//关闭防火墙和seliunx
[root@localhost ~]# systemctl disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# vim /etc/selinux/config 
//安装yum源
[root@localhost ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
[root@localhost ~]#  curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
[root@localhost ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
安装httpd
//安装开发环境
[root@localhost ~]# yum  -y groups mark install 'Development Tools'


//创建apache服务的用户和组
[root@localhost ~]# groupadd  -r apache
[root@localhost ~]# useradd -r -M -s /sbin/nologin   apache apache

//安装apache依赖包
[root@localhost ~]# yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make
//解压
[root@localhost ~]# tar xf apr-1.6.5.tar.gz 
[root@localhost ~]# cd  apr-1.6.5
[root@localhost apr-1.6.5]# vim configure
    cfgfile=${ofile}T
    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
    # $RM "$cfgfile"   //将此行加上注释,或者删除此行
[root@localhost apr-1.6.5]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.6.5]# make && make install


[root@localhost ~]# tar xf apr-util-1.6.1.tar.gz 
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
[root@localhost apr-util-1.6.1]# make && make install

[root@localhost ~]# tar xf httpd-2.4.46.tar.gz
[root@localhost httpd-2.4.46]# ./configure --prefix=/usr/local/apache \
 --sysconfdir=/etc/httpd24 \
 --enable-proxy \
 --enable-proxy-connect \
 --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

[root@localhost httpd-2.4.46]# make && make install


//写环境变量
[root@localhost ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh
[root@localhost ~]# source /etc/profile.d/httpd.sh
[root@localhost ~]# which httpd
/usr/local/apache/bin/httpd

//软连接
[root@localhost ~]# ln -s /usr/local/apache/include /usr/include/apache
[root@localhost ~]# ll -d /usr/include/apache
lrwxrwxrwx 1 root root 25 Nov 28 15:41 /usr/include/apache -> /usr/local/apache/include


//取消ServerName注释             
[root@localhost ~]#  sed -i '/#ServerName/s/#//g' /etc/httpd24/httpd.conf


[root@localhost ~]# apachectl start
[root@localhost ~]# ss -antl
State    Recv-Q   Send-Q     Local Address:Port                  Peer Address:Port                
LISTEN   0        128              0.0.0.0:22                         0.0.0.0:*                   
LISTEN   0        128                    *:80                               *:*                   
LISTEN   0        128                 [::]:22                            [::]:*    

在这里插入图片描述

安装mysql

//创建用户和组
[root@localhost ~]# groupadd -r mysql 
[root@localhost ~]# useradd -M -s /sbin/nologin -g mysql mysql

//解压到/usr/local
[root@localhost ~]# tar xf mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz /usr/local/
//软连接
[root@localhost local]# ln -sv mysql-5.7.31-linux-glibc2.12-x86_64/ mysql

//修改目录/usr/local/mysql的属主属组
ot@localhost ~]# chown  -R mysql.mysql /usr/local/mysql
[root@localhost ~]# ll /usr/local/mysql -d
lrwxrwxrwx. 1 mysql mysql 36 Nov 26 16:32 /usr/local/mysql -> mysql-5.7.31-linux-glibc2.12-x86_64/

//添加环境变量
[root@localhost ~]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh   
[root@localhost ~]# . /etc/profile.d/mysql.sh 
[root@localhost ~]# echo $PATH 
/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

//建立数据存放目录
[root@localhost ~]# mkdir /opt/data
[root@localhost ~]# chown -R mysql.mysql /opt/data/
[root@localhost ~]# ll /opt/
total 0
drwxr-xr-x. 2 mysql mysql 6 Nov 26 16:53 data

//初始化数据库
[root@localhost ~]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data/
2020-11-26T08:54:19.554804Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-11-26T08:54:20.730893Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-11-26T08:54:20.817091Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-11-26T08:54:20.849560Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: f95aa789-2fc4-11eb-8a1f-000c29548350.
2020-11-26T08:54:20.850450Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-11-26T08:54:21.682486Z 0 [Warning] CA certificate ca.pem is self signed.
2020-11-26T08:54:21.966033Z 1 [Note] A temporary password is generated for root@localhost: Csm)ojuSd9ej


//生成配置文件
[root@localhost ~]# vim /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
skip-name-resolve

//配置服务启动脚本
[root@localhost ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost ~]# sed -ri 's#^(basedir=).*#\1/usr/local/mysql#g' /etc/init.d/mysqld
[root@localhost ~]# sed -ri 's#^(datadir=).*#\1/opt/data#g' /etc/init.d/mysqld



[root@localhost ~]# /usr/local/mysql/bin/mysql -uroot -p
Enter password: Csm)ojuSd9ej
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.31

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> 


//设置新密码
mysql> set password = password('123123') ;
Query OK, 0 rows affected, 1 warning (0.00 sec)

安装tamcat

//安装openjdk
[root@localhost ~]# yum -y install java-1.8.0-openjdk* 

//解压
[root@localhost ~]# tar xf apache-tomcat-10.0.0-M10.tar.gz -C /usr/local/
//软连接
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ln -s apache-tomcat-10.0.0-M10/  tomcat

//写一个hello world的java页面
[root@localhost ~]# cd /usr/local/tomcat/webapps/
[root@localhost webapps]# mkdir test
[root@localhost webapps]# cd test/
[root@localhost test]# pwd
/usr/local/tomcat/webapps/test

[root@localhost test]# cat index.jsp 
<html>
<head>
	<title>test page</title>

</head>
<body>
        <%
	    out.println("hello world");
	%>
</body>
</html>

在这里插入图片描述

配置虚拟主机

//启动代理模块
[root@wnz ~]# vim /etc/httpd24/httpd.conf 
//将下面三行取消注释
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
//配置虚拟主机
[root@localhost ~]# vim /etc/httpd24/httpd.conf 
Include /etc/httpd24/extra/httpd-vhosts.conf  #取消注释,启动虚拟主机文件

[root@localhost ~]# vim /etc/httpd24/extra/httpd-vhosts.conf 
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdocs"
    ServerName www.example.com
    ErrorLog "logs/www.example.com-error_log"
    CustomLog "logs/www.example.com-access_log" common
     ProxyRequests Off
     ProxyPass / http://192.168.236.131:8080/
     ProxyPassReverse / http://192.168.236.131:8080/
    <Directory "/usr/local/apache/htdocs">
        Require all granted
    </Directory>
</VirtualHost>
               


[root@localhost ~]# ss -antl
State   Recv-Q  Send-Q        Local Address:Port     Peer Address:Port  
LISTEN  0       128                 0.0.0.0:22            0.0.0.0:*     
LISTEN  0       1        [::ffff:127.0.0.1]:8005                *:*     
LISTEN  0       80                        *:3306                *:*     
LISTEN  0       100                       *:8080                *:*     
LISTEN  0       128                       *:80                  *:*     
LISTEN  0       128                    [::]:22               [::]:*     

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值