All posts by dotte

wpf开源项目整理

FrameWork:

Prism – Application framework which provides an implementation of a collection of design patterns (MVVM, EventAggregator, …) that are helpful in writing well structured and maintainable applications

UI:

Dragablz – Dragable and tearable tab control for WPF

MahApps.Metro – “Metro” or “Modern UI” for WPF applications

MaterialDesignInXamlToolkit – Material Design templates and styles for WPF

MaterialSkin  -Theming .NET WinForms, C# , to Google’s Material Design Principles.

Plot:

OxyPlot – Plotting library for .NET

Live-Charts –  Simple, flexible, interactive & powerful charts, maps and gauges for .Net

Common:

Newtonsoft.Json – JSON framework for .NET

WpfLocalizeExtension – Library for the localization

Sample:

WPF-Samples -Repository for WPF related samples

PrismMahAppsSample -Modular application sample based on the PRISM-Library and MahApps.Metro as UI

Prism-Samples-Windows -Samples that demonstrate how to use various Prism features

GearedExamples -A set of examples for the LiveCharts.Geared package

Projects:

MetroFtpClient  – FTP-Client (MahApps.Metro, OxyPlot, Prism)

BaiduPanDownloadWinform  -百度网盘不限速下载工具 (MahApps.Metro, Prism)

Others:

WPF 杂谈——开篇简言

How to install redis server on CentOS

In this tutorial we will learn, how to install redis server on CentOS 7 / RHEL 7 . The abbreviation of redis is REmote DIctionary Server. It is one the of the most popular open source,advanced key-value cache and store.

Project URL : http://redis.io/

Follow the given below steps to install redis server on CentOS 7 and Red Hat Enterprise Linux 7.

Install wget utility

Install wget command

yum install wget

Install EPEL repo

First we will install the EPEL repo. For more detail on EPEL repo, we suggest you to read our this post.

Because our system has x86_64 Operating System architecture, we will use only epel repo package for x86_64 . Search epel repo package as per your Operating System architecture(EPEL URL)

wget -r --no-parent -A 'epel-release-*.rpm' http://dl.fedoraproject.org/pub/epel/7/x86_64/e/

rpm -Uvh dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-*.rpm

It will create two epel’s repo file inside /etc/yum.repos.d
These are –
1. epel.repo
2.epel-testing.repo

[root@localhost ~]# ls -l /etc/yum.repos.d/
total 28
-rw-r--r--. 1 root root 1612 Jul  4 07:00 CentOS-Base.repo
-rw-r--r--. 1 root root  640 Jul  4 07:00 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 1331 Jul  4 07:00 CentOS-Sources.repo
-rw-r--r--. 1 root root  156 Jul  4 07:00 CentOS-Vault.repo
-rw-r--r--. 1 root root  957 Sep  2 12:14 epel.repo
-rw-r--r--. 1 root root 1056 Sep  2 12:14 epel-testing.repo
[root@localhost ~]#

Install redis server

Now use yum command to install redis server

yum install redis

Two important redis server configuration file’s path
1. /etc/redis.conf
2. /etc/redis-sentinel.conf

Now start the redis server after this.

systemctl start redis.service

Check the running status of redis server

systemctl status redis.service

To test the installation of Redis, use below given command

redis-cli ping

If the response output is PONG, it means installation is completed successfully.

[root@localhost ~]# redis-cli ping
PONG
[root@localhost ~]#

Start/Stop/Restart/Status and Enable redis server

To start redis server

systemctl start redis.service

To stop redis server

systemctl stop redis.service

To restart redis server

systemctl restart redis.service

To get running status of redis server

systemctl status redis.service

To enable redis server at system’s booting time.

systemctl enable redis.service

To disable redis server at system’s booting time.

systemctl disable redis.service

Listening Port Of Redis Server

Redis Server listens by default at port number 6379. Use below given ss command. (To learn more about ss command)

[root@localhost ~]# ss -nlp|grep redis
tcp    LISTEN     0      128            127.0.0.1:6379                  *:*      users:(("redis-server",19706,4))
[root@localhost ~]#

Note: On minimal installed CentOS 7/ RHEL 7,you wont get netstat command. Instead of netstat command, use ss command which is by default available on system.

Learn Redis : http://redis.io/documentation

Who is using redis: Who is using Redis

Redis配置文件参数说明

from:http://sharadchhetri.com/2014/10/04/install-redis-server-centos-7-rhel-7/

你没穷过你不懂,房地产已成一盘死棋!

你没穷过你不懂,房地产已成一盘死棋!(深度好文)

2017年已经注定的是中国中产嗷嗷叫的一年,此时起,『阶级固化』深入骨髓,我们越来越像一个那个我们曾经口诛笔伐的『万恶的资本主义』:

  1. 中产屌丝化:以土地恢复阶级划分。中产和屌丝的区别是谁的负债更多一点。
  2. 货币信仰裂痕:人民币信任度屡创新低,排列在房产、美元、食品之后。这年头连老太太都不敢存钱了,几乎全民押注人民币持续贬值,纷纷用资产来和央行对赌,去拼命购买无法印刷的土地。
  3. 阶级门票高涨:教育成为阶级军火,从幼儿园开始的新科举之路,一线城市一个孩子上学的开支等于买一辆解放军99式主战坦克。

中产们恐慌了,选择用房地产捍卫阶级。但是,当全社会60%以上的财富都在固定资产上的时候,几十万亿级别获利盘的规模是根本无法兑现的,一旦集体兑现,就挂了。

我们今天可以说,房产永远涨,这种心态,就像猪儿们都说,饲养员永远爱它一样。对于饲养员来说,99.9%的时间,是真的爱猪如子。等到足够肥,该出栏了,饲养员真正的思考的问题只有一个,最终采取的处理方式人道与否。

天地不仁,以万物为刍狗。就像筹码社群中发起的『学区房悖论』:为什么学区房值钱,而学历不值钱?为什么读了清华也买不起房,干嘛还要买学区房?根源不能讨论,但是出路需要思考。

对于筹码的读者而言,我们应该积极的思考:阶级竞争的本质是什么,终局是什么,下一步如何布局?

1
阶层竞争的本质与终局

我们集体攀爬社会阶层,归根结底,想争夺的是生存的选择权:时间+空间的自由。

过去,只有贵族才有的选。在1900年,美国人均寿命期望不过47岁,我国不会好于这个数字,只有李鸿章大人这种当朝一品贵胄,才能活过70岁,大部分老百姓的寿命会停止在40岁之前。

饥荒、战乱,在我们的DNA 里面留下了贪婪和恐惧的指令,一定要活下来,看到别人跑,就一定要跑的比别人快。我们都知道,每上升一个阶层,存活的概率就会极大提高。

1900年,美国人均期望寿命是47岁,中国数据暂缺

向上攀爬是没错的,只是时代发展太快了,我们的思维还在农业社会,时代却已经进入到互联网社会了。

筹码团队认为在中国,阶级竞争的焦点不会在房产停留太久,会很快向前切换,不断升级演变:

  1. 开局是地产(静态博弈,一劳永逸);
  2. 中场是教育(动态博弈,价值提升);
  3. 终局是时间(全局博弈,拿钱买命)。
2

静态博弈
地产改变命运的幻觉

地产的估值支撑,是生产资料的捆绑,是纳税管道,是农业思维形成的长期惯性:土地意味着一切。

恰好,地产可以参与信用的创造。在过去20年里,凡是参与政府共同做市,扩大房地产行业税基的开发商和囤房者,都撬动了大量财富。得益于此,我们国家从从资本紧缺、严重依赖美元,到资本泛滥到处投资,只花了不到20年,成果斐然。

如今,我们的地产已经达到GDP250% ,同时,大家对高价持有的物业也给予了越来越大的回报希望,可是接盘侠的人数和资金更多了吗?所有人都在说京沪永远涨,和上两轮股灾太像。

真正主导利益分配的不是房本,而是权力和更大的利益格局。京沪永远涨的前提是经济发展模式的永远不换轨。

我们的经济发展模式是在GDP+政治强化引导后的产物。GDP是1934年哈佛大学经济学家西蒙·史密斯·库兹涅茨在给美国国会的报告中正式提的,居然沿用到现在。 二战之前的指标,主要为了工业和战争服务,数量是一切的核心。70多年前的指标,指导70年后的经济发展,结果可想而知。

GDP忽视了系统熵,忽视了外部性,也无法衡量新技术的进步,只热衷于量的堆砌。这种被异化的命令,无异于神经毒素,永远推动着经济体走向肢端肥大症,并可能重现欧洲的早期的错误:为了工业,牺牲一切;为了发展,炮轰一切。

今天,为了GDP,通过房地产收割年轻一代,和为了炼钢,乱砍乱伐是根源一致的。 虽然代价实质上更大,但GDP的反馈却在鼓励我们继续下去。如果这种逆向激励持续下去,读书显然没有买房有用啊,人民币没有房本有用,我们又会重复晚清的教训:GDP全球第一,4亿人口,地大物博,但是被八国联军的百人小分队占领首都,典型的肢端肥大,毫无竞争力。

今天,技术加速进步,历史进程推进迭代速度10+倍于过去,人才的投资回报率轻松碾压房产。月租金3万的房子不常有,待遇超过3万的码农可是越来越多见。游戏的规则在慢慢改变,我们不能只看到财务回报,就以为自己主宰命运了。

3

 动态博弈
提升成功概率的阶级军火

我们一直看多教育,最终的估值是向军工体系看齐,是阶级竞争的工具,是提升成功概率的武器,是博弈从静态走向动态的标志。

因为,有了房产的中产阶级会发现,有限的顶层位置,依然关闭着。

房本一开始是敲门砖,后来站票都算不上。权力和资源的分配都是动态的。当全部的精英都聚集在北上广深,他们的子女在同一起跑线竞争,没有超过其他人的教育,只靠房产根本无法提高胜出概率。

重视教育并不是亚洲家长的偏执,而是社会发展的必然:

  1. 高薪工作所需的技能和知识壁垒在不断加高
  2. 技术的进步在加速阶层的洗牌和分化,高知阶层碾压底层是常态
  3. 保持足够强的学习能力是保持在本阶层的关键。

古人说,朝中不可无人,如今,是常春藤里不可无人。这些年里,从核弹、半导体、计算机、互联网、生物医药,金融市场,哪一项不是顶尖高知分子和顶层阶级全面收割落后分子/国家?智商税是这个地球上最重的赋税。

成为收割者集团的成员或者公民,是新生代父母的愿望。和中国一样,这催生了美国庞大的『高考复读班产业』。以总部在纽约的Kaplan卡普兰教育集团为例,1994年收入仅800万美元,如今已经是全球最顶尖的终身教育集团之一,收购了好多所大学,每年覆盖100万学生,年收入超过30亿美元,是巴菲特最爱的公司(华盛顿邮报旗下产业,因为太有钱而私有化),没有之一。

 

大陆中学生去香港参加美国高考。SAT是当下最火的考试

竞争还在延伸,许多贵族预备学校纷纷把学制下延到每年学费几万美元的贵族幼儿园,这些名牌幼儿园的入学名额有限,除了学费外,通常还会有10-20万美元额外的捐赠。

中国的教育市场也更加白热化,51talk(COE)、新东方(EDU)、好未来(TAL)、达内教育(TEDU),正保远程教育(DL)等,是国内赴海外上市公司数量最多的板块。 其中,新东方和好未来,更是阿里和百度之后,最大的中概旗舰,估值的持续上涨,折射了从资本到需求的全面看多。

教育的终极是什么? 目前看,更像软件业。想想看,为PC 安装操作系统的微软,市值2000亿美元,为人类安装操作系统的教育产业,怎么可能价值更低呢?在人类社会的动态博弈中,教育的需求是长期的,动态的,就像武器一样,你可以不用,但不能没有,捍卫阶层和Offer的时候,你绝不会后悔多一个技能。

4

全局博弈
时间战场的终极支配和自由

 

全球年龄中位数

老龄化正在重塑整个世界。

我们不妨看看全球的年龄中位数,中国中位数年龄已经高达36.7岁,即:有50%的人的年龄> 36.7岁。这样的中国,是3000多年中国历史,乃至100万年的人类进化史从来没有的现象。

全世界,10亿以上的人口在未来进入80-100岁区间,我们的一切基础设施都没有准备好,谁能够多活几年,就变成了医疗行业的最残酷的资源竞价。

大量富裕的老年人,推动了时间价值的全面重估。拿钱买命,是持续很多年的投资的核心逻辑。拿钱续命的价格比房子便宜算我输。

 

1970-2014年,Y轴是全球预期寿命,X轴是每年健康开支

寿命预期突破100岁,医疗开支超过1万美元指日可待

本来,命是无法延续的,时间对所有人都是公平的。但是技术进步,药品会帮助人类穿越时间线,让时间真正的不公平起来,实现真正的阶级不平等。

一个场景:2067年,80岁的小明办理了退休,确实老了,自己的DNA健全程度越来越差,疾病和癌变始终伴随着他。虽然寿命快到了,可是家里还有110岁的老娘要赡养,自己买不起延寿的药物,更换不起器官和身体,只能慢慢走向死亡。公司里的健身房,癌症痊愈后的董事长还在美女教练的陪伴下举铁,110多岁的人了,花了15亿更换了心肺,注射了 1针2000万的抗衰老药物,如今看起来和50岁的人差不多。

对于小明来说,时间公平吗?

公平将最终被消灭,就好像它从未存在过一样。国家将变成一个付费网游社区,能够活多久,取决于你创造的价值,或者你充值的费用。

 

这只是一个做牙箍、卖水光针的企业:艾利科技 (Nasdaq: ALGN),16年超过100倍

我们要知道,衰老和癌变是医学界的两座大山,技术正在狠狠的攻击这两座大山,并有望在10年内确定性的取得重大突破。

最近暴涨的Kite Pharma(NASDAQ:KITE)在研制CAR-T新药Axicabtagene Ciloleucel,这药大致原理就是:

  1. 从病人身上提取合适的免疫T细胞;
  2. 基因改造这个细胞,类似于装上GPS专门打击癌细胞;
  3. 大量培养这种改造过的免疫细胞;
  4. 注射回病人体内;
  5. 开挂的T细胞开始在体内扫荡癌细胞。

这种治疗中,安装不同的GPS(靶点)就是应对不同的癌症类型。目前还没有一个CAR-T上市。Kite这药如果顺利将是人类第一个获批的CAR-T治疗,这种治疗手段极为暴力,效果明显,但是有小概率直接把病人毒死。

 

 

同样,衰老的大山在人类的进攻中走向坍塌。

数十年的研究终于有所突破,美国加州大学的博士后研究员伊莉莎·拉扎里(Elisa Lazzari)研究发现,细胞的RNA具有可用于识别细胞衰老的特性,因此,可以尝试在细胞DNA年老力衰时,用人工接管RNA来控制基因表达合成蛋白质。在这种思路指导下,阿肯色州的研究团队已经研制出一种新化合物 ,成功清除老鼠身血液里的老化造血细胞,使老鼠的造血功能保持活力。进而使老鼠的整个身体状况都得到改善。在人类医院中,这种RNA手段的疗法已经被引入临床,在癌症和感染等科室中使用。

 

社会发展指数和人均GDP

技术的进步,将我们人类的竞争,甚至最终的货币体系,都指向时间战场。治疗癌症、延长2年寿命、换一个心脏,都是明码标价,并与时间挂钩。当我们看着高等阶级的大人物,有能力向天再借500年的时候,他的孩子开始从云端下载各项逆天的技能的时候,还是普通寿命的你,看着一事无成的傻逼孩子,还会守着去炒房么?

我们的时代在加速前行。不要停留在过去的估值体系里面陶醉,甚至拼命加杠杆。时间将成为终极的成本,人口是终极的资源,阶级,还是终极的稀缺。

爸爸和儿子的幽默对话

爸爸和儿子的幽默对话,佩服!值得存五十年

01
儿两岁。某日,头撞桌角,长一包,大哭。
一分钟余,我走向桌子,大声问:
“桌子呀,是谁把你撞疼了?哭得这么伤心?”
儿止哭,泪眼看我。我抚桌,冲儿问:
“谁呀?谁撞疼了桌子?”
“我,爸爸,我撞的!”
“哦,是你撞的,那还不快向桌子鞠个躬,说对不起!”
儿含泪,鞠躬,说:“对不起。”
自此,儿学会了责任和担当!

02
儿三岁。无故大哭,我问:
“咋了,哪不舒服?”
“没有不舒服。”
“那为什么哭!”
“就是要哭!”明显撒娇。
“好吧,你要哭我们都没意见,可是你在这儿哭不合适,会打扰我们说话的,爸爸给你找个地方,你一个人好好哭,哭够了再叫我们。”
说完将儿关进了洗手间:“哭完了敲门。”
2分钟,儿拍门:“爸爸,爸爸,我哭完了!”
“好,哭完了?哭完了就出来吧。”
至今,儿18岁,仍未学会操纵和迁怒。

03
儿5岁。傍晚,牵儿散步经小桥,桥下碧水见底,暗流汹涌。儿仰头看我:
“爸爸,小河好美,我想跳下去游泳。”
我一愣:
“好吧,爸爸跟你一起跳。不过我们先回家,换一下衣服。”
回家,儿换衣毕,见一盆水在面前,困惑。
“儿子,下水游泳得把脸埋进水里,这你懂吧?”儿点头。
“那我们现在就先练习一下,看看你能埋多久。”我看表。
“好!”儿把脸埋进水里,豪气冲天?仅10秒:
“呸呸,爸爸,呛水了,好难受。”
“是吗?等等跳到河里,可能会更难受些。”
“爸爸,我们可以不去跳吗?”
“好吧,不去就不去了。”
从此,儿学会了谨慎而不冒失,三思而后行。

04
儿6岁,好吃。某晚,放学经麦当劳,驻足:
“爸爸,麦当劳!”垂涎欲滴。
“嗯,麦当劳!想吃?”
“想吃!”
“儿子,一个人想吃就吃呢,叫狗熊;想吃而能不吃呢,叫英雄。”
接着问:“儿子,你要做英雄呢还是做狗熊?”
“爸爸,我当然要做英雄!”
“好!那英雄,想吃麦当劳时会怎样呢?”
“能不吃!”很坚定!
“太棒了,英雄!回家吧。”
儿流着口水,随我回。
从此,儿学会了有所为而有所不为,经得起诱惑。

05
儿8岁,顽皮,与大同学打架。伤痕累累,回,大哭不止。
“委屈?”
“委屈!”儿泣答。
“愤怒?”
“愤怒!”儿嚎啕。
“你打算怎么办?”再问,“需要爸爸为你做点什么?”
“爸爸,我要找块砖头,明天从背后去砸他!”
“嗯,我看行!爸爸明天为你准备砖头。”继续问,“还有呢?”
“爸爸,你给我弄把刀,我明天从背后去捅他!”
“好!这个更解气,爸爸这就去准备一下。”
我上楼。
理解支持,儿渐平静。约20分钟,我从楼上搬一大堆衣服及棉被。
“儿子,你决定了吗?是用砖头,还是用刀呀?”
“但是,爸爸,你搬那么多衣服被子干吗?”儿困惑。
“儿子,是这样的:如果你用砖头砸他,那么警察就会把我们带走,在监狱里大概只要住一个月,我们就带些短衣薄被就可以;如果你用刀子捅他,那么我们在监狱里至少3年回不来,我们可要多带些衣服被子,四季都要带齐?”
“所以,儿子你决定了吗?爸爸愿意支持你!”
“要这样的?”儿惊愕。
“是这样的,法律是这样规定的!”我趁机普法。
“爸爸,那我们就不干了吧?”
“儿子,你不是很愤怒吗?”
“嗨嗨,爸爸,我已经不愤怒了,其实我也有错。”儿脸红。
“好,爸爸支持你!”
自此,儿学会了选择和代价。

06
儿9岁,四年级,数学不及格,闷闷不乐。
“怎么了?考试不及格,还给我们脸色。”
“因为数学老师很讨厌,她的课不爱听。”理直气壮。
“哦,怎么个讨厌法?”我很感兴趣。
“…….”儿说了很多,“总之她也不喜欢我。”
“哦,别人喜欢你,你就喜欢她;别人不喜欢你,你就讨厌她。这说明你是个主动的人还是被动的人?”
“是个被动的人!”儿子回答。
“是强者,还是弱者?是大人,还是小人?”继续问。
“是弱者,是小人!”儿怯怯。
“那你要做大人,还是小人?”
“做大人!爸爸,我知道了:无论老师喜不喜欢我,我都可以去喜欢她,尊敬她,主动影响她,做一个强者。”
翌日,开心上学,数学从此优秀。并知道了何为大人,何为小人。

07
儿10岁,玩游戏。妻屡教,子不改。
“儿子,听说你每天玩这个?”我指着电脑。
“嗯。”承认,低头!
“每次玩完之后,什么感受?”
“茫然,空虚,没劲,自责,看不起自已?”
“那为什么还玩呢?把持不住自己,是不?”
“是的,爸爸。”儿很无助。
“好!爸爸帮助你!”我搬来电脑,给儿子一小锤,“儿子,砸了它!”
“爸爸!”儿惊愕!
“砸了它,爸爸可以没有电脑,但不能没了儿子!”
儿流泪,亲手砸了电脑!
从此,儿懂得了什么叫原则。

How to Install Apache Tomcat on CentOS

Apache Tomcat is an open source Java Servlet implementation developed by the Apache Software Foundation. Beside Java Servlets, Tomcat implements several other Java server technologies including  JavaServer Pages (JSP), Java Expression Language, and Java WebSocket. Tomcat provides an HTTP Web Server for Java applications with support for HTTP/2, OpenSSL for JSSE and TLS virtual hosting.

In this tutorial, I will show you how to install and configure Apache Tomcat 8.5 on a CentOS 7 server and how to install and configure Java on a CentOS server which is one of the prerequisites for Tomcat.

Prerequisites

  • Server with CentOS 7 – 64bit
  • 2 GB or more RAM (Recommended)
  • Root Privileges on the server

Step 1 – Install Java (JRE and JDK)

In this step, we will install the Java JRE and JDK from the CentOS repository. We will install Java 1.8.11 on the server with the yum command.

Run this command to install Java JRE and JDK from CentOS repository with yum:

yum -y install java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64

It will take some time, wait until the installation finished.

Then you should check the Java version with the command below:

java -version

You should see results similar to the ones below:

openjdk version “1.8.0_111”
OpenJDK Runtime Environment (build 1.8.0_111-b15)
OpenJDK 64-Bit Server VM (build 25.111-b15, mixed mode)

Check the Java version

Step 2 – Configure the Java Home Environment

In the first step, we’ve installed Java. Now we need to configure the JAVA_HOME environment variable on the CentOS server so that Java applications can find the right Java version and Tomcat requires the JAVA_HOME environment to be setup properly, so we need to configure it.

Before we configure the JAVA_HOME environment, we need to know where the Java directory is. Check the Java directory with the command below:

sudo update-alternatives –config java

Java directory = “/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-1.b15.el7_2.x86_64/jre

Then edit the environment file with vim:

vim /etc/environment

Add the JAVA_HOME environment variable by adding the configuration below:

JAVA_HOME=”/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-1.b15.el7_2.x86_64/jre”

Save the /etc/environment file and exit vim.

Next, edit the .bash_profile file and add the JAVA_HOME variable as well:

vim ~/.bash_profile

At the end of the file, paste the configuration below:

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-1.b15.el7_2.x86_64/jre
export PATH=$JAVA_HOME/bin:$PATH

Save the file, then reload the bash_profile file.

source ~/.bash_profile

Make sure there is no error, Finally check the JAVA_HOME environment variable:

echo $JAVA_HOME

You will see Java path directory.

Setup the Java home environment variable

Step 3 – Install Apache Tomcat 8.5

In this step, we will install Apache Tomcat under the user tomcat (which we have to create first).

Create a user and group named tomcat:

groupadd tomcat
useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat

Note:
-s /bin/false = disable shell access
-g tomcat = assign new user to the group tomcat
-d /opt/tomcat = define the home directory for the user

Next, go to the /opt directory and download tomcat with the wget command:

cd /opt/
wget http://mirror.wanxp.id/apache/tomcat/tomcat-8/v8.5.6/bin/apache-tomcat-8.5.6.tar.gz

Extract Tomcat and move all the files and directories that are in the ‘apache-tomcat-8.5.6’ directory to the ‘tomcat’ directory.

tar -xzvf apache-tomcat-8.5.6.tar.gz
mv apache-tomcat-8.5.6/* tomcat/

Now change the owner of the tomcat directory to the tomcat user and group.

chown -hR tomcat:tomcat tomcat

Step 4 – Test Apache Tomcat

In step 3, we installed and configure tomcat. In this step, we just want to run a short test to make sure there are no errors.

Go to the tomcat/bin directory and run the command ‘startup.sh’ to test Apache Tomcat:

cd /opt/tomcat/bin/
./startup.sh

Make sure the result is ‘Tomcat started’.

Tomcat is using port 8080 now, check the open port on the server with the netstat command.

netstat -plntu

Check that Tomcat has been started with netstat

Or visit the server IP address with port 8080 – in my case 192.168.1.120:8080 – with a web browser. You will see the Apache Tomcat default page.

Test Apache Tomcat with a Browser

Next, stop Apache Tomcat and because we will run it Tomcat with a systemd service file in the final configuration. Make sure the tomcat directory is owned by the tomcat user and group.

cd /opt/tomcat/bin/
./shutdown.sh
chown -hR tomcat:tomcat /opt/tomcat/

Shutdown Apache Tomcat server test.

Step 5 – Setup Apache Tomcat Service

In this tutorial, we will run Apache Tomcat as tomcat user with a systemd service file for easy starting and stopping of the service. So the next step is to create a ‘tomcat.service’ file.

Go to the systemd system directory and create a new file ‘tomcat.service’.

cd /etc/systemd/system/
vim tomcat.service

Paste the configuration below:

[Unit]
Description=Apache Tomcat 8 Servlet Container
After=syslog.target network.target
 
[Service]
User=tomcat
Group=tomcat
Type=forking
Environment=CATALINA_PID=/opt/tomcat/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
Restart=on-failure
 
[Install]
WantedBy=multi-user.target

Save the file and exit vim.

Reload the systemd daemon, then start and add the Apache Tomcat service at boot time.

systemctl daemon-reload
systemctl start tomcat
systemctl enable tomcat

Now check that tomcat is running by checking the open port 8080.

netstat -plntu

And check the tomcat status, make sure the service is active.

systemctl status tomcat

Check Tomcat service started with Systemd

Step 6 – Configure Apache Tomcat Users

In this step, we will configure the users for Apache Tomcat. Tomcat is installed, and it’s running by default on port 8080, we can access it with a web browser, but we can not access the site-manager dashboard yet. To enable and configure Tomcat users, edit the file ‘tomcat-users.xml’.

Go to the tomcat configuration directory and edit the tomcat-users.xml file with vim.

cd /opt/tomcat/conf/
vim tomcat-users.xml

Create a new line under line 43 and paste configuration below:


Save the file and exit vim.

Next, go to the manager directory and edit the context.xml file.

cd /opt/tomcat/webapps/manager/META-INF/
vim context.xml

Comment out line 19 and 20.



Save the file and exit vim.

Go to the host-manager directory and edit the context.xml file again.

cd /opt/tomcat/webapps/host-manager/META-INF/
vim context.xml

Comment out again line 19 and 20.



Save the file and exit, then restart tomcat.

systemctl restart tomcat

Step 7 – Configure Firewalld

In CentOS 7, we have a default firewall tool named firewalld. It replaces the iptables interface and connects to the Netfilter kernel code.

In this step, we will start the firewalld service and open port 8080 so we can access the Apache Tomcat server from the outside of the network.

Start the firewalld service and add it to start at boot time with the systemctl command.

systemctl start firewalld
systemctl enable firewalld

Next, add the apache tomcat port 8080 to the firewall with the firewall-cmd command, and reload the firewalld service.

firewall-cmd –zone=public –permanent –add-port=8080/tcp
firewall-cmd –reload

Check that all the services are available in the firewall and check that the Apache Tomcat port 8080 is open.

firewall-cmd –list-ports
firewall-cmd –list-services

Apache Tomcat port 8080 is accessible from outside of the network, and the ssh port is open by default as well.

Start Apache Tomcat Service with Systemd

Step 8 – Testing

Open your web browser and type in your server IP with port 8080. You will see the Apache Tomcat default page.

http://192.168.1.120:8080

Apache Tomcat Home page

Go to the manager dashboard with URL below:

http://192.168.1.120:8080/manager/html

Type in the admin username ‘admin‘ with password ‘mypassword‘, the configuration that we made on step 5.

Apache Tomcat Manager Dashboard

Now go to the host-manager dashboard with URL below:

http://192.168.1.120:8080/host-manager/html

Enter the admin user and password that you set in step 5, you will see the Tomcat Virtual host Manager.

Apache Tomcat Virtual Host Manager Dashboard

Apache Tomcat 8.5 has been installed on a CentOS 7 Server.

from:https://www.howtoforge.com/tutorial/how-to-install-tomcat-on-centos/