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. 二:SQL映射文件

    二:SQL映射文件 1.SQL映射文件: (1)mapper:映射文件的根元素节点,只有一个属性namespace(命名空间) 作用:用于区分不同的mapper全局唯一 绑定dao接口即面向接口编程, ...

  2. JavaScript:在JS中截取字符串的方法

    这篇主要说一说截取字符串的方法,用于帮助自己缕清方法的作用,参数的意义,返回值,是否对于原来的字符串进行了操作等. 在javascript中,常见的截取字符串的方法有slice().substring ...

  3. SSM所需的jar

    首先去找struts的. http://struts.apache.org/ 下载最新的struts 2.3.7. http://www.springsource.org/spring-framewo ...

  4. 微信JS-SDK 选取手机照片并进行上传

    项目中遇到需要选取照片上传的需求,因为网页运行在微信的浏览器里面,所以用微信的 js-sdk 提供的选取照片功能,来进行项目开发.实际开发中需要用到微信web开发者工具,详细参考链接:https:// ...

  5. 模仿J2EE的session机制的App后端会话信息管理

    此文章只将思想,不提供具体完整实现(博主太懒,懒得整理),有疑问或想了解的可以私信或评论 背景 在传统的java web 中小型项目中,一般使用session暂存会话信息,比如登录者的身份信息等.此机 ...

  6. Struts2-045验证脚本

    #! /usr/bin/env python # encoding:utf-8 import urllib2 import sys from poster.encode import multipar ...

  7. 九、VueJs 填坑日记之在项目中使用jQuery

    很多人学习 js 都是从 jQuery 开始的,我也不例外.有时候进行一些操作的时候,还是感觉 jQuery 比较好用,那么,我们如何在项目中使用 jQuery 呢?这篇博文带你实践. 引用 jQue ...

  8. npoi导入导出

    NPOI是指构建在POI 3.x版本之上的一个程序,NPOI可以在没有安装Office的情况下对Word或Excel文档进行读写操作. NPOI是一个开源的Java读写Excel.WORD等微软OLE ...

  9. Linux上安装和卸载mysql数据库 (一)

    一.前言 第一次写博客,很激动同时有点畏惧,激动是我可以将我的经验进行分享,畏惧是我怕我写的东西,大家借鉴的时候,有些步骤不能成功.不过,我还是很有信息的,我分享的经验都是我搭建成功以后才分享出来.这 ...

  10. JavaScript中typeof,instanceof,hasOwnProperty,in的用法和区别

    一. typeof操作符 typeof操作符用于返回正在使用值的类型. // 使用原始值 let mNull = null; let mUndefined = undefined; let mStri ...