Skip to content

Commit 018d376

Browse files
committed
Add java, shadowsocks configurations
1 parent 59d2cde commit 018d376

File tree

3 files changed

+126
-2
lines changed

3 files changed

+126
-2
lines changed

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@ CentOS 7 下服务器配置,各类应用部署等文档
55
* [基本配置](./base/centos.md)
66

77
* 常用软件
8-
* [MariaDB](./base/mariadb.md)
98
* [Nginx](./base/nginx.md)
9+
* [MariaDB](./base/mariadb.md)
10+
* [PostgreSQL](./base/postgresql.md)
1011
* [Redis](./base/redis.md)
1112
* [Docker](./base/docker.md)
1213

13-
* GitLab 相关
14+
* GitLab
1415
* [GitLab 安装与维护](./gitlab/gitlab.md)
1516
* [GitLab-CI 安装与维护](./gitlab/gitlab-ci.md)
1617
* [GitLab-CI 用法](./gitlab/gitlab-ci-usage.md)
1718

1819
* 各语言环境配置
20+
* [Java](./languages/java.md)
1921
* [PHP](./languages/php.md)
2022
* [Ruby](./languages/ruby.md)
2123
* [Node.js](./languages/nodejs.md)
@@ -34,3 +36,4 @@ CentOS 7 下服务器配置,各类应用部署等文档
3436
* [Emqttd](./others/emqttd.md)
3537
* [Nexus Repository Manager OSS](./others/nexus.md)
3638
* [Certbot - Let's Encrypt SSL 证书](./others/certbot.md)
39+
* [Shadowsocks](./others/shadowsocks.md)

languages/java.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Java
2+
3+
使用 [OpenJDK](http://openjdk.java.net/)
4+
5+
## 安装
6+
7+
```
8+
# JRE only
9+
sudo yum install java-1.8.0-openjdk
10+
11+
# JDK
12+
sudo yum install java-1.8.0-openjdk-devel
13+
```
14+
15+
## 配置
16+
17+
有些应用依赖 `JAVA_HOME` 环境变量
18+
19+
`~/.bash_profile`:
20+
21+
```bash
22+
export JAVA_HOME=/usr/lib/jvm/java
23+
# 如果只安装了 JRE
24+
# export JAVA_HOME=/usr/lib/jvm/jre
25+
```
26+
27+
`/usr/lib/jvm/java` 是个符号链接,指向当前使用的 Java 版本。也可设置为 `/usr/lib/jvm/` 下的其它目录
28+
29+
这些符号链接是由 `chkconfig` 包提供的 `alternatives` 管理的。如果同时安装了多个 Java 版本,可使用以下命令选择默认使用的版本:
30+
31+
```bash
32+
alternatives --config java
33+
```
34+
35+
## Maven 国内镜像
36+
37+
只对 maven 有效,对 Gradle 无效。
38+
39+
`~/.m2/settings.xml`:
40+
41+
```
42+
<?xml version="1.0" encoding="UTF-8"?>
43+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
44+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
45+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
46+
<mirrors>
47+
<mirror>
48+
<id>nexus-aliyun</id>
49+
<mirrorOf>central, jcenter, gradle-plugin</mirrorOf>
50+
<name>Nexus aliyun</name>
51+
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
52+
</mirror>
53+
</mirrors>
54+
</settings>
55+
```
56+
57+
## 参考资料
58+
59+
* [OpenJDK](http://openjdk.java.net/install/)
60+
* [Install OpenJDK on Red Hat Enterprise Linux 6](https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6/html/Installation_Guide/Install_OpenJDK_on_Red_Hat_Enterprise_Linux.html)
61+
* [Using Java on RHEL 7 with OpenJDK 8](https://developers.redhat.com/articles/using-java-rhel-7-openjdk-8/)

others/shadowsoccks.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Shadowsocks
2+
3+
## 安装
4+
5+
需先安装 Python 和 pip, 2.x 或 3.x 版本均可
6+
7+
```bash
8+
sudo pip3 install shadowsocks
9+
```
10+
11+
## 配置
12+
13+
创建 `/etc/shadowsocks/config.json`:
14+
15+
```
16+
{
17+
"server": "0.0.0.0",
18+
"server_port": 8388,
19+
"password": "Your password",
20+
"timeout": 300,
21+
"method": "aes-256-cfb",
22+
"fast_open": true,
23+
"workers": 2
24+
}
25+
```
26+
27+
酌情修改配置
28+
29+
## 启动
30+
31+
```bash
32+
ssserver -c /etc/shadowsocks/config.json
33+
```
34+
35+
`server_port` 小于 1024,需要以 root 权限启动
36+
37+
## 自动启动
38+
39+
创建 `/etc/systemd/system/shadowsocks.service`:
40+
41+
```
42+
[Unit]
43+
Description=Shadowsocks Server Service
44+
After=network.target
45+
46+
[Service]
47+
# Require root if server_port < 1024
48+
User=root
49+
ExecStart=/usr/bin/ssserver -q -c /etc/shadowsocks/config.json
50+
Restart=always
51+
52+
[Install]
53+
WantedBy=multi-user.target
54+
```
55+
56+
```bash
57+
sudo systemctl daemon-reload
58+
sudo systemctl enable shadowsocks
59+
sudo systemctl start shadowsocks
60+
```

0 commit comments

Comments
 (0)