I am implementing my simple webservice in linux using Apache, CGI(C++) and Flat File(Data).
I kept my WWW location path in /usr/share/www/
CGI location path in /usr/lib/cgi-bin/
Data location path in /usr/share/Data/
I just wanted to access my files located in WWW and Data only through my Apache server and CGI application. Sometimes I will updated my Data Files, some times I will copy some file from Data to WWW folder using CGI application. Important that my Data Files only should by accessed by my CGI application not by any other at any cost. So I decided to give permission and ownership just like following. But It could not copy a file from Data to WWW Folder.
sudo chmod 644 -R /usr/share/Data/
sudo chown www-data /usr/share/Data/
Its not working to copy a file from Data to WWW using my CGI application. What are the permission should I provide for the above 3 locations(WWW,CGI,Data) to secure my web service.
My Apache Configuration is,
<VirtualHost *:80>
ServerName www.mytestsite.com
ServerAdmin webmaster@localhost
DocumentRoot /usr/share/www/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin/">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
</Directory>
<Directory /usr/share/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
/usr
folder in Ubuntu stands for "Unix System Resources" In other words this folder should have the operating systems files. This is probably not the right folder to keep your web data. Messing with the permissions of system files and folders are not the best ideas either. The web server data should be in the sub-directories of/var/
. – user68186 Apr 12 '18 at 12:06