Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

how to activate apache2 as localhost?

i am on an iMac 21,5 of mid 2011; Mem 4G, 1333 MHz, DDR3 - OS X El Capitan


I have a website in HTML/CSS where I want to integrate PHP-Scripts. To test this I want to use apache2 as localhost.

But I cannot connect to it. It seems there have to be made certain adjustments in the httpd.conf file, and I got as far as to: sudo nano etc/apache2/httpd.conf on the terminal-app. But from there I got lost. I am a beginner at this and I would appreciate if someone could tell me what to do in as simple as possible a language. Thanks a lot!

iMac (21.5-inch Mid 2011), OSX 10.11.6

Posted on Sep 7, 2016 7:15 AM

Reply
9 replies

Sep 9, 2016 2:42 AM in response to BobTheFisherman

1) I solved the problem in the Terminal app because I noticed the conflict between mouse curser and curser on the terminal.


2) But I did not see the line -rw-r--r-- 1 root wheel 298 June28 16:47 username.conf


3) If I enter http://localhost "it works", but after sudo nano apachectl restart

the localhost followed by my name the page cannot be found. I have uncommented all the necessary lines and passed through the whole process twice.


4) I found a file "index.html" in the Sites folder and tried to enter a small php-script. the php was not recognized.


Is there a chance to make this work at all?


I would be most grateful for your support!

Sep 9, 2016 7:03 AM in response to helgafromfr

If you entered php code in the index.html file you would then need to change the name of the file to index.php otherwise the server would not recognize the file as containing php code.


"Is there a chance to make this work at all?" Yes it works very well when the configuration is correct. You appear to be doing things without understanding what you are doing, creating php code without changing file names, trying to use nano without knowing what it does or how it does it, making conf file changes without knowing what the changes affect. I suggest you find some tutorials online and study how AMP servers work and how to configure them. The subject is too large to address fully and adequately in this community.

Sep 10, 2016 11:15 AM in response to BobTheFisherman

I'm sorry but where should I delete the httpd.conf file? Is it the one that appears on the Terminal under my name when I type in sudo nano /etc/apache2/httpd.conf? If I have to delete this file, is it on the terminal app and how exactly? I do have time machine, but the file doesn't show for reset.

I'm still lost and very sorry hope not to drive you nuts.

Sep 11, 2016 6:02 AM in response to helgafromfr

You don't need time machine. It is common practice when editing conf files in terminal that you save the original file with a new filename before editing the file. This way if and when you make errors to the conf file you can always start over because you still have the original file. You did do this saving of the original file before you started editing it did you not?


If you don't know how to delete a file in terminal I suggest you get some basic instruction before proceeding. You can seriously damage your system files if you do not know what you are doing in terminal.

Sep 11, 2016 6:29 AM in response to BobTheFisherman

Hello Bob,


I know that I did not save the original file and you are right about saying that that was bloody careless of me. I have not before been doing any "programming" and when I started with HTML and creating my website it seemed easy to handle. I wanted to also do some php which wouldn't work (obviously) and then I read somewhere Apache is the thing to have. I downloaded a package but that failed me as well. Then I found out from a new search that Apache is already installed on my iMac and that it is called apache2. So that was when I joined the apple forum and got onto your website. I went a long way already and I wouldn't like to give up, so if there is no other possibility I could reinstall El Capitan and start afresh with the little experiences I could collect so far.

I am writing all this to explain that my intention is not to waste your time. If you feel that you cannot help me at this point I will fully understand.

Best regards,

Helga

how to activate apache2 as localhost?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.