How to create simple web page that share files and folders

How to create simple web page that share files and folders

http_a_3

Here I will show how to quickly create basic web page with links to files. The idea is to quickly install web serwer on a clean OS and setup it to share files.

This little guide is based on the CentOS 7 and apache web server 2.4.6.

First verify if apache web server is installed:

[centos@cent7 Desktop]$ yum list httpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.icm.edu.pl
* extras: ftp.icm.edu.pl
* updates: centos2.hti.pl
Available Packages
httpd.x86_64 2.4.6-40.el7.centos base
[centos@cent7 Desktop]$

If not, install it:

[centos@cent7 Desktop]$ sudo yum install httpd

 

After that enable the httpd service and run:

[centos@cent7 ~]$ sudo systemctl enable httpd
[centos@cent7 ~]$ sudo systemctl start httpd

 

Then open web browser and enter address: http://localhost. Welcome page of apache web server opens:

http_a_1

 

To have web server sharing files remove the file welcome.conf or rename it:

[centos@cent7 ~]$ sudo mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.orig

And restart the web server:

[centos@cent7 ~]$ sudo systemctl restart httpd

 

Now go to the apache web server configuration file and verify the document root. The directory where web page files are stored or files in our situation. Default directory is  /var/www/html. You can change this directory to whatever you want.

Also make sure that there is option inside <Directory> clause:

Options Indexes FollowSymLinks

Then you can create files, folders and so on:

[root@cent7 ~]# for i in {1..4}; do touch /var/www/html/file${i}; done
[root@cent7 ~]# for i in {1..4}; do mkdir /var/www/html/dir${i}; done

[root@cent7 ~]# ls /var/www/html/
dir1 dir2 dir3 dir4 file1 file2 file3 file4

You can also upload files using sftp or scp to the folder /var/www/html. To verify if the web server is sharing files and folders from other computer enter web server address.

Make sure your firewall is disabled (this is not recommended but acceptable for testing purpose)

[root@cent7 ~]# systemctl disable firewalld
[root@cent7 ~]# iptables -F

Example:

http_a_2

 

Example of apache web server configuration file:
/etc/httpd/conf/httpd.conf

<Directory “/var/www”>
AllowOverride None
Require all granted
</Directory>

<Directory “/var/www/html”>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

Note: There is no need to change anything in configuration file httpd.conf.

That is it!

Instruction in youtube:

1 Comment

  1. Wow thawt ԝas strange. I jսst wrote an incredibly lonjg ϲomment but after I
    clicked submit my comment diⅾn’t show up. Grrrr…
    wrll I’m not writing ɑll that over again. Anywɑys,
    just wanted to ssay superb blog!

    Reply

Leave a Reply