How do I log visits to a certain subdirectory of my website? - apache

I have a simple apache server (the default installation on Digitalocean). I can view visits to the domain in the /var/log/apache2 directory, but how do I see which subdirectory they viewed? If this isn't something that's logged by default, how should I set it up?

There is indeed a logfile for all requests the server processed.
RHEL / Red Hat / CentOS / Fedora Linux Apache access file location is:
/var/log/httpd/access_log
Debian / Ubuntu Linux Apache access log file location is:
/var/log/apache2/access.log
FreeBSD Apache access log file location is:
/var/log/httpd-access.log
By default, there you can find the IP address, time, request method, URL the client was using to access your server and browser user agent.
If you want a customized log file you can always visit the official documentation - AccessLog.

Related

Adding a Shared folder also as Document Root

I am running Apache 2.4.41 on Linux Mint 20.
My document root is home/www/.
I have a laptop also connected using Samba.
I would like to add a shared folder also (from the laptop) to the Document Root settings.
How do I do it without removing home/www/?
On your laptop, enable sharing of a folder. Lets say C:\LinuxShare.
On mint, install Samba to mount that folder. Mount it on /mnt/LinuxShare.
When that works...
Identify the user running your Apache. You can start is and do ps -ef | grep httpd, it will show you the user. Or look in httpd.conf, directive User.
Configure the permissions on /mnt/LinuxShare so that the user identified in 3) can read files under that directory. You could use a group, or others permissions (for home it's ok, for corporate network, do not use others!).
When you have validated that the Apache user can read files under /mnt/LinuxShare
In your VirtualHost, add Alias /wwwpc /mnt/LinuxShare
Also add a <Directory /mnt/LinuxShare> section to allow reading that directory.
Restart Apache
on the laptop, put an HTML file (lets say SOMEPAGE.html) in C:\LinuxShare. Make sure you can see it on mint under /mnt/LinuxShare.
on mint, start a browser and try http://localhost/wwwpc/SOMEPAGE.html. You should see the page.
on the laptop, start a browser and try http://THE_IP_OF_THE_MINT/wwwpc/SOMEPAGE.html. Remember that Apache runs on mint, so on the laptop you cannot access it via localhost.

How do I make the Apache Server point to the /var/www/html directory

In a new RHEL 7.5 server, I have created a var directory and within that the /www/html directory in which my website resides. When I try to access the website, I get the Apache Server Test page and mentions that the Apache server is running and I need to point to the /var/www/html directory.
How do I point the Apache Server to the /var/www/html directory?
You need to configure the available-sites and enabled-sites and remember to restart apache after changes in the config files.
Have a look at this guide:
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts#step-four-%E2%80%94-create-new-virtual-host-files

PHPmyadmin and Wordpress directories access denied

Running wordpress locally on a centOS 7 server running the latest apache, PHPmyadmin and mariadb-server.
IP/wordpress and IP/phpmyadmin on systems within the local network yields "403 forbidden" "you dont have permission to access (directory) on this server."
How can I fix this to allow the website to be seen on the public internet?
Could be a lot of things.
In your main Apache configuration file (e.g. /etc/httpd/conf/httpd.conf on Arch Linux), confirm your DocumentRoot path. The files you want to serve must reside there, or in sub-directories from there (If not, you might want to use an Alias to specify another path). Since you call IP/wordpress and IP/phpmyadmin, then you probably have directories called wordpress and phpmyadmin under your DocumentRoot path.
You also want to check the Directory groups in your Apache configuration file. Under those, the main culprit would be the Require directive set to all denied or something else too much restrictive like ip your_ip.
Finally, PHP can restrict path access with the open_basedir directive. Look for it in your php configuration file (e.g. /etc/php/php.ini on Arch Linux). If the line is commented, you're fine. But if a path is specified, your wordpress and phpmyadmin files must reside there.
Depending on your setup, any directive mentioned above could be in another Apache configuration file (e.g. /etc/httpd/conf/extra/* on Arch Linux).
Take a look at Apache and PHP online documentation for information about those directives.
Probably there is an issue with your directory privileges.
Use the follwing command to check it:
cd your_site_directory
ls -l
You can have a look to have a better understanding on directory privileges here.
As mentioned here apache runs under "apache" user.
Have a look at this post here to fix the issue.
All files should belong at least to apache group. To do it you can use
cd your_site_directory
chgrp -R apache ./*

Forbidden You don't have permission to access / on this server

I'm trying to set up a webserver on my VPS (Running Debian 7). I have installed apache and configured it. However, when I try to connect to my IP I am faced with a 403 forbidden error saying that I don't have access to / on the server. I have attempted to set it up so that when connecting the webserver should direct to the directory: /home/webmaster/website. My main apache.conf file is as follows: http://pastebin.com/zgyik39y
and my site config, called "web.conf" is: http://pastebin.com/jpRJAaCw I don't know what to do, I've tried many suggestions on here and in other places and none so far have worked.
Line 18 of web.conf should be:
Allow from all
For apache 2.2 or:
Require all granted
For apache 2.4

Virtual Host using Apache

We have development team of 10 people working on Linux platform our application is hosted on Apache server
Now what i want if every developer is having own codebase in his directory
he can have his own httpd conf file which uses his code base and his port on that server
and whenever he changes the code base he needs run only his apache process
and there is no need to start , restart the apache server as other people should not get disturbed
so can we do this listening same server on different ports with different DocumentRoot and no need to start or restart the whole apache server only individual process of apache need to be started if any changes are done in the local conf file of that user
You need not get into the complexity of managing virtual hosts.
You can create alias for each developer which will point to his directory.
http://httpd.apache.org/docs/1.3/mod/mod_alias.html#alias
Eg :
servername.com/dev1/
in httpd conf point dev1 to developer's working folder.
Developer can update code see the result at the above url without restarting server.