CentOS7服务器jdk8安装实战

下载jdk官网:

https://www.oracle.com/technetwork/Java/javase/downloads/jdk8-downloads-2133151.html

全局环境变量的配置文件:vi /etc/profifile

export java_HOME=/usr/local/jdk1.8 #这个路径要改,其余不需要改

export JRE_HOME=$JAVA_HOME/jre

export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH

export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

加载环境变量:source /etc/profifile

java -version

java version "1.8.0_211"

Java(TM) SE Runtime Environment (build 1.8.0_211-b12)

Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)

CentOS7 实战部署Tomcat网站服务器

Tomcat:是一个开源免费的Web应用服务器,性能稳定,是目前比较流行的Web应用服务器

tomcat官网下载:

https://tomcat.Apache.org/download-80.cgi

下载:

yum install -y wget

wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.43/bin/apache-tomcat-8.5.43.tar.gz

解压:tar -xf apache-tomcat-8.5.43.tar.gz

mv apache-tomcat-8.5.43 /usr/local/tomcat8

检查java环境:java -version

tomcat重要目录介绍

[root@localhost tomcat8]# ls -lrt /usr/local/tomcat8

total 132

drwxr-x---. 7 root root 76 Jul 5 04:53 webapps

-rw-r-----. 1 root root 16262 Jul 5 04:56 RUNNING.txt

-rw-r-----. 1 root root 7139 Jul 5 04:56 RELEASE-NOTES

-rw-r-----. 1 root root 3255 Jul 5 04:56 README.md

-rw-r-----. 1 root root 1726 Jul 5 04:56 NOTICE

-rw-r-----. 1 root root 57011 Jul 5 04:56 LICENSE

-rw-r-----. 1 root root 5407 Jul 5 04:56 CONTRIBUTING.md

-rw-r-----. 1 root root 19534 Jul 5 04:56 BUILDING.txt

drwxr-x---. 2 root root 4096 Aug 1 23:33 lib

drwxr-x---. 2 root root 29 Aug 1 23:33 temp

drwxr-x---. 2 root root 4096 Aug 1 23:33 bin

drwx------. 3 root root 4096 Aug 1 23:43 conf

drwxr-x---. 2 root root 4096 Aug 1 23:43 logs

drwxr-x---. 3 root root 21 Aug 1 23:43 work

bin:存放可执行命令,比如开启和关闭;

conf:配置文件;

Context.xml:Tomcat公用的环境配置,tomcat 服务器会定时去扫描这个文件

web.xml:Web应用程序描述文件,都是关于是Web应用程序的配置文件

server.xml:可以设置tomcat的端口号,添加虚拟机这些的,是对服务器的设置

tomcat-users.xml:用户配置文件

webapps:发布web应用;

lib:库文件;

关闭防火墙

systemctl stop firewalld.service

启动tomcat

sh startup.sh

查看是否监听tomcat

linux服务器项目部署(linux服务器常用企业服务的安装)(1)

测试能否访问测试页面:IP地址:8080

linux服务器项目部署(linux服务器常用企业服务的安装)(2)

CentOS7 实战源码部署apache网站服务器

Apache简介:

Apache软件基金会的一个开源免费的网页服务器,也是目前世界上使用最广泛的一种web server ,apache最出名的是它跨平台,高效和稳定,可以运行在几乎所有广泛使用的计算机平台上。其特点是简单、速度快、性能稳定,并可做代

理服务器来使用,并且可通过简单的 API 扩充,将 Perl/Python 等解释器编译到服务器中

源码编译安装 Apache:

组件apr官方网站:http://apr.apache.org/download.cgi wget http://mirror.bit.edu.cn/apache//apr/apr-1.7.0.tar.gz tar -xf apr-1.7.0.tar.gz

组件apr-util官方网站:http://apr.apache.org/download.cgi wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz tar -xf apr-util-1.6.1.tar.gz

apache官方网站:http://httpd.apache.org/download.cgi wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.39.tar.gz tar -xf httpd-2.4.39.tar.gz

yum install -y gcc*

yum install -y zlib-devel

yum install -y expat-devel

下载地址:https://ftp.pcre.org/pub/pcre/ tar -xf pcre-8.43.tar.gz cd pcre-8.43 mkdir -p /usr/local/pcre ./configure --prefix=/usr/local/pcre make && make install

cp -rf apr-1.7.0 /root/test/httpd-2.4.39/srclib/apr cp -rf apr-util-1.6.1 /root/test/httpd-2.4.39/srclib/apr-util

cd /root/test/httpd-2.4.39 mkdir -p /usr/local/apache ---------------------------------------------------------------------------------- ./configure \--prefix=/usr/local/apache \--sysconfdir=/usr/local/apache/etc \--with- apr=/home/test/apr-1.7.0 \--with-apr-util=/home/test/apr-util-1.6.1 \--with- included-apr \--with-pcre=/usr/local/pcre \--enable-deflate \--enable-expires \-- enable-headers \--enable-so \--enable-modules=most \--with-mpm=worker \--enable- rewrite ---------------------------------------------------------------------------------- 选项说明: --prefix #指定安装目录 --sysconfdir #指定配置文件的路径 --with-apr #指定依赖文件的路径 --with-apr-util #指定依赖文件的路径 --with-included-apr #增加编译效率的 --with-pcre #指定pcre正则表达式库安装路径 --enable-deflate #开启压缩文件提高速度节约带宽 --enable-expires #开启让浏览器缓存,减轻服务器压力,提高访问速度 --enable-headers #使得支持http头 --enable-so #使得支持动态模块 --enable-modules=most #使得支持大多数模块 --with-mpm=worker #使得Apache工作在worker模式下 --enable-rewrite #使得支持地址重写

make -j4 && make install

vi /usr/local/apache/etc/httpd.conf 输入:ServerName进行搜索 添加: ServerName www.sddzcyz.cn

ln -s /usr/local/apache/bin/* /usr/sbin/ #设置软连接 echo "export PATH=/usr/local/apache/bin:$PATH" >> /etc/profile #设置环境变量 source /etc/profile #加载环境变量 httpd -t #测试配置文件语法有没有错误 httpd -k start #启动apache服务 httpd -k stop #关闭apache服务 在防火墙关闭的条件下,打开浏览器,输入IP地址,成功打开apache测试页面

(1)make[1]: *** [xml/apr_xml.lo] Error 1 make[1]: Entering directory `/home/test/apr-util-1.6.1' /bin/sh /usr/local/apache/apr/build-1/libtool --silent --mode=compile gcc -g -O2 - pthread -DHAVE_CONFIG_H -DLINUX -D_REENTRANT -D_GNU_SOURCE -I/home/test/apr- util-1.6.1/include -I/home/test/apr-util-1.6.1/include/private - I/usr/local/apache/apr/include/apr-1 -o xml/apr_xml.lo -c xml/apr_xml.c && touch xml/apr_xml.lo xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory # include <expat.h> ^ compilation terminated. make[1]: *** [xml/apr_xml.lo] Error 1 make[1]: Leaving directory `/home/test/apr-util-1.6.1' make: *** [all-recursive] Error 1 错误原因:缺少xml 的解析器 解决方法:yum -y install expat-devel ---------------------------------------------------------------------------------- (2)configure 时 error: APR not found 错误详情: configure: checking for APR… no configure: error: APR not found. Please read the documentation. 错误原因:没有指定 Apache 必需组件 APR 或没有加–with-apr 选项指定 APR 的安装位置。 解决方法:安装 APR 并且加-–with-apr 选项指定正确的位置。 ---------------------------------------------------------------------------------- (3)configure 时-–with-apr 选项不正确 错误详情: configure: checking for APR… configure: error: –with-apr requires a directory or file to be provided configure: checking for APR… configure: error: the –with-apr parameter is incorrect. It must specify an install prefix, a build directory, or an apr-config file. 错误原因:-–with-apr 选项不能为空或者指定的 APR 的位置不正确 解决方法:指定正确的 APR 选项。其实系统中已经使用 yum 安装了 APR,却不 知道如何指定 yum 安装的 APR 的位置,故出此错误,也可以进行手动源代码编译安装 APR来解决这个错误。 ---------------------------------------------------------------------------------- (4)configure 时 error: APR-util not found 错误详情: configure: checking for APR-util… no configure: error: APR-util not found. Please read the documentation. 错误原因:没有安装 Apache 必需组件 APR-util 或没有加–with-apr-util 选 项指定 APR-util 的位置 解决方法:-–with-apr-util 选项指定正确的安装位置 ---------------------------------------------------------------------------------- (5)configure 时 error: pcre-config for libpcre not found 错误详情: checking for pcre-config… false configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/ 错误原因:没有安装 Apache 必需组件 PCRE 或没有加–with-pcre 选项指定 PCRE 的安装位置。 解决方法:安装 PCRE 并且加–with-pcre 选项指定正确的安装位置 ---------------------------------------------------------------------------------- (6)configure 时 error: Did not find pcre-config script at /usr/local/pcre2 错误详情: checking for pcre-config… false configure: error: Did not find pcre-config script at /usr/local/pcre2 错误原因: httpd 2.4.39 不支持 pcre2? 解决方法:下载 pcre-8.43 安装即可。 ---------------------------------------------------------------------------------- (7)启动 Apache 时提示设置 ServerName 错误详情: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message 错误原因:没有设置服务器名称 解决方法:vi /usr/local/apache/etc/httpd.conf

CentOS7 实战源码部署nginx网站服务器

Nginx是一款高性能的 HTTP 和反向代理服务器

1.高并发量:根据官方给出的数据,能够支持高达 50,000 个并发连接数的响应

2.内存消耗少:处理静态文件,同样起web 服务,比apache 占用更少的内存及资源,所有它是轻量级的

3.简单稳定:配置简单,基本在一个conf文件中配置,性能比较稳定,可以7*24小时长时间不间断运行

4.模块化程度高:Nginx是高度模块化的设计,编写模块相对简单

5.负载均衡服务器:Nginx可以做高并发的负载均衡,且Nginx是开源免费的,如果使用F5等硬件来做负载均衡,硬件成本比较高

6.可移植性高:Nginx代码完全用C语言编写

1.动态处理差:nginx处理静态文件好,耗费内存少,但是处理动态页面比较差

2.rewrite弱:虽然nginx支持rewrite功能,但是相比于Apache来说,Apache比nginx 的rewrite 强大。

安装gcc编译环境:

yum install -y gcc-c

安装zlib-devel库:

yum install -y zlib-devel

安装OpenSSL密码库:

yum install -y openssl openssl-devel

安装pcre正则表达式库:

下载地址:https://ftp.pcre.org/pub/pcre/ tar -xf pcre-8.43.tar.gz cd pcre-8.43 mkdir -p /usr/local/pcre ./configure --prefix=/usr/local/pcre make && make install

下载编译安装nginx:

nginx下载官网:http://nginx.org/en/download.html wget http://nginx.org/download/nginx-1.16.0.tar.gz mkdir -p /usr/local/nginx tar -xf nginx-1.16.0.tar.gz cd nginx-1.16.0 ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with- http_stub_status_module --with-pcre make && make install

启停nginx服务:

启动: /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 测试: /usr/local/nginx/sbin/nginx -t 关闭: /usr/local/nginx/sbin/nginx -s stop

打开浏览器测试能否访问到测试页面

linux服务器项目部署(linux服务器常用企业服务的安装)(3)

参考个人博客:cyz

,