Lamt
安装apache
安装依赖
[root@czh ~]# dnf -y install gcc gcc-c++ pcre-devel zlib-devel openssl
openssl-devel make expat-devel libtool
解压后编译安装apache
[root@czh ~]# tar xf apr-1.7.0.tar.bz2
[root@czh ~]# cd apr-1.7.0/
[root@czh ~]# tar xf apr-util-1.6.1.tar.bz2
[root@czh apr-1.7.0]# vim configure (打开包里面的 configure 文件,将'$cfgfile'这一行注释掉 )
setopt NO_GLOB_SUBST
fi
cfgfile=${ofile}T
trap "$RM \"$cfgfile\"; exit 1" 1 2 15
# $RM "$cfgfile"
[root@czh apr-1.7.0]# ./configure --prefix=/usr/local/apr
[root@czh apr-1.7.0]# make & make install
[root@czh ~]# cd apr-util-1.6.1/
[root@czh apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@czh apr-util-1.6.1]# make & make install
[root@czh src]# tar xf httpd-2.4.43.tar.bz2
[root@czh src]# cd httpd-2.4.43/
[root@czh httpd-2.4.43]# ./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@czh httpd-2.4.43]# make & make install
#启动服务
[root@czh ~]# /usr/local/apache/bin/apachectl start
[root@czh local]# 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 [::]:22 [::]:*
LISTEN 0 128 *:80 *:*
mysql安装
下载安装包
[root@czh ~]# dnf -y install wget make tree ncurses-compat-libs vim
创建新的一个用户
[root@czh ~]# useradd -r -M -s /sbin/nologin mysql
解压安装包到/usr/local下
[root@czh ~]# tar xf mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz -C /usr/local
修改名字
[root@czh ~]# mv mysql-5.7.33-linux-glibc2.12-x86_64 /usr/local/
修改文件文件的属组和属主
[root@czh local]# chown -R mysql.mysql /usr/local/mysql/
设置环境变量
[root@czh mysql]# vim /etc/profile.d/mysql.sh
[root@czh mysql]# cat /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH
[root@czh mysql]# . /etc/profile.d/mysql.sh
[root@czh mysql]# which mysql
/usr/local/mysql/bin/mysql
创建一个存放数据的目录
[root@czh mysql]# mkdir /opt/mysql_data
[root@czh mysql]# chown -R mysql.mysql /opt/mysql_data/
[root@czh mysql]# ll /opt/
总用量 0
drwxr-xr-x. 2 mysql mysql 6 5月 5 15:25 mysql_data
初始化并会生成初始密码
[root@czh mysql]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/mysql_data/
2021-05-05T07:28:22.085737Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-05-05T07:28:22.383660Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-05-05T07:28:22.441499Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-05-05T07:28:22.502711Z 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: 78d56077-ad73-11eb-8a03-000c29284f0e.
2021-05-05T07:28:22.505086Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-05-05T07:28:23.405193Z 0 [Warning] CA certificate ca.pem is self signed.
2021-05-05T07:28:23.500882Z 1 [Note] A temporary password is generated for root@localhost: (?qFv=aIt1?x
生成配置文件
[root@czh mysql]# cat > /etc/my.cnf <<EOF
> [mysqld]
> basedir = /usr/local/mysql
> datadir = /opt/mysql_data
> socket = /tmp/mysql.sock
> port = 3306
> pid-file = /opt/mysql_data/mysql.pid
> user = mysql
> skip-name-resolve
> EOF
[root@czh ~]# cat /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/mysql_data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/mysql_data/mysql.pid
user = mysql
skip-name-resolve
[root@czh mysql]#
配置服务启动脚本 ,并且设置开机自动启动,并且启动mysql服务
[root@czh mysql]# cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@czh mysql]# sed -ri 's#^(basedir=).*#\1/usr/local/mysql#g' /etc/init.d/mysqld
[root@czh mysql]# sed -ri 's#^(datadir=).*#\1/opt/data#g' /etc/init.d/mysqld
[root@czh mysql]# service mysqld start
Starting MySQL.Logging to '/opt/data/czh.err'.
SUCCESS!
[root@czh mysql]# chkconfig mysqld on
[root@czh mysql]# chkconfig --list
[root@czh etc]# mysql -uroot -p' (?qFv=aIt1?x'
mysql> set password = password('123456')
安装tomcat
安装相应的依赖
[root@czh ~]# yum -y install java-11-openjdk.x86_64 java-11-openjdk-devel.x86_64
下载tomcat的安装包
[root@czh ~]# wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.45/bin/apache-tomcat-9.0.45.tar.gz
解压 并修改名字
[root@czh ~]# tar xf apache-tomcat-9.0.45.tar.gz -C /usr/local/
[root@czh ~]# cd /usr/local/
[root@czh local]# mv apache-tomcat-9.0.45/ tomcat
写一个hello world的java页面
[root@czh local]# vim index.jsp
[root@czh local]# cat index.jsp
<html>
<head>
<title>test page</title>
</head>
<body>
<%
out.println("Hellow World");
%>
</body>
</html>
[root@czh local]# mkdir /usr/local/tomcat/webapps/test
[root@czh local]# cp index.jsp /usr/local/tomcat/webapps/test/
测试
配置apache
取消注释
[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
Include /etc/httpd24/extra/httpd-vhosts.conf
然后在最后一排添加
<VirtualHost *:80>
DocumentRoot "/usr/local/apache/htdocs"
ProxyPass / http://192.168.31.140:8080/
ProxyPassReverse / http://192.168.31.140:8080/
<Directory "/usr/local/apache/htdocs">
Options none
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
把所有http的请求代理到 http://192.168.10.40:8080/ ,也就是 Tomcat 的访问地址
重启apache
[root@happy ~]# apachectl restart
[root@happy ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:80 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 80 *:3306 *:*
LISTEN 0 100 *:8080 *:*
LISTEN 0 128 [::]:22 [::]:*
测试