主要使用Nginx和vsftpd. 安装方面可以直接从nginx官网上下载,或者...
yum install nginx
如果没有yum源则需要自行添加再进行install.
yum install wgetwget http://www.atomicorp.com/installers/atomic sh ./atomic yum check update
系统环境可能有少许差异,执行以下命令,把缺少的东西补上:
yum install gcc-c++yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
如果是从官网上下载的则进行如下操作:
[root@admin local]# cd /usr/local[root@admin local]# tar -zxv -f nginx-1.7.7.tar.gz[root@admin local]# rm -rf nginx-1.7.7.tar.gz[root@admin local]# mv nginx-1.7.7 nginx[root@admin local]# cd /usr/local/nginx
./configure时可能由于系统上的差异需要亲自指定一些东西,比如加上参数--with-openssl
之类:
[root@admin nginx]# ./configure --PRefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf[root@admin nginx]# make[root@admin nginx]# make install
修改防火墙配置:
vim /etc/sysconfig/iptables
添加配置项
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
重启防火墙和网络配置
service iptables restart /etc/init.d/network restart
安装vsftpd:
yum install vsftpd
配置首先确认一下nginx指向的配置文件是/usr/local/nginx/conf/nginx.conf执行:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
对nginx没有做太复杂的配置,仅仅是创建了一个虚拟目录并打开了目录浏览功能。我想访问http://localhost/apps时实际访问的路径是/home/appmanager/首先我需要在nginx/html下创建一个apps文件夹,尽管实际访问的不是这个路径。
mkdir /usr/local/nginx/html/apps
然后修改nginx/conf/nginx.conf在默认的server里再添加一个location并指定实际路径:
location /apps/ { root /home/appmanager/; #alias ; autoindex on; #autoindex_exact_size off; #autoindex_localtime on;}
autoindex on便是打开浏览功能。 root则是将apps映射到/home/appmanager/apps/当然,alias也可以实现我想要的效果,只是用法上和root稍有差异。
接着需要创建用户,就是上面配置文件中的appmanager。
useradd -d /home/appmanager -M appmanager
接着指定目录并加入权限
chown appmanager /home/appmanagerchmod 777 -R /home/appmanager
不知是什么原因,我第一次创建的用户的目录总是不生效,虽然多次进行usermod -d也毫无效果....
无论如何现在可以通过Jsch api访问了。
public static void main(String[] args) throws JSchException { session session = null; ChannelSftp channelSftp = null; try { JSch.setLogger(new JSCHLogger()); JSch jsch = new JSch(); session = jsch.getSession("appmanager", "101.x.x.x", "22"); session.setPassWord("password"); Properties config = new Properties(); config.put("StrictHostKeyChecking", "no"); session.setConfig(config); session.connect(); channelSftp = (ChannelSftp) session.openChannel("sftp"); channelSftp.connect(); } catch (JSchException | SftpException | IOException e) { logger.error(e.getMessage(), e); } finally { if (channelSftp != null) { channelSftp.disconnect(); } if (session != null) session.disconnect(); }}
新闻热点
疑难解答