Problem Description: Apache does not work properly after restarting the computer due to the deletion of the log below/private/var/log.
The purpose of deleting log is: When the system is used for a long time, the log file occupies dozens of g of hard disk capacity.
The result: Apache does not function properly after restarting the computer, and accessing localhost or 127.0.0.1 will not be able to find the server.
Exploration: After the problem occurs, because the $ sudo apachectl start will not report any errors, access to localhost or 127.0.0.1 always fails.
Possible Scenario 1: No 80 ports listening
Exclusion possible 1: My Apache, I am aware that I am listening on 80 ports.
There may be a problem with the configuration of the 2:hosts file
The exclusion may 2:localhost before the problem, and has not changed, ruled out.
Suspect point: 80 port occupied
Exclude suspicion point: Terminal runs $ sudo lsof-itcp:80-stcp:listen, no other program is found to occupy, exclude this doubt.
That's weird! So... (Terminal $ sudo/usr/sbin/httpd-k start) The problem arose: No such file or directory:httpd:could not open error log file/private/var/log/ Apache2/error_log.
Remember that yesterday deleted all log files under Log, and finally create a folder apache2, OK.
The workaround is: in the log directory, create a new folder named Apache2 (Terminal $ sudo mkdir/private/var/log/apache2), and then restart Apache (terminal $ sudo apachectl restart), It will automatically regenerate the logs required by Apache in the Apache2, and will be able to access and use Apache services normally.
Mac (OSX) Apache cannot start localhost cannot access server []