发布于 2016-02-10 21:04:27 | 517 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的Nginx开发从入门到精通,程序狗速度看过来!

Nginx WEB服务器

Nginx 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,第一个公开版本0.1.0发布于2004年10月4日。其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。


这篇文章主要介绍了Linux环境下nginx搭建简易图片服务器,需要的朋友可以参考下

主要使用Nginx和vsftpd.
安装方面可以直接从nginx官网上下载,或者...



yum install nginx  


 
如果没有yum源则需要自行添加再进行install.



yum install wget

wget http://www.atomicorp.com/installers/atomic  

sh ./atomic  

yum check update  

如果是从官网上下载的则进行如下操作:



[root@admin local]# cd /usr/local

[root@admin local]# tar -zxv -f nginx-1.6.2.tar.gz

[root@admin local]# rm -rf nginx-1.6.2.tar.gz

[root@admin local]# mv nginx-1.6.2 nginx

[root@admin local]# cd /usr/local/nginx

[root@admin nginx]# ./configure --prefix=/usr/local/nginx

[root@admin nginx]# make

[root@admin nginx]# make install      

安装vsftpd:



yum install vsftpd  

对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/appmanager

chmod 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();
    }
}



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务