前言
此文主要记录nginx、apache、tomcat安装过程,仅供参考!
一、nginx安装
nginx环境安装
安装编译工具及库文件
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
PCRE 作用是让 Nginx 支持 Rewrite 功能 pcer包需要自己在网上寻找
参考链接:http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
tar zxvf pcre-8.45.tar.gz
cd pcre-8.45
./configure
make && make instal //编译安装
pcre-config --version //查看版本号
安装nginx
cd /usr/local/src/
wget https://nginx.org/download/nginx-1.20.2.tar.gz
cd nginx-1.20.2
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.45
make && make install
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx //建立快捷方式
nginx -t //检查配置文件
nginx //启动nginx
ps aux |grep nginx //检查nginx是否启动
二、安装tomcat
JDK环境搭建
下载JDK包
wget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz
解压JDK包
tar zxvf jdk-17_linux-x64_bin.tar.gz
创建JDK目录并把解压的包移动重命名
mkdir /usr/local/jdk
mv /usr/local/src/jdk-17.0.3.1/ /usr/local/jdk/jdk17
修改环境变量
vi /etc/profile
export JAVA_HOME=/usr/local/jdk/jdk17
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin
source /etc/profile //加载环境变量
查看java版本
java -version
tomcat安装
ghi使用迅雷下载tomcat包
https://dlcdn.apache.org/tomcat/tomcat-10/v10.0.20/bin/apache-tomcat-10.0.20.tar.gz
解压使用
tar zxvf apache-tomcat-10.0.20.tar.gz
cd /usr/local/src/apache-tomcat-10.0.20/bin
[root@192 bin]# ./startup.sh //开启tomcat
Using CATALINA_BASE: /usr/local/src/apache-tomcat-10.0.20
Using CATALINA_HOME: /usr/local/src/apache-tomcat-10.0.20
Using CATALINA_TMPDIR: /usr/local/src/apache-tomcat-10.0.20/temp
Using JRE_HOME: /usr/local/jdk/jdk17
Using CLASSPATH: /usr/local/src/apache-tomcat-10.0.20/bin/bootstrap.jar:/usr/local/src/apache-tomcat-10.0.20/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
ps aux | grep tomcat 检查tomcat是否安装
关闭防火墙和selinux
systemctl stop firewalld
setenforce 0
访问tomcat网站
三、Apache安装
apache依赖包安装
安装apr、apr-utils
yum install -y expat-devel
wget http://archive.apache.org/dist/apr/apr-1.6.5.tar.gz
wget http://archive.apache.org/dist/apr/apr-util-1.6.1.tar.gz
tar zxvf apr-1.6.5.tar.gz
cd apr-1.6.5
./configure --prefix=/usr/local/apr
rm: cannot remove 'libtoolT': No such file or directory //编译报错
cat configure | grep cfgfile -n
vi configure
30993:# $RM "$cfgfile" //将其注释
./configure --prefix=/usr/local/apr
make && make install
cd ../
cd apr-util-1.6.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
Apache安装
下载地址:https://dlcdn.apache.org/httpd/httpd-2.4.53.tar.gz
tar zxvf httpd-2.4.53.tar.gz
cd httpd-2.4.53
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared-most --enable-mpm-shared=all --with-mpm=event --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
make && make install
cd /usr/local/apache2/bin/
./httpd -k start
[root@192 bin]# ps aux | grep httpd
root 44383 0.0 0.2 75000 2444 ? Ss 09:06 0:00 ./httpd -k start
daemon 44384 0.0 0.4 363964 4256 ? Sl 09:06 0:00 ./httpd -k start
daemon 44385 0.0 0.4 363964 4256 ? Sl 09:06 0:00 ./httpd -k start
daemon 44386 0.0 0.4 429500 4788 ? Sl 09:06 0:00 ./httpd -k start
daemon 44517 0.0 0.4 363964 4260 ? Sl 09:08 0:00 ./httpd -k start
root 44817 0.0 0.0 112812 980 pts/0 R+ 09:26 0:00 grep --color=auto httpd
温馨提示
记得关闭防火墙、selinux