Apache is running but not working - apache

I am running a huge php-application on an ubuntu server, using apache2, php5, mysql.
Sometimes (approx. once a month) the page ist not reachable from the internet ("it's down").
The weird thing is, that service apache2 status says that apache is running.
The solution is always to restart apache using service apache2 restart and everything works fine again.
The server load is at a minimum and can't be part of the problem (I guess).
I know, this description is not as detailed as it should be, but I do not have more information.
Any suggestions about what could cause this problem are appreciated!

Disable Firewall or Antivirus and try again.

Change /etc/apache2/apache2.conf => change all AllowOverride all,
and make sure that /etc/apache2/sites-available/000.default.conf => verify the path of the Directory that you access.

assign the necessary permissions of the webroot directory for the domain.
chmod -R 755 /var/www/html/

Related

apache subprocess can't access files

i'm running into a problem where a program written to be accessed as a web service can't access anything in the local file system. running the program from the command line works correctly, but fails when called via apache as a subprocess exec'd via system() from a php script ; it simply can't find the files it's supposed to work on. i'm convinced this is an apache configuration issue, as the program has no problem reading /var/www/html [the webserver document root] and any/all files/directories under it.
here are some details :
virtual centos 7 server running apache 2.4.6.
the program runs as user apache
it can read / [root dir] and interprets it correctly [i.e. it really is / the system root, not /var/www/html]
it doesn't have access to /tmp at all, nor to /var/tmp
some external files are network mounted on /mnt. the program can access /mnt, but attempts to read /mnt/{anything} fail -- even though remote shares are mounted w/effective uid/gid as apache and all files/directories are readable by world.
selinux is currently disabled
for kicks, i tried setting Require all granted inside <Directory / > and <Directory /tmp > in httpd.conf, but that didn't change anything.
does anyone have any idea what could be causing this and how i could fix it ?
thanks.
Have you checked to see if selinux is restricting access?
You can see if Selinux is causing issues by install selinux troubleshooting
yum install -y setroubleshoot
sealert -a /var/log/audit/audit.log

How can "localhost" give an answer when apache2 is not installed?

My apache2 configuration is driving me crazy, and since I'm new to Linux/Ubuntu (16.04) and servers, I've been trying to install/remove lamp (and also xampp, and also phpmyadmin) a great number of times now, with several methods... without much results.
However, my current configuration is :
mysql-server is installed, and I can connect with 'mysql -u root -p'
phpmyadmin : I have tried to reinstall it, but there was a problem with apache2 (could not reload it or something... I haven't figured it yet)
php7 is installed and has been working until my server has crashed (I haven't tried to remove it)
apache2 : I used to have a lamp configuration + XAMPP (lampp in /opt/), but since there has been a problem, I uninstalled XAMPP and recently I also unistalled apache2 (sudo apt-get purge apache2, sudo apt-get autoremove, sudo apt-get clean and I verified that the configuration files have been deleted).
When I still had apache2, I finally had this problem : when opening "localhost" on Firefox, it was showing :
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /
on this server.<br>
</p>
<p>Additionally, a 403 Forbidden
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>
My main question for this post now :
Since I have deleted Apache2, "localhost" should not be working at all now on my browser (Firefox)... However, I still get the exact same page ?! Do you know why / can help me ?
Thanks a lot in advance to all who can help me, either to understand my problem better (so that I know a bit more where/how to search for answers), or to solve my problem (and help me work on my website again ^^) !
Have you already stopped Apache via systemctl? Something like sudo service stop apache2 (or is it sudo service apache2 stop), will stop the server from running. Even though you have uninstalled everything, the server process will still run if you haven't stopped it.

How do you remove SSL encryption after letsencrypt set up forced SSL?

I chose to force https on my server when setting up let's encrypt, not realizing what a NIGHTMARE it would cause for my Node.js WebSocket server. Nothing that I've found online works to get a secure WebSocket connection up and running. (Probably because I'm using Apache for everything aside from WebSockets)
So I've decided to just disable SSL site-wide. I don't have any real use for it as my server is strictly for development anyway.
I've tried the method here But Apache reports that the site is already disabled. So I cleared the cache on my browser and even tried to visit the site incognito to no avail.
I also looked at the instructions here but NONE of my site-available contain the lines that are mentioned.
Then I saw this post but my apache2.conf file did not contain the lines he mentioned either.
I'm puling my hair out.
If anyone else has this issue, here's what I did to solve it.
I saw a configuration file named <sitenam>-le-ssl.conf in /etc/apache2/sites-enabled So I tried a2dissite <sitename>-le-ssl.conf
But Apache said "the file doesn't exist"
So I copied that file to my home directory with cp <sitename>-le-ssl.conf ~(AND YOU SHOULD TOO! just in case...)
Then I deleted that file with sudo rm <sitename>-le-ssl.conf
Then, restart apache with sudo service apache2 restart
Finally, clear the cache on your browser and visit your site. Everything should be back to normal now.
No idea why letsencrypt set up my server in such an odd way. It didn't follow ANY of the standards that others said it should.
Hope this helps someone in the future.

Can't Access to my Amazon Instance with public Ip

I have a new amazon instance EC2, and I want to build a Web Server so I did :
Install apache2
Install libapache2-mod-php5
a2enmod rewrite
Add a Http rule in the default group to allow all IP
add Directory AllowOverride All in /etc/apache2/sites-availables/ default-conf
But when I want to check if apache is running by typing the public ip of the instance in my browser, I dont have the basic index.html "it's works". I got nothing.
What does i missed ?
Thanks you.
If apache is running fine, then it might be the firewall.
In the AWS console, make sure you have unblocked port 80 in the "Security Groups" under "Network & Security".
I found the solution.
It was a problem with the firewall.
The security group that I changed was not the one that was linked with my Instance
My bad.
do you know if the apache is running? you can check with:
ps aux |grep -i 'http\|apache'
if it has not started, you can try:
/etc/init.d/httpd start

Does Apache need to be stopped to edit "/etc/apache2/sites-available/default"?

I am attempting to edit the "default" file located at ..
"/etc/apache2/sites-available/default"
on my Ubuntu machine running Apache 2.2.8.
I want to do this in order to enable the use of .htaccess files. I have downloaded the "default" file and edited it and now I am trying to upload it back to the server via SFTP. I keep getting permission denied errors.
Could it be because Apache is running and making use of the file? I am an admin on the machine so I would expect to be able to overwrite the file. Thanks for any assistance.
No it does not need to be stopped.
Try accessing the file through ssh, and make sure you access it with root privileges:
sudo nano /etc/apache2/sites-available/default
You would still need to force-reload Apache after changing the config files, as tux21b suggested in a comment below:
sudo /etc/init.d/apache2 force-reload
For Apache/2.4.7 , the file that you want to edit is:
/etc/apache2/apache2.conf