Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-bash: trojan: command not found 解决办法 #32

Closed
sjzbim opened this issue Mar 27, 2020 · 51 comments
Closed

-bash: trojan: command not found 解决办法 #32

sjzbim opened this issue Mar 27, 2020 · 51 comments

Comments

@sjzbim
Copy link

sjzbim commented Mar 27, 2020

添加路径(执行代码)
echo 'export PATH=$PATH:/usr/local/bin' > /etc/profile.d/ulb.sh
source /etc/profile.d/ulb.sh

出处:http://tj.6finger.at:8080/2020/03/23/trojan-%e5%a4%9a%e7%94%a8%e6%88%b7%e9%9d%a2%e6%9d%bf%e6%90%ad%e5%bb%ba/

@Jrohy
Copy link
Owner

Jrohy commented Mar 27, 2020

不需要看教程的,直接一键脚本即可安装的,不需要手动添加环境变量的

@Jrohy
Copy link
Owner

Jrohy commented Mar 27, 2020

可以先试下程序自带的docker mysql安装,已经做了相应优化

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

gcp,centos7,一键安装脚本,安装时,总是卡在“2020-03-28 00:13:10 mysql启动中,请稍等...”这里;之前有两次过了这个,但是无法登录mysql,没有密码

docker run --name trojan-mysql --restart=always -p 16756:3306 -v /home/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=wGZFc -e MYSQL_ROOT_HOST=% -e MYSQL_DATABASE=trojan -d mysql/mysql-server:5.7
/usr/bin/docker-current: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See '/usr/bin/docker-current run --help'.
2020-03-28 00:12:18 mysql启动中,请稍等...
2020-03-28 00:12:20 mysql启动中,请稍等...
2020-03-28 00:12:22 mysql启动中,请稍等...
2020-03-28 00:12:24 mysql启动中,请稍等...
2020-03-28 00:12:26 mysql启动中,请稍等...
2020-03-28 00:12:28 mysql启动中,请稍等...
2020-03-28 00:12:30 mysql启动中,请稍等...
2020-03-28 00:12:32 mysql启动中,请稍等...
2020-03-28 00:12:34 mysql启动中,请稍等...
2020-03-28 00:12:36 mysql启动中,请稍等...
2020-03-28 00:12:38 mysql启动中,请稍等...
2020-03-28 00:12:40 mysql启动中,请稍等...
2020-03-28 00:12:42 mysql启动中,请稍等...
2020-03-28 00:12:44 mysql启动中,请稍等...
2020-03-28 00:12:46 mysql启动中,请稍等...
2020-03-28 00:12:48 mysql启动中,请稍等...
2020-03-28 00:12:50 mysql启动中,请稍等...
2020-03-28 00:12:52 mysql启动中,请稍等...
2020-03-28 00:12:54 mysql启动中,请稍等...
2020-03-28 00:12:56 mysql启动中,请稍等...
2020-03-28 00:12:58 mysql启动中,请稍等...
2020-03-28 00:13:00 mysql启动中,请稍等...
2020-03-28 00:13:02 mysql启动中,请稍等...
2020-03-28 00:13:04 mysql启动中,请稍等...
2020-03-28 00:13:06 mysql启动中,请稍等...
2020-03-28 00:13:08 mysql启动中,请稍等...
2020-03-28 00:13:10 mysql启动中,请稍等...
2020-03-28 00:13:12 mysql启动中,请稍等...
2020-03-28 00:13:14 mysql启动中,请稍等...
2020-03-28 00:13:16 mysql启动中,请稍等...
2020-03-28 00:13:18 mysql启动中,请稍等...
2020-03-28 00:13:20 mysql启动中,请稍等...
2020-03-28 00:13:22 mysql启动中,请稍等...
2020-03-28 00:13:24 mysql启动中,请稍等...
2020-03-28 00:13:26 mysql启动中,请稍等...
2020-03-28 00:13:28 mysql启动中,请稍等...
2020-03-28 00:13:30 mysql启动中,请稍等...
2020-03-28 00:13:32 mysql启动中,请稍等...
2020-03-28 00:13:34 mysql启动中,请稍等...
2020-03-28 00:13:36 mysql启动中,请稍等...
2020-03-28 00:13:38 mysql启动中,请稍等...
2020-03-28 00:13:40 mysql启动中,请稍等...
2020-03-28 00:13:42 mysql启动中,请稍等...
2020-03-28 00:13:44 mysql启动中,请稍等...
2020-03-28 00:13:46 mysql启动中,请稍等...
2020-03-28 00:13:48 mysql启动中,请稍等...
2020-03-28 00:13:50 mysql启动中,请稍等...
2020-03-28 00:13:52 mysql启动中,请稍等...
2020-03-28 00:13:54 mysql启动中,请稍等...
2020-03-28 00:13:56 mysql启动中,请稍等...
2020-03-28 00:13:58 mysql启动中,请稍等...
2020-03-28 00:14:00 mysql启动中,请稍等...
2020-03-28 00:14:02 mysql启动中,请稍等...
2020-03-28 00:14:04 mysql启动中,请稍等...
2020-03-28 00:14:06 mysql启动中,请稍等...
2020-03-28 00:14:08 mysql启动中,请稍等...
2020-03-28 00:14:10 mysql启动中,请稍等...
2020-03-28 00:14:12 mysql启动中,请稍等...
2020-03-28 00:14:14 mysql启动中,请稍等...
2020-03-28 00:14:16 mysql启动中,请稍等...
2020-03-28 00:14:18 mysql启动中,请稍等...
2020-03-28 00:14:20 mysql启动中,请稍等...

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

@sjzbim docker安装失败了. 你可以试下用官方docker安装脚本sh <(curl -sL https://get.docker.com), 先安装成功docker再安装本程序. 运行完后docker info看下正不正常

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

我再优化下docker安装这块,估计换成用官方脚本来安装,提高成功率

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

@sjzbim 2.3.3版本已优化docker安装,优先使用官方脚本进行安装, 麻烦帮测试下在gcp上的docker安装

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

@sjzbim docker安装失败了. 你可以试下用官方docker安装脚本sh <(curl -sL https://get.docker.com), 先安装成功docker再安装本程序. 运行完后docker info看下正不正常
gcp,centos 7, 官方脚本安装docker,貌似失败吧~
[root@trojan-panel ~]# docker info
Client:
Debug Mode: false

Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

systemctl start docker

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

官方脚本安装完是没启动的,需要手动启动下

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

官方脚本安装完是没启动的,需要手动启动下
手动启动后

[root@trojan-panel ~]# systemctl start docker
[root@trojan-panel ~]# docker info
Client:
Debug Mode: false

Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 19.03.8
Storage Driver: overlay2
Backing Filesystem:
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-1062.12.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 587.1MiB
Name: trojan-panel
ID: 25BC:7UOT:KEAP:HP5H:G6N4:QPMM:MNEM:JHBC:2P42:C6DO:6DYH:6X27
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

docker run --name trojan-mysql --restart=always -p 16756:3306 -v /home/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=wGZFc -e MYSQL_ROOT_HOST=% -e MYSQL_DATABASE=trojan -d mysql/mysql-server:5.7
试下运行,看下有没报错了

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

[root@trojan-panel ~]# docker run --name trojan-mysql --restart=always -p 16756:3306 -v /home/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=wGZFc -e MYSQL_ROOT_HOST=% -e MYSQL_DATABASE=trojan -d mysql/mysql-server:5.7
docker: Error response from daemon: Conflict. The container name "/trojan-mysql" is already in use by container "64b59adf2f98163005eb119a94d3437aab67898fd6c8040981cf2f8c036bd220". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.
[root@trojan-panel ~]#

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

我删除了以上container,重新trojan,安装mysql,依然卡在 mysql启动中,请稍等……

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

要清理掉mysql数据, rm -rf /home/mysql 以及清理容器 docker rm -f trojan-mysql
这才算彻底清理mysql

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

清理了之后,重新运行trojan 安装mysql还是 启动中~

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

是会有启动中的,因为要等mysql启动完来自动创建表和用户

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

是会有启动中的,因为要等mysql启动完来自动创建表和用户

就是时间比较长,2分钟以上了

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

正常不会这么长,应该有问题才这么久。退出来 docker ps看下容器状态

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

还有有没有重装系统来试下呢,如果用之前的环境来测,用的还是二进制的docker安装方式

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

我新建了系统,再试一遍一键脚本

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

麻烦了👍

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

全新系统centos7,1.7g内存(之前600多),这次使用的网页ssh,一键脚本source <(curl -sL https://git.io/trojan-install)
Created symlink from /etc/systemd/system/multi-user.target.wants/trojan-web.service to /etc/systemd/system/trojan-w
eb.service.
-bash: trojan: command not found
安装trojan管理程序成功!
运行命令trojan可进行trojan管理
-bash: trojan: command not found
浏览器访问'https://域名'可在线trojan多用户管理

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

mysql建用户能成功不

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

手动添加路径,正在安装trojan

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

正在安装mysql

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

mysql启动了
但是证书貌似没有申请成功,配置文件里面没有证书

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

报什么日志错误申请证书

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

[Sat Mar 28 12:04:27 UTC 2020] Lets find script dir.
[Sat Mar 28 12:04:27 UTC 2020] SCRIPT='/root/.acme.sh/acme.sh'
[Sat Mar 28 12:04:27 UTC 2020] _script='/root/.acme.sh/acme.sh'
[Sat Mar 28 12:04:27 UTC 2020] _script_home='/root/.acme.sh'
[Sat Mar 28 12:04:27 UTC 2020] Using config home:/root/.acme.sh
https://github.com/acmesh-official/acme.sh
v2.8.6
[Sat Mar 28 12:04:27 UTC 2020] Running cmd: issue
[Sat Mar 28 12:04:27 UTC 2020] _main_domain='sese.ml'
[Sat Mar 28 12:04:27 UTC 2020] _alt_domains='no'
[Sat Mar 28 12:04:27 UTC 2020] Using config home:/root/.acme.sh
[Sat Mar 28 12:04:27 UTC 2020] ACME_DIRECTORY='https://acme-v02.api.letsencrypt.org/directory'
[Sat Mar 28 12:04:27 UTC 2020] DOMAIN_PATH='/root/.acme.sh/sese.ml_ecc'
[Sat Mar 28 12:04:27 UTC 2020] Using ACME_DIRECTORY: https://acme-v02.api.letsencrypt.org/directory
[Sat Mar 28 12:04:27 UTC 2020] _init api for server: https://acme-v02.api.letsencrypt.org/directory
[Sat Mar 28 12:04:27 UTC 2020] GET
[Sat Mar 28 12:04:27 UTC 2020] url='https://acme-v02.api.letsencrypt.org/directory'
[Sat Mar 28 12:04:27 UTC 2020] timeout=
[Sat Mar 28 12:04:27 UTC 2020] _CURL='curl -L --silent --dump-header /root/.acme.sh/http.header -g '
[Sat Mar 28 12:04:28 UTC 2020] ret='0'
[Sat Mar 28 12:04:28 UTC 2020] ACME_KEY_CHANGE='https://acme-v02.api.letsencrypt.org/acme/key-change'
[Sat Mar 28 12:04:28 UTC 2020] ACME_NEW_AUTHZ
[Sat Mar 28 12:04:28 UTC 2020] ACME_NEW_ORDER='https://acme-v02.api.letsencrypt.org/acme/new-order'
[Sat Mar 28 12:04:28 UTC 2020] ACME_NEW_ACCOUNT='https://acme-v02.api.letsencrypt.org/acme/new-acct'
[Sat Mar 28 12:04:28 UTC 2020] ACME_REVOKE_CERT='https://acme-v02.api.letsencrypt.org/acme/revoke-cert'
[Sat Mar 28 12:04:28 UTC 2020] ACME_AGREEMENT='https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf'
[Sat Mar 28 12:04:28 UTC 2020] ACME_NEW_NONCE='https://acme-v02.api.letsencrypt.org/acme/new-nonce'
[Sat Mar 28 12:04:28 UTC 2020] ACME_VERSION='2'
[Sat Mar 28 12:04:28 UTC 2020] Le_NextRenewTime
[Sat Mar 28 12:04:28 UTC 2020] _on_before_issue
[Sat Mar 28 12:04:28 UTC 2020] _chk_main_domain='sese.ml'
[Sat Mar 28 12:04:28 UTC 2020] _chk_alt_domains
[Sat Mar 28 12:04:28 UTC 2020] Le_LocalAddress
[Sat Mar 28 12:04:28 UTC 2020] d='sese.ml'
[Sat Mar 28 12:04:28 UTC 2020] Check for domain='sese.ml'
[Sat Mar 28 12:04:28 UTC 2020] _currentRoot='no'
[Sat Mar 28 12:04:28 UTC 2020] Standalone mode.
[Sat Mar 28 12:04:28 UTC 2020] _checkport='80'
[Sat Mar 28 12:04:28 UTC 2020] _checkaddr
[Sat Mar 28 12:04:28 UTC 2020] Using: ss
[Sat Mar 28 12:04:28 UTC 2020] LISTEN 0 128 [::]:80 [::]:* users:(("trojan",pid=1415,fd=3))
[Sat Mar 28 12:04:28 UTC 2020] tcp port 80 is already used by 80 [
[Sat Mar 28 12:04:28 UTC 2020] Please stop it first
[Sat Mar 28 12:04:28 UTC 2020] _on_before_issue.

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

先systemctl stop trojan-web 再去申请证书, 申请完后systemctl start trojan-web

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

"type": "urn:ietf:params:acme:error:rateLimited",
"detail": "Error creating new order :: too many certificates already issued for exact set of domains: sese.ml: see https://letsencrypt.org/docs/rate-limits/",
"status": 429
这个就尴尬了,只能换域名了吧?

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

嗯没有新域名就隔天试试

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

我换一个事实哈

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

有点想解决那个路径问题,可惜没有gcp机器来做验证😂

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

我没有换域名,申请了通配符证书,手动修改了root/config.json,添加了证书路径,配置算是成功了,trojan可以用了,面板也OK。
有两个问题:1.config没添加key也可以使用,
2.web面板没有强制https,http和https都可以访问

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

做不了强制https,因为trojan本身占了443端口,管理程序控制不到这个操作, 程序只起了80的端口

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

做不了强制https,因为trojan本身占了443端口,管理程序控制不到这个操作, 程序只起了80的端口

不用key也可以使用trojan吗

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

那就不清楚了,正常应该不是这样。能使用就好

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

我在root找的生成的配置文件,不知道原始配置文件在哪里

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

/usr/local/etc/trojan
找到了配置文件,里面有crt和key
但用trojan命令,生成配置文件内没有cert和key文件,如果这样的话,在电脑端配置起来就比较麻烦了~建议添加选项让用户自己导出cert、key和json配置文件,便于在mac和win使用

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

太繁琐了,你直接用trojan://链接导入就好

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

https://github.com/TheWanderingCoel/Trojan-Qt5 可以用这个扫描二维码或者导入trojan://链接

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

https://github.com/TheWanderingCoel/Trojan-Qt5 可以用这个扫描二维码或者导入trojan://链接

这个感觉还不是很稳定,用terminal那个+surge(sock5)好用些~

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

有点想解决那个路径问题,可惜没有gcp机器来做验证😂

申请一个呗,不是有免费300刀那个服务么?我记得,绑定招商visa就可以

@Jrohy
Copy link
Owner

Jrohy commented Mar 28, 2020

费事了为了这个特意搞个双币信用卡

@sjzbim
Copy link
Author

sjzbim commented Mar 28, 2020

费事了为了这个特意搞个双币信用卡

双币可能不行吧,单独visa应该可以,还没有年费,哈哈哈~~

@xnknown
Copy link

xnknown commented Mar 30, 2020

额。。我有个闲置的谷歌云
要不 拿去测试下

@Jrohy
Copy link
Owner

Jrohy commented Mar 30, 2020

@xnknown 可以的😀

@Jrohy
Copy link
Owner

Jrohy commented Mar 30, 2020

方便的话留个tg号联系 @xnknown

@luoqiz
Copy link

luoqiz commented Apr 1, 2020

路径问题就谷歌云的服务器有问题,不知道为啥没把 /usr/local/bin 这个路径加入到环境变量,也许它的是最小化系统吧。阿里云的就没问题。

@Jrohy
Copy link
Owner

Jrohy commented Apr 1, 2020

@luoqiz 确实其他vps我也没见过不将/usr/local/bin加入环境变量的,所以不好测试

@luoqiz
Copy link

luoqiz commented Apr 1, 2020

我当时也是没想到这个,当时重装系统安装了三次都提示这个。检查了trojan已安装,不得已就看了一下path,看完后我才反应过来......

@Jrohy Jrohy closed this as completed May 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants