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. C#配合利用XML文件构建反射表机制

    在设计程序时,无论是界面或是后台代码,我们通常都想留给用户一个较为简单的接口.而我在参与封装语音卡开发函数包的时候,发现各种语音卡的底层函数的接口都是各种整形变量标记值,使用起来极为不变.于是就理解了 ...

  2. SQL Server多表同时查询

    今天在练sql server发现多条语句同时使用可以多表同时查询,具体操作如下: 代码示例: USE teachingGOSELECT *FROM dbo.teach_classORDER BY cl ...

  3. Python之re正则模块二

    13.编译的标志 可以用re.I.re.M等参数,也可以直接在表达式中添加"?(iLmsux)"标志 *s:单行,“.”匹配包括换行符在内的所有字符 *i:忽略大小写 *L:让&q ...

  4. 选择排序-Python与PHP实现版

    选择排序Python实现 import random # 生成待排序数组 a=[random.randint(1,999) for x in range(0,36)] # 选择排序 def selec ...

  5. 书籍推荐系列之一 -- 《凤凰项目:一个IT运维的传奇故事》

    博客已经完全更新了名字,新的名字,新的开始,想让自走向新的道路是很难的,走出舒适圈说了好久,也是时候开始行动了,今天就从写博客开始. 今天给大家推荐一本书,<凤凰项目:一个IT运维的传奇故事&g ...

  6. Java爬虫框架WebMagic——入门(爬取列表类网站文章)

    初学爬虫,WebMagic作为一个Java开发的爬虫框架很容易上手,下面就通过一个简单的小例子来看一下. WebMagic框架简介 WebMagic框架包含四个组件,PageProcessor.Sch ...

  7. 机器学习 F1-Score 精确率 - P 准确率 -Acc 召回率 - R

    准确率 召回率 精确率 : 准确率->accuracy, 精确率->precision. 召回率-> recall. 三者很像,但是并不同,简单来说三者的目的对象并不相同. 大多时候 ...

  8. windows下tensorflow的安装

    一.直接python安装 1.CPU版本: pip3 install --upgrade tensorflow 2.GPU版本:pip3 install --upgrade tensorflow-gp ...

  9. 转:聚类、K-Means、例子、细节

    今天说聚类,但是必须要先理解聚类和分类的区别,很多业务人员在日常分析时候不是很严谨,混为一谈,其实二者有本质的区别. 分类其实是从特定的数据中挖掘模式,作出判断的过程.比如Gmail邮箱里有垃圾邮件分 ...

  10. 《Linux命令行与shell脚本编程大全》第十八章 图形化桌面环境中的脚本编程

    18.1 创建文本菜单 直接上例子吧:   1 #!/bin/bash   2 function menu   3 {   4         clear   5         echo   6   ...