Centos6.5 Install & Config

Centos6.5

Basic Install

1. install tomcat, jdk, nginx

1
2
3
4
5
[root@localhost temp]# tar -zxvf apache-tomcat-7.0.68.tar.gz -C ../tomcat
[root@localhost temp]# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.zip
[root@localhost pcre-8.37]# yum install gcc gcc-c++ autoconf make
[root@localhost pcre-8.37]# ./configure & make & make install
[root@localhost temp]# ./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf
  • Simplier way to install nginx

First, install Extra Packages for Enterprise Linux

1
$ sudo yum install epel-release

Then, install nginx:

1
$ sudo yum install nginx

Then, start ngix:

1
$ sudo /etc/init.d/nginx start

Config here:

1
$ sudo vim /etc/nginx/nginx.conf

Shutdown:

1
$ nginx -s quit

注意:
普通用户无法启动 nginx, 其端口为80,1024以下的端口只有 root 能监听,
有些文件也无法访问

解决:
切换 root 用户, /usr/sbin:

1
2
# chown root nginx
# chmod u+s nginx

  • nginx startup cmd
1
2
[root@localhost ~]# /usr/local/nginx/sbin/nginx
[root@localhost ~]# netstat -ano |grep 80

2. Install tomcat as a service

Change to the /etc/init.d directory and create a script called ‘tomcat’ as shown below.

1
2
[root@srv6 share]# cd /etc/init.d
[root@srv6 init.d]# vi tomcat

And here is the script we will use.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
JAVA_HOME=/usr/java/jdk1.7.0_05
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/usr/share/apache-tomcat-7.0.29

case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
stop)
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
esac
exit 0

Tomcat install reference url

1
2
3
[root@srv6 init.d]# chmod 755 tomcat
[root@srv6 init.d]# chkconfig --add tomcat
[root@srv6 init.d]# chkconfig --level 234 tomcat on

reference url

3. Install Redis

1
2
[root@nginx redis]# make && make install
[root@nginx redis]# redis-server /etc/redis/redis.conf
1
vi /etc/redis/redis.conf

仅修改: daemonize yes (no–>yes)

1
echo "/usr/local/bin/redis-server /etc/redis/redis.conf &" >> /etc/rc.local

CentOS6 安装 Redis

4. install mysql

查看 mysql:

1
yum list | grep mysql

安装:

1
yum install mysql-server mysql mysql-devel

查看安装结果:

1
[root@nginx ~]# rpm -qi mysql-server

首次启动:

1
[root@nginx ~]# service mysqld start

Set a password:

1
[root@nginx ~]# /usr/bin/mysqladmin -u root password 123456

设置开机自启动:

1
[root@nginx ~]# chkconfig mysqld on

5. install varnish

使用epel源

1
[root@localhost bin]# rpm -ivh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

check varnish:

1
[root@localhost bin]# yum list|grep varnish

Startup:

1
[root@localhost bin]# service varnish start

Check:

1
[root@localhost bin]# varnishd -V

For more details:

Varnish official User Guide

6. Install Maven

wget and tar and config the env.

For mvnw:

https://github.com/takari/maven-wrapper

1. Install ZooKeeper

  • 启动
1
zookeeper-3.4.6/bin/zkServer.sh start
  • 输入jps命令查看进程
1
2
1573 QuorumPeerMain
1654 Jps

Configuration

1. Set time zone

1
2
3
[root@demo81 Asia]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

[root@demo81 Asia]# vim /etc/sysconfig/clock

Add line:

1
UTC=false or no — The hardware clock is set to local time.

Reload:

1
2
3
[root@demo81 Asia]# /etc/init.d/ntpd restart
OR:
[root@dlp ~]# source /etc/sysconfig/clock

Check:

1
2
[root@demo81 Asia]# date
2016年 05月 26日 星期四 09:36:10 CST

2. 环境变量 $PATH

1
2
3
4
5
# echo 'pathmunge /usr/local/maven/bin' > /etc/profile.d/mvn.sh
# chmod +x /etc/profile.d/mvn.sh
# . /etc/profile
# echo $PATH
/usr/local/maven/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/jdk/bin:/usr/local/jdk/jre/bin:/root/bin:/usr/local/jdk/bin:/usr/local/jdk/jre/bin

pathmunge 是redhat版本中系统变量profile中的函数,判断当前系统是否有此命令,如果没有,放置在之前或之后 ?

3. vim

  1. Vim show line number 显示行号

    1
    2
    3
    4
    Find vimrc file:
    $ whereis vimrc
    $ sudo vim /etc/vimrc
    Add: set nu!
  2. Vim 查找单词
    配置:

    set insearch

使用 /word 查找单词

vim 深造