Linux服务器配置(一)

jdk,tomcat,nginx记录

最近公司买了三台服务器System x3650 M5用来跑公司的项目。现,记录一下真机部署与后期维护历程~

因为系统是服务器买来就装好的,所以避免不了有一些不符合应用场景的程序,服务等,首先使用yum grouplist命令来看看当前系统中已经包含哪些东西~

Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Group Process
Loading mirror speeds from cached hostfile
* base: mirrors.tuna.tsinghua.edu.cn
* extras: mirror.bit.edu.cn
* updates: mirror.bit.edu.cn
Installed Groups:
Java 平台
NFS 文件服务器
Perl 支持
SNMP 支持
X 窗口系统
万维网服务器
互联网应用程序
互联网浏览器
办公套件和生产率
图形管理工具
基本
字体
安全性工具
性能工具
打印客户端
打印服务器
拨号网络支持
服务器平台
桌面
桌面平台
桌面调试和运行工具
电子邮件服务器
目录客户端
硬件监控工具
继承 UNIX 兼容性
继承 X Windows 系统的兼容性
网络基础设施服务器
网络文件系统客户端
联网工具
调试工具
输入法
通用桌面
附加开发

系统默认安装了java平台,看看是不是我们想要的。

[root@hart ~]# java -version
java version "1.7.0_45"
OpenJDK Runtime Environment (rhel-2.4.3.3.el6-x86_64 u45-b15)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)

原来安装的是OpenJDK,好吧。我们自己动手换成我们自己常用的oracle jdk.那么首先我们要将OpenJDK卸载。

[root@hart ~]# rpm -qa | grep jdk
java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
[root@hart ~]# yum -y remove java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64 java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
....
....
....
Complete!
[root@hart ~]#

ok 卸载完成。

http://www.oracle.com/technetwork/java/javase/downloads/index.html

自行下载jdk


[root@hart hart]# tar -zxvf jdk-7u80-linux-x64.gz //解压jdk到当前目录下
[root@hart hart]# mkdir /usr/java
[root@hart hart]# mv jdk1.7.0_80/ /usr/java/jdk1.7
[root@hart jdk1.7]# vi /etc/profile
//在文件最后面添加
export JAVA_HOME=/usr/java/jdk1.7/
export PATH=$PATH:$JAVA_HOME\bin
export CLASSPATH=.
//保存 退出 :wq
[root@hart jdk1.7]# source /etc/profile
[root@hart jdk1.7]# java
[root@hart jdk1.7]# javac
[root@hart jdk1.7]# java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

Ok~JDK安装配置完成。下面安装tomcat

[root@hart tomcat]# ls
apache-tomcat-7.0.69.tar.gz
[root@hart tomcat]# tar -zxvf apache-tomcat-7.0.69.tar.gz
[root@hart tomcat]# ls
apache-tomcat-7.0.69 apache-tomcat-7.0.69.tar.gz
[root@hart tomcat]# mv apache-tomcat-7.0.69 tomcat7.0
[root@hart tomcat]# ls
apache-tomcat-7.0.69.tar.gz tomcat7.0

配置tomcat

[root@hart tomcat]# cd tomcat7.0/conf/
[root@hart conf]# ls
catalina.policy context.xml server.xml web.xml
catalina.properties logging.properties tomcat-users.xml
[root@hart conf]# vi server.xml
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" />
//port自行修改,最后加上URIEncoding="UTF-8"可以避免地址栏路径中文乱码问题
//在<Host>标签中添加以下代码,可以使tomcat访问虚拟路径
<Context docBase="/usr/filePath" path="/file" />
//此外,在context.xml中配置也可以
[root@hart conf]# vi web.xml
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<!-- 将false改为true-->
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

Ok,安装nginx

[root@hart nginx]# ls
nginx-1.8.1.tar.gz
[root@hart nginx]# tar -zxvf nginx-1.8.1.tar.gz
[root@hart nginx]# cd nginx-1.8.1
[root@hart nginx-1.8.1]# ./configure
[root@hart nginx-1.8.1]# ./configure
checking for OS
+ Linux 2.6.32-431.el6.x86_64 x86_64
checking for C compiler ... not found ./configure: error: C compiler cc is not found
//没有gcc,安装
[root@hart nginx-1.8.1]# yum -y install gcc
Complete!
[root@hart nginx-1.8.1]# ./configure
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
//安装pcre-devel
[root@hart nginx-1.8.1]# yum install pcre-devel
Total download size: 516 k
Is this ok [y/N]: y
Complete!
[root@hart nginx-1.8.1]# ./configure
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
//哎= =!安装zlib-devel
[root@hart nginx-1.8.1]# yum -install zlib-devel Total download size: 44 k
Installed size: 115 k
Is this ok [y/N]: y
Complete!
[root@hart nginx-1.8.1]# ./configure
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using builtin md5 code
+ sha1 library is not found
+ using system zlib library nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
//终于哦了~~~make
[root@hart nginx-1.8.1]# make install

nginx代理tomcat

//在/usr/local/nginx/conf/nginx.conf中:
//配置tomcat节点:在http节点内部,server节点外部
upstream tomcat-servers {
server ip:tomcatport;
}
//server节点内部:
location / {
proxy_pass http://tomcat-servers;
proxy_redirect off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_next_upstream http_502 http_504 error timeout invalid_header;
}

只是现在从别的机器还访问不了,怎么办呢?

[root@hart sbin]# vi /etc/rc.d/init.d/iptables
//加入以下这条规则
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
[root@hart sbin]# service iptables restart

ok.这样就可以访问啦~~

先这样简单的记录一下步骤。深入的运维管理,让我们一起慢慢学习。

Linux服务器配置(一)的更多相关文章

  1. Linux服务器配置之加载硬盘

    Linux服务器配置之加载硬盘 1.修改密码 passwd 2.测试密码是否成功 3.查看硬盘信息 fdisk –l 4.格式化分区 fdisk /dev/vdb 5.查看分区 6.快速格式化/dev ...

  2. Linux 服务器配置、运行、不用敲命令(新手必备!) - 宝塔全攻略建站一条龙

    Linux 服务器配置.运行.不用敲命令 WordPress 建站攻略 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整 ...

  3. 关于Linux服务器配置java环境遇到的问题

    关于Linux服务器配置java环境遇到的问题 将下载好的JDK安装包解压到/etc/local/路径下,安装完后用vim/etc/profile文件,在文件末尾添加 export JAVA_HOME ...

  4. Linux服务器配置DNS解析

    概述 DNS(Domain Name System,域名系统) DNS的作用,简单的说:就是把我们输入的网站域名翻译成IP地址的系统. 本文建立在已搭建好DNS服务器,这里讨论为linux机器配置DN ...

  5. Linux服务器配置多台虚拟主机

    2016年11月4日15:59:12 LAMP环境 参考:http://blog.itblood.com/nginx-same-ip-multi-domain-configuration.html 在 ...

  6. Linux服务器配置git服务

    前言 Git是一个非常著名的分布式版本控制系统,而广大开发者更是习惯在最大的远程仓库GitHub上提交自己的代码.但是有时候,一些小项目不值得放到GitHub上去,或是由于隐私问题不好在GitHub的 ...

  7. Linux服务器配置WEB应用日志文件到指定目录

    在Linux服务器上配置WEB应用程序日志到指定文件   服务器环境是 RedHat Linux, 其上运行的是 Apache + Tomcat,容器中运行的是我们公司的壹个小型电子商务网站,原来项目 ...

  8. 个人技术博客——linux服务器配置以及flask框架

    本次的软件工程实践,我负责我们组后台服务的搭建,我选用了bandwagon的服务器,安装的是Debian GNU/Linux,全程在root用户下操作,后端服务是用python的flask框架,数据库 ...

  9. Linux 服务器配置网站以及绑定域名

    Linux 服务器如何配置网站以及绑定域名 转载来源:http://www.xinnet.com/service/cjwt/idc/guanli/1424.html 以下列举一些 主机上常见的 Web ...

随机推荐

  1. eclipse项目中丢失的R包找回方法

    当我们项目中的R文件丢失的时候会令我们痛苦不已,怎样找回呢?总不能删了吧,那样心血会毁于一旦的,我们肯定不会那样做,那要怎么办呢?我这里提供三种方法: ​一,一般情况下这样: ​    ​方法一:选中 ...

  2. 《Linux命令行与shell脚本编程大全》第十二章 使用结构化命令

    许多程序要就对shell脚本中的命令施加一些逻辑控制流程. 结构化命令允许你改变程序执行的顺序.不一定是依次进行的 12.1 使用if-then语句 如下格式: if command then     ...

  3. 《Metasploit魔鬼训练营》第四章(下)

    p163 XSSF 默认kali 2.0中没有xssf,先下载:https://code.google.com/archive/p/xssf/downloads 将下载下来的zip文件解压,将其中的d ...

  4. 一篇不错的Gibbs Sampling解释文章,通俗易懂

    http://cos.name/2013/01/lda-math-mcmc-and-gibbs-sampling/  直接原文的链接了.原文写的不错,是中文博客中说的比较明白的了. 但为了保留文章,随 ...

  5. RecyclerView分割线——万能分割线

    参照网络上众多的分割线设计方法,对方法进行调整和修改,最终完成的比较通用的RecyclerView分割线,底部会附上参考网址,大家可以去看一下. 在正文之前,先说一下个人看法:研究下来,我发现,其实最 ...

  6. python中函数的参数解析

    python中函数的各种参数梳理: 1.形参:函数定义时传入的参数 2.实参:函数调用时传入的参数 (有形参必传实参,形参里自身特点可不传的,可传可不传) 3.缺省参数:不传为默认值,传了会覆盖(下面 ...

  7. 并发容器之写时拷贝的 List 和 Set

    对于一个对象来说,我们为了保证它的并发性,通常会选择使用声明式加锁方式交由我们的 Java 虚拟机来完成自动的加锁和释放锁的操作,例如我们的 synchronized.也会选择使用显式锁机制来主动的控 ...

  8. Unity3D_GUI (1)--按钮控件

    这是自己的第一篇记录自己的技术文章,自己还是个菜鸟,有错误之处还望大家能够多多指点. 下面记录的是自己在学GUI.Button的自己认知,这里用的是代码进行控制,当然当你学熟练了就可以直接使用GUI ...

  9. Python学习笔记整理总结【web基础】【web/HTML/CSS/JavaScript/DOM/jQuery】

    一.HTML HTML是英文Hyper Text Mark-up Language(超文本标记语言)的缩写,他是一种制作万维网页面标准语言(标记).相当于定义统一的一套规则,大家都来遵守他,这样就可以 ...

  10. python实战--数据结构二叉树

    此文将讲述如何用python实战解决二叉树实验 前面已经讲述了python语言的基本用法,现在让我们实战一下具体明确python的用法 点击我进入python速成笔记 先看一下最终效果图: 首先我们要 ...