Linux服务器配置(一)
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服务器配置(一)的更多相关文章
- Linux服务器配置之加载硬盘
Linux服务器配置之加载硬盘 1.修改密码 passwd 2.测试密码是否成功 3.查看硬盘信息 fdisk –l 4.格式化分区 fdisk /dev/vdb 5.查看分区 6.快速格式化/dev ...
- Linux 服务器配置、运行、不用敲命令(新手必备!) - 宝塔全攻略建站一条龙
Linux 服务器配置.运行.不用敲命令 WordPress 建站攻略 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整 ...
- 关于Linux服务器配置java环境遇到的问题
关于Linux服务器配置java环境遇到的问题 将下载好的JDK安装包解压到/etc/local/路径下,安装完后用vim/etc/profile文件,在文件末尾添加 export JAVA_HOME ...
- Linux服务器配置DNS解析
概述 DNS(Domain Name System,域名系统) DNS的作用,简单的说:就是把我们输入的网站域名翻译成IP地址的系统. 本文建立在已搭建好DNS服务器,这里讨论为linux机器配置DN ...
- Linux服务器配置多台虚拟主机
2016年11月4日15:59:12 LAMP环境 参考:http://blog.itblood.com/nginx-same-ip-multi-domain-configuration.html 在 ...
- Linux服务器配置git服务
前言 Git是一个非常著名的分布式版本控制系统,而广大开发者更是习惯在最大的远程仓库GitHub上提交自己的代码.但是有时候,一些小项目不值得放到GitHub上去,或是由于隐私问题不好在GitHub的 ...
- Linux服务器配置WEB应用日志文件到指定目录
在Linux服务器上配置WEB应用程序日志到指定文件 服务器环境是 RedHat Linux, 其上运行的是 Apache + Tomcat,容器中运行的是我们公司的壹个小型电子商务网站,原来项目 ...
- 个人技术博客——linux服务器配置以及flask框架
本次的软件工程实践,我负责我们组后台服务的搭建,我选用了bandwagon的服务器,安装的是Debian GNU/Linux,全程在root用户下操作,后端服务是用python的flask框架,数据库 ...
- Linux 服务器配置网站以及绑定域名
Linux 服务器如何配置网站以及绑定域名 转载来源:http://www.xinnet.com/service/cjwt/idc/guanli/1424.html 以下列举一些 主机上常见的 Web ...
随机推荐
- TextView SpannableString 使用之实现可点击超链接效果
TextView SpannableString 使用之实现可点击超链接效果 如果看到这里说明你对 TextView 已经有了一定的了解,至少已经使用过该控件显示文字过.现在来实现一些复杂一点的效果. ...
- linux如何查看端口被谁占用
1.查看端口是否被占用 [guosong@alice48 main]$ netstat -nlp|grep 6184 (Not all processes could be identified, n ...
- http2.4简单配置
前言: 上一篇博文说到了http的发展以及http完整请求响应的工作流程. 一.开篇: 从最简单的静态服务器开始. 之前说过,http是应用层协议,必定会在用户空间体现出具体的应用程序.常见的http ...
- CentOS6.9编译安装Nginx1.12
1:安装必要的库 Bash yum install gc gcc gcc-c++ pcre-devel zlib-devel openssl-devel 2:创建Nginx用户和组 Bash grou ...
- AES加密实现
起因 这段时间因为要对接一个外部接口,其参数的加密方式为AES,就需要学下AES的加密写法,但网上的资料不是很全,自己记录下遇到的坑: 基本写法 String str = "hello&qu ...
- Redis 持久化之RDB和AOP
Redis 持久化之RDB和AOP Redis 有两种持久化方案,RDB (Redis DataBase)和 AOP (Append Only File).如果你先快速了解和使用RDB和AOP,可以直 ...
- Python 学习之路
这个是我学python以来,写的的第一个小游戏,写的不好 题目:石头剪刀布 主要有两个难度 在普通模式,电脑是随机出 在噩梦下,就是不管你出什么,电脑都会赢你,牛逼吧 #Author:陈浩彬 impo ...
- Android App插件式换肤实现方案
背景 目前很多app都具有换肤功能,用户可以根据需要切换不同的皮肤,为使我们的App支持换肤功能,给用户提供更好的体验,在这里对换肤原理进行研究总结,并选择一个合适的换肤解决方案. 换肤介绍 App换 ...
- RAC(ReactiveCocoa)使用方法(二)
RAC(ReactiveCocoa)使用方法(一) RAC(ReactiveCocoa)使用方法(二) 上篇文章:RAC(ReactiveCocoa)使用方法(一) 中主要介绍了一些RAC中常见类的用 ...
- Function Programming - 柯里化(curry)
看到一篇非常不错的文章,这里分享给大家:http://www.jianshu.com/p/fa3568087881. 首先,柯里化的定义:你可以只透过部分的参数呼叫一个function,它会回传一个f ...