I am using Google Cloud Platform to test out ModSecurity and I am using a tutorial to launch it. However, I need to restart Apache every once in a while. I'm using Ubuntu 18.04. I write sudo systemctl restart apache2, but an error comes back and it says Failed to restart apache2.service: Unit apache2.service not found. What should I do?
Did you install apache2 first ?
sudo apt install apache2
For those who run into the same issue using Debian
I did have apache2 installed and running as was confirmed by apache2.service | loaded active running.
I still tried to install it.
I did also get the same error Failed to restart apache2.service: Unit apache2.service not found
How I got apache2 to restart
Using: Debian (9.13)
sudo service apache2 restart
or by typing
sudo apachectl stop
sudo apachectl start
Type sudo apt install apache2
To start the apache service type
sudo systemctl start apache2
if you tried to install it and still got the same problem , you can update it , try :
apt-get update
Related
I wanted to install httpd-2.2.32. So I downloaded it from this link and installed it with the help of this guid.
It installed successfully and start it using this command,
sudo systemctl start apache2.service
but, I run below status command,
sudo systemctl status apache2.service
An error occurs as Can't open /etc/apache2/envvars
And localhost won't open
please help me to fix it
I'm building a new web server on a new M1 Mac Mini running the latest version of Big Sur, fresh install. Only thing I have done to the machine is install Chrome.
I'm installing Apache with the following:
Install xcode command line tools: xcode-select --install
Install Homebrew: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Install missing libraries: brew install openssl
Check to see if apache is running, remove any scripts:
sudo apachectl stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
Install httpd: brew install httpd
Configure autostart: brew services start httpd
At this point, httpd is running fine, and I can see the pages at http://localhost:8080
And I can confirm httpd starts up fine after reboot.
Issue is, I can't shut it down. if i issue the command brew services stop httpd, I get the following:
Mac-mini / % brew services stop httpd
Stopping httpd... (might take a while)
==> Successfully stopped httpd (label: homebrew.mxcl.httpd)
Mac-mini / %
Activity monitor still shows multiple instances of httpd running, though.
The only way to shut it down is either quit it in actvity monitor or issue the command
sudo apachectl -k stop
Any suggestions of why niether of the following commands work or how to track down the issue?
brew services stop httpd
brew services restart httpd
I had apache2 installed on my raspberry pi 4 and was getting some strange behavior so I removed it via apt remove apache2, removed the /etc/apache2 directory and reinstalled by sudo apt-get apache2 -y.
After reinstallation the server would not start, I determine that there was no apache2.conf file in /etc/apache2.
I've tried installing and reinstalling several time to no avail. What am I doing wrong?
try
sudo apt-get purge apache2
If you just want a light-weight http server you might want to try Nginx as a replacement.
sudo apt-get --reinstall install apache2
I am deploying Flask application in Apache2 server during this i need to run a command for enabling mod_wsgi by using:
sudo a2enmod wsgi
but its showing:
sudo: a2enmod: command not found
please help
thanks
I had the same problem with using Ubuntu 16.04 in AWS. However, installing apache2 along with libapache2-mod-wsgi and python-dev solved the issue.
Try:
sudo apt-get update
sudo apt-get install apache2 libapache2-mod-wsgi python-dev
Then,
sudo a2enmod wsgi
I share this tips because it append to me :
If you enter into the root account with su, the /usr/sbin folder is not in the path and the a2enmod command is not found...
So you have to use su - instead ;)
This can happen if you switch to root user as su root instead of su - on Debian Buster
Installation debugging
For asking about installation debugging, you have to post (and think) about
Architecture (hardware)
OS with version
Host attibution (server, desktop, other)
Procedure followed for installation
Software (apache) version
Anyway
You could try to reinstall your package. If under Ubuntu, you could try:
sudo apt update &&
sudo apt reinstall apache2 libapache2-mod-wsgi
Then rerun:
sudo a2enmod wsgi
I am trying to install Cobbler on a brand new Ubuntu 15.10 virtual box but it is not working. When I run the apt-get install cobbler cobbler-web it seems to break apache completely to the point I can't get it working again.
I see this in the apache error log:
[wsgi:crit] [pid 8112:tid 140273573488512] mod_wsgi (pid=8112): The mod_python module can not be used on conjunction with mod_wsgi 4.0+. Remove the mod_python module from the Apache configuration.
and this in the auth.log:
polkitd(authority=local): Unregistered Authentication Agent for unix-process:8081:54865 (system bus name :1.24, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
I have tried removing the mod_python and wsgi modules but apache still doesn't start up. And I think Cobbler uses them anyways, so I kind of need them.
I have also tried disabling polkitd. I don't find any clues when searching for that weird error message.
I was able to install Cobbler on Ubuntu 14.04 pretty easily and apache works fine.
Here is the basic chain of install commands I used:
apt-get update
apt-get install apache2
apt-get install isc-dhcp-server
apt-get install bind9 bind9utils bind9-doc
apt-get install cobbler cobbler-web debmirror mkisofs
Disable the module by typing sudo a2dismod python
You should then see this:
Module python disabled. To activate the new configuration, you need to
run: service apache2 restart
So type sudo service apache2 restart.
If that doesn't fix it, check the error log for more information by typing
cat /var/log/apache2/error.log.