lamt安装部署

apache安装

关闭防火墙和selinux

[root@localhost ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# setenforce 0
[root@localhost ~]# vim /etc/selinux/config 

创建apache组和用户

[root@localhost ~]# groupadd -r apache
[root@localhost ~]# useradd -r -M -s /sbin/nologin -g apache apache

安装依赖包

[root@localhost ~]# yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ --allowerasing

下载和解压apr和apr-util

[root@localhost ~]# cd /usr/src/

[root@localhost src]# yum -y install wget

[root@localhost src]# wget https://downloads.apache.org/apr/apr-1.7.4.tar.gz

[root@localhost src]# tar xf apr-1.7.4.tar.gz
[root@localhost src]# wget https://downloads.apache.org/apr/apr-util-1.6.3.tar.gz

[root@localhost src]# tar xf apr-util-1.6.3.tar.gz
[root@localhost src]# ls
apr-1.7.4         apr-util-1.6.3         debug
apr-1.7.4.tar.gz  apr-util-1.6.3.tar.gz  kernels

安装apr和apr-util

[root@localhost src]# cd apr-1.7.4
[root@localhost apr-1.7.4]# sed -i '/$RM "$cfgfile"/d' configure

[root@localhost apr-1.7.4]# ./configure --prefix=/usr/local/apr

[root@localhost apr-1.7.4]# yum -y install make

[root@localhost apr-1.7.4]# make && make install

[root@localhost apr-1.7.4]# cd ..

[root@localhost src]# cd apr-util-1.6.3
[root@localhost apr-util-1.6.3]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

[root@localhost apr-util-1.6.3]# make && make install

下载并安装httpd

[root@localhost src]# wget https://downloads.apache.org/httpd/httpd-2.4.57.tar.gz

[root@localhost src]# tar xf httpd-2.4.57.tar.gz
[root@localhost src]# cd httpd-2.4.57
[root@localhost httpd-2.4.57]# ./configure --prefix=/usr/local/apache --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@localhost httpd-2.4.57]# 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 ~]# ln -s /usr/local/apache/include/ /usr/include/httpd
[root@localhost ~]# echo 'MANPATH /usr/local/apache/man' >> /etc/man.config

取消SERVERNAME注释

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

启动apache

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

安装mysql

[root@localhost ~]# yum -y install mariadb*

root@localhost ~]# systemctl enable --now mariadb

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

[root@localhost ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.3.28-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> set password = password('chenxi123');
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> quit
Bye

安装tomcat

安装依赖包

[root@localhost ~]# yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel

下载tomcat二进制包

[root@localhost ~]# wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.80/bin/apache-tomcat-9.0.80.tar.gz

[root@localhost ~]# tar xf apache-tomcat-9.0.80.tar.gz  -C /usr/local/

[root@localhost ~]# wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.93/bin/apache-tomcat-8.5.93.tar.gz

[root@localhost ~]# tar xf apache-tomcat-8.5.93.tar.gz -C /usr/local

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

[root@localhost local]# ln -s apache-tomcat-9.0.80 tomcat

[root@localhost local]#ls

[root@localhost local]# ls
apache                apr       etc      index.jsp  libexec  src
apache-tomcat-8.5.93  apr-util  games    lib        sbin     tomcat
apache-tomcat-9.0.80  bin       include  lib64      share

启动服务

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

[root@localhost tomcat]# ./bin/catalina.sh start
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:   
Tomcat started.

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

写一个Java页面

[root@localhost ~]# vim index.jsp
[root@localhost ~]# cat index.jsp
<html>
<head>
        <title>test page</title>
</head>
<body>
        <%
           out.println("chenxi");
        %>
</body>
</html>

[root@localhost ~]# mkdir /usr/local/tomcat/webapps/test
[root@localhost ~]# cp /usr/local/index.jsp /usr/local/tomcat/webapps/test/

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值