Mac (OSX) Apache cannot start localhost cannot access server []

Source: Internet
Author: User

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 []

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.