1、linux目录下的文件怎么通过浏览器输入http的方式访问文件?
这个需复要在本机搭建制有一个文本服务器才可以,例如Apache等。
1、下载Apache软件安装到电脑上,将制作好的页面放在网页的根目录下,Linux下为Apache安装目录下的htdocs文件夹下。
2、接下来就可以实现输入IP/文件名称访问该网页了。
补充知识:
Apache是世界使用排名第一的Web服务器软件。它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一。它快速、可靠并且可通过简单的API扩充,将Perl/Python等解释器编译到服务器中。同时Apache音译为阿帕奇,是北美印第安人的一个部落,叫阿帕奇族,在美国的西南部。也是一个基金会的名称、一种武装直升机等等。
2、HTTP从其他服务器(WINDOWS或者LINUX系统)下载图片
public static void doGetFile(String url, Header[] headers, String fileName) throws ServiceException {
if (url == null || url.length() <= 0) {
throw new ServiceException("Url can not be null.");
}
String temp = url.toLowerCase();
if (!temp.startsWith("http://") && !temp.startsWith("https://")) {
url = "http://" + url;
}
URI uri = URI.create(url);
url = uri.toASCIIString();
String host = uri.getHost();
if (headers == null) {
headers = prepareHeaders(host);
}
HttpGet httpMethod = null;
try {
// 初始化Http请求方法和参数
httpMethod = new HttpGet(url);
httpMethod.setHeaders(headers);
// 进行Http请求
HttpResponse response = SingletonHttpclient.getHttpClient().execute(httpMethod);
// 判断请求是否成功
if (!isResponseSuccessStatus(response)) {
int status = response.getStatusLine().getStatusCode();
System.out.println("Http Satus:" + status + ",Url:" + url);
if (status >= 500 && status < 600)
throw new IOException("Remote service<" + url + "> respose a error, status:" + status);
return;
}
File file = new File(DOWNLOAD_BASE_PATH + fileName);
if (!file.exists()) {
file.getParentFile().mkdirs();
}
FileOutputStream outputStream = new FileOutputStream(file);
InputStream inputStream = response.getEntity().getContent();
byte b[] = new byte[1024];
int j = 0;
while ((j = inputStream.read(b)) != -1) {
outputStream.write(b, 0, j);
}
outputStream.flush();
outputStream.close();
System.out.println("存储了文件: " + file.getAbsolutePath());
} catch (Exception e) {
if (httpMethod != null) {
httpMethod.abort();
}
throw new ServiceException("get,error!url={" + url + "}");
}
}
3、linux下在配置WEB服务器初期,由于经常需要编辑Apache配置文件,请为编辑该配置文件定义别名confighttp
直接给出命令
#vi /root/.bashrc
alias confighttp='vi /etc/httpd/conf/httpd.conf'
4、怎么通过web方式下载放在linux服务器上的文件
你启动了http服务了么?
放在DocumentRoot的目录下或其下的子目录下,就可以专了
访问方式属 http://your_server_ip/your_file
5、linux centos怎么搭建http文件服务器
centos如果是建立文件服务器一般使用ftp,安装vsftp服务即可。
如果使用http的文件服务器,可以使用apache的目录浏览功能。
6、linux 如何禁止IP访问http服务器
Linux系统中,如果需要禁止特定ip地址访问来保证系统的安全,只需通过操作iptalbes来实现,下面就给绍下Linux如何禁止某个ip地址访问。
一、概述
这两个文件是tcpd服务器的配置文件,tcpd服务器可以控制外部IP对本机服务的访问。这两个配置文件的格式如下:
#服务进程名:主机列表:当规则匹配时可选的命令操作
server_name:hosts-list[:command]
/etc/hosts.allow控制可以访问本机的IP地址,/etc/hosts.deny控制禁止访问本机的IP。如果两个文件的配置有冲突,以/etc/hosts.deny为准。
/etc/hosts.allow和/etc/hosts.deny两个文件是控制远程访问设置的,可以允许或者拒绝某个ip或者ip段的客户访问linux的某项服务。
比如SSH服务,通常只对管理员开放,那就可以禁用不必要的IP,而只开放管理员可能使用到的IP段。
二、配置
1、修改/etc/hosts.allow文件
#
# hosts.allow This file describes the names of the hosts which are
# allowed to use the local INET services, as decided
# by the ‘/usr/sbin/tcpd’ server.
#
sshd:210.13.218.*:allow
sshd:222.77.15.*:allow
all:218.24.129.110 #表示接受110这个ip的所有请求!
in.telnetd:140.116.44.0/255.255.255.0
in.telnetd:140.116.79.0/255.255.255.0
in.telnetd:140.116.141.99
in.telnetd:LOCAL
smbd:192.168.0.0/255.255.255.0 #允许192.168.0.网段的IP访问smbd服务
#sendmail:192.168.1.0/255.255.255.0
#pop3d:192.168.1.0/255.255.255.0
#swat:192.168.1.0/255.255.255.0
pptpd:all EXCEPT 192.168.0.0/255.255.255.0
httpd:all
vsftpd:all
以上写法表示允许210和222两个ip段连接sshd服务(这必然需要hosts.deny这个文件配合使用),当然:allow完全可以省略的。
ALL要害字匹配所有情况,EXCEPT匹配除了某些项之外的情况,PARANOID匹配你想控制的IP地址和它的域名不匹配时(域名伪装)的情况。
2、修改/etc/hosts.deny文件
#
# hosts.deny This file describes the names of the hosts which are
# *not* allowed to use the local INET services, as decided
# by the ‘/usr/sbin/tcpd’ server.
#
# The portmap line is rendant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow. In particular
# you should know that NFS uses portmap!
sshd:all:deny
in.telnet:ALL
ALL:ALL EXCEPT 192.168.0.1/255.255.255.0,192.168.1.21,
202.10.5.0/255.255.255.0
注意看:sshd:all:deny表示拒绝了所有sshd远程连接。:deny可以省略。
3、启动服务。
注意修改完后:
#service xinetd restart
才能让刚才的更改生效。
7、为什么我的Linux里没有 /etc/httpd/conf/http.conf 这个文件????
为什么我的Linux里没有 /etc/httpd/conf/http.conf 这个文件????
yum install httpd httpd-devel -y 安装完阿帕奇就有了
ls -lh /etc/httpd.conf≠/etc/httpd/conf/http.conf
路径要仔细看,一个符号差别就不是一个位置了
8、java web项目 在linux服务器发送http post请求 中文乱码
在进行post方式提交的时候,写上request.setCharacterEncoding("UTF-8");
记住要在request设置提交参数之前设置字符编码
祝:生活愉快
9、如何搭建像linux公社资源站那样的Http 文件服务器, 附带公社http://linux.linuxidc.com/
这是http服务器的基本功能,如果不设置index这类文件,就可以显示目录列表。
10、linux 如何禁止IP访问http服务器
Linux系统中,如果需要禁止特定ip地址访问来保证系统的安全,只需通过操作iptalbes来实现,下面就给绍下Linux如何禁止某个ip地址访问。
一、概述
这两个文件是tcpd服务器的配置文件,tcpd服务器可以控制外部IP对本机服务的访问。这两个配置文件的格式如下:
#服务进程名:主机列表:当规则匹配时可选的命令操作
server_name:hosts-list[:command]
/etc/hosts.allow控制可以访问本机的IP地址,/etc/hosts.deny控制禁止访问本机的IP。如果两个文件的配置有冲突,以/etc/hosts.deny为准。
/etc/hosts.allow和/etc/hosts.deny两个文件是控制远程访问设置的,可以允许或者拒绝某个ip或者ip段的客户访问linux的某项服务。
比如SSH服务,通常只对管理员开放,那就可以禁用不必要的IP,而只开放管理员可能使用到的IP段。
二、配置
1、修改/etc/hosts.allow文件
#
# hosts.allow This file describes the names of the hosts which are
# allowed to use the local INET services, as decided
# by the ‘/usr/sbin/tcpd’ server.
#
sshd:210.13.218.*:allow
sshd:222.77.15.*:allow
all:218.24.129.110 #表示接受110这个ip的所有请求!
in.telnetd:140.116.44.0/255.255.255.0
in.telnetd:140.116.79.0/255.255.255.0
in.telnetd:140.116.141.99
in.telnetd:LOCAL
smbd:192.168.0.0/255.255.255.0 #允许192.168.0.网段的IP访问smbd服务
#sendmail:192.168.1.0/255.255.255.0
#pop3d:192.168.1.0/255.255.255.0
#swat:192.168.1.0/255.255.255.0
pptpd:all EXCEPT 192.168.0.0/255.255.255.0
httpd:all
vsftpd:all
以上写法表示允许210和222两个ip段连接sshd服务(这必然需要hosts.deny这个文件配合使用),当然:allow完全可以省略的。
ALL要害字匹配所有情况,EXCEPT匹配除了某些项之外的情况,PARANOID匹配你想控制的IP地址和它的域名不匹配时(域名伪装)的情况。
2、修改/etc/hosts.deny文件
#
# hosts.deny This file describes the names of the hosts which are
# *not* allowed to use the local INET services, as decided
# by the ‘/usr/sbin/tcpd’ server.
#
# The portmap line is rendant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow. In particular
# you should know that NFS uses portmap!
sshd:all:deny
in.telnet:ALL
ALL:ALL EXCEPT 192.168.0.1/255.255.255.0,192.168.1.21,
202.10.5.0/255.255.255.0
注意看:sshd:all:deny表示拒绝了所有sshd远程连接。:deny可以省略。
3、启动服务。
注意修改完后:
#service xinetd restart
才能让刚才的更改生效。