0

After using apache in a local dev setup it has suddenly stopped working. I have tried pinging a previously used custom domain and I'm not getting anything.

I have checked the syntax its correct according to apache. I have made sure that my custom domain is in my hosts file. All seems ok.

I have tried this sudo bash -x /usr/sbin/apachectl -k start and still nothing. Error or access logs don't show any errors or warnings.

I have also checked the permissions of the folder I'm trying to accesses and it is drwxrwxrwx and a random file inside of the folder has -rwxrwxrwx@ and the parent folder is drwxrwxrwx 34 _www staff 1.1K Feb 4 20:06 www

There were no changes to my httpd file, but I checked it anyways. I tried disabling it Include /private/etc/apache2/other/*.conf (which contains virtual hosts) and Include /private/etc/apache2/extra/httpd-vhosts.conf and added one of the previously working vhosts at the end of the httpd file.

Not sure how to proceed as there is no error or flags. The only thing that might have changed are the permissions, but it did work after changing it.

edit: should also add that I'm on Mountain Lion.

3
  • So you're just running Apache on localhost, right? What do you get from apachectl status? Have you tried restarting it from the init.d script? (Should be something like /etc/init.d/httpd restart.) What happens when you do so there? Also, does it indicate that Apache is running when you do a ps aux | grep apache or ps aux | grep httpd?
    – Nate
    Feb 5, 2013 at 16:40
  • -bash: /etc/init.d/httpd: No such file or directory. ping localhost:80 gets me a response but the address given by apachectl status doesn't work. ps aux | grep apache doesn't return anything, but ps aux | grep httpd says _www 12397 0.0 0.0 2454312 936 ?? S 12:10PM 0:00.00 /usr/sbin/httpd -D FOREGROUND and root 12397 0.0 0.0 2454312 936 ?? S 12:10PM 0:00.00 /usr/sbin/httpd -D FOREGROUND
    – alme1304
    Feb 5, 2013 at 17:19
  • What happens if you do the following command in a terminal window: telnet localhost 80?
    – Jenny D
    Feb 6, 2013 at 10:04

1 Answer 1

1

After more troubleshooting and research I ran file -b /etc/hosts and to my surprise line endings had changed. For the hosts file to work, the output from the command can only be ASCII English text, anything about line endings will brake it and cause your DNS to stop working. To fix it, I ran:

tr -d '\r' < /etc/hosts > output.txt and then replaced my hosts file with the new output.txt. After that, I used vim to add line breaks again

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .