apache doesn't restart on vagrant - apache

I have a vagrant site setup on my machine as client-machine by vagrantfile (received it from client).
Now on on the machine, I'm unable to restart the apache server. I did the following commands.
sudo service apache2 restart
dpkg-reconfigure -plow apache2
both are giving me following error.
Restarting web server apache2 [fail]
The apache2 configtest failed.
Output of config test was:
apache2: Syntax error on line 219 of /etc/apache2/apache2.conf: Could not open configuration file /etc/apache2/sites-enabled/default.conf: No such file or directory
Action 'configtest' failed.
The Apache error log may have more information.
invoke-rc.d: initscript apache2, action "restart" failed.
Also, when I try to access the error log, it's giving me permission issue.
please help me resolve this issue.
Thanks,
Dilip Gupta

Related

Error creating apache certificate

I have a CentOS server and I'm trying to install Apache Certificate using the following command:
certbot --apache -d myDomain.com
But I'm getting the following error:
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Starting new HTTPS connection (1): acme-v01.api.letsencrypt.org
Obtaining a new certificate
Performing the following challenges:
tls-sni-01 challenge for myDomain.com
Error while running apachectl graceful.
Job for httpd.service invalid.
Cleaning up challenges
Error while running apachectl graceful.
Job for httpd.service invalid.
Encountered exception during recovery
Error while running apachectl graceful.
Job for httpd.service invalid.
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/certbot/error_handler.py", line 100, in _call_registered
self.funcs[-1]()
File "/usr/lib/python2.7/site-packages/certbot/auth_handler.py", line 284, in _cleanup_challenges
self.auth.cleanup(achalls)
File "/usr/lib/python2.7/site-packages/certbot_apache/configurator.py", line 1945, in cleanup
self.restart()
File "/usr/lib/python2.7/site-packages/certbot_apache/configurator.py", line 1834, in restart
self._reload()
File "/usr/lib/python2.7/site-packages/certbot_apache/configurator.py", line 1845, in _reload
raise errors.MisconfigurationError(str(err))
MisconfigurationError: Error while running apachectl graceful.
Job for httpd.service invalid.
Error while running apachectl graceful.
Job for httpd.service invalid.
I check if Apache was running:
ps aux|grep httpd
root 16569 0.0 0.0 9064 920 pts/1 S+ 14:44 0:00 grep --color=auto httpd
I had no instances of apache running.
Any of you knows how can I fix this error or if there is workaround this?
I'll really appreciate your help.
certbot is clearly trying to start/restart apache and that's failing. There could be many reasons for that, and I would start by looking for the apache error log and seeing what it has. (There can be more than one, so check the timestamps.)
It would also be interesting to know if apache can start at all. What happens with a plain old apachectl start?

Setting up SSL on raspberry pi

I have a raspberry pi with apache on it, and I would like to set up SSL on it.
Issues and what I have tried:
When I try to activate the SSL module and run the command: sudo a2enmod ssl and sudo a2enmod default-ssl I get command not found.
My second issue is that I cannot restart the apache webserver, I would run the command sudo /etc/init.d/apache2 restart and as a result I get apache2.serviceJob for apache2.service failed. See 'systemctl status apache2.service' and 'journalctl -xn' for details.
What am I doing wrong?
Any advice is greatly appreciated.
Thanks in advance
Do you have a default-ssl.conf file in [wherever-it-is]/mods-available/default-ssl.conf
sudo nano it into existence if not,
restarting the server, have you tried "sudo service apache2 restart" or replace "restart" with "reload"?
How do you normally access services on a Pi?

Tomcat not Restarting :: Syntax error on line 106 of /etc/httpd/conf/httpd.conf

When i logged into my remote system (Amazon Linux) after executing apache2 recipe, the httpd service was running, i checked it by using service httpd status, then i wrote service httpd restart after that service stopped but didnt restart. It gives me following error.
[root#java-app1 webapps]# sudo service httpd restart
Stopping httpd: [ OK ]
Starting httpd: httpd: Syntax error on line 106 of /etc/httpd/conf/httpd.conf: Syntax error on line 1 of /etc/httpd/mods-enabled/systemd.load: Cannot load /usr/lib64/httpd/modules/mod_systemd.so into server: /usr/lib64/httpd/modules/mod_systemd.so: cannot open shared object file: No such file or directory
[FAILED]

Failed to get D-Bus connection - httpd service in Docker container

I am creating a Dockerfile for PostgreSQL with CentOS7 as the base image. I am trying to start httpd service with the following command in the container,
service httpd start
and i get the following error:
Redirecting to /bin/systemctl start httpd.service
Failed to get D-Bus connection: No connection to service manager.
The log file directory /var/log/httpd is also empty. I guess this is the problem with Docker CentOS7 image. Any help appreciated.
I have run into this a well.
It might not be the best way, but you can find a copy of the /etc/init.d/httpd file from another computer. copy that into the container in /etc/init.d
then run
chkconfig --level 345 httpd on
then you will be able to use either
/etc/init.d/httpd start or service httpd start

$ service apache2 restart [fail]

I have installed Apache on my Ubuntu Server.
For a special reason I have to enable mod_rewrite on it.
So I have done this.
And in every Tutorial on the internet the last command is to restart apache.
But when I do this the console prints [fail].
Can anyone help me here?
$ service apache2 restart
* Restarting web server apache2 [fail]
I had a similar problem, and for me it was about the logged in user not having privileges so instead of
service apache2 restart
I had to do
sudo service apache2 restart
It's telling you some other service is already on port 80, perhaps it's apache
try Code:
sudo /etc/init.d/apache2 stop
followed by Code:
sudo killall apache2
then make sure no services are running on port 80 Code:
sudo netstat -l|grep www
then (re)start apache Code:
sudo /etc/init.d/apache2 restart
Using the systemd features ( starting from Ubuntu 15) , you can restart apache service as follow :
sudo systemctl restart apache2.service
Check the status:
sudo systemctl status apache2.service
There are various reason for this one .
could be the privilege problem if you have privilege problem then
please use sudo for the same .
could be the apache already running in your system then please check the
status of the service by running command service apache2 status if they
said that [FAIL] apache2 is not running ... failed! it mean it is not running
you can start by the command service apache2 start or sudo service
apache2 start
if you having not above problem please look at the PID file of
apache2 by following command cat /var/run/apache2/apache2.pid
which will give you the process ID of the apache it means you
system accidentally shutdown without deleting the PID file so
delete by following command rm - rf/var/run/apache2/apache2.pid or sudo rm -rf/var/run/apache2/apache2.pid and start again the server by
following command service apache2 start or sudo service
apache2 start
I face this issue when I was adding new web site to my web server which is hosted in Digital Ocean Cloud service. So what happened was, when I using sudo commands to restart or reload apache2 server its restring with following error messages.
For me everything worked well despite these two error messages.
Error 1 - Unable to resolve host 'YOUR HOST NAME' .
Error 2 - sum_functio_error() //I don't remember this function name I'll update this later.
So the fix was very simple.
First open your hotsts file.
sudo nano /etc/hosts
Output File
127.0.1.1 hostname
127.0.0.1 localhost
sudo nano /etc/hostname
Output File
hostnamexxx
Try below command to restart.
# /etc/init.d/apache2 restart
OR
$ sudo /etc/init.d/apache2 restart
OR
$ sudo service apache2 restart
To stop Apache 2 web server, enter:
# /etc/init.d/apache2 stop
OR
$ sudo /etc/init.d/apache2 stop
OR
$ sudo service apache2 stop
To start Apache 2 web server, enter:
# /etc/init.d/apache2 start
OR
$ sudo /etc/init.d/apache2 start
OR
$ sudo service apache2 start