Hot answers tagged

58

As morth pointed out, for the default Mac OS X Apache installation these are located in: /var/log/apache2/error_log. The location can be changed in the httpd config using the ErrorLog directive, even for individual virtual hosts. Also note that if you installed another Apache besides the built-in one (like through MacPorts, or MAMP), this probably is ...


37

Had the same problem. I deleted one of my project's folder and it became broken. In this case the site's configs should be removed from httpd-vhosts.conf and httpd.conf. Try ping 127.0.0.1 apachectl configtest can help you to detect the problem.


35

LockFile is one of the directives of Apache ≤ 2.2. This was replaced by Mutex in Apache 2.4, which is the version of Apache installed with OS X 10.11, El Capitan. Edit the file /etc/apache2/extra/httpd-mpm.conf to remove this part: # # The accept serialization lock file MUST BE STORED ON A LOCAL DISK. # <IfModule !mpm_winnt_module> <IfModule !...


32

You first need to enable Apache in the Sharing prefpane. Check "Web sharing" and your web server is running. Note that since Mountain Lion, Web Sharing was removed from the Sharing preference pane, but Apache is still included. Check this answer for controlling Apache in Mountain Lion. To activate PHP you'll need to edit /etc/apache2/httpd.conf in ...


25

OS X provides launchctl to control which daemons are started at boot time. To stop and disable Apache: Open Terminal Type the following command (type your login password when sudo requests it): sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist A few words on launchctl's -w option The -w option is the silver bullet for ...


18

Here is how you can re-enable the web page with the command line using Terminal. First copy this and paste it into Terminal. You may have to press enter after pasting to run it. It will ask for your password because it is adding a file to your system directory. USER_DIR=$(basename $(echo ~)) sudo bash -c "cat > /etc/apache2/users/$USER_DIR.conf" <&...


18

I have an alias specified in OSX server pointing to a user directory. I spent a long while chmodding and messing with _www user, adding executable permissions recursively, uninstalling macports and all sorts of stuff trying to get this to work. No idea why it wasn't working. Eventually, I just checked the "shared folder" checkbox in the Finder for that ...


16

I looked up the information on the file http-mpm.conf at the Apache website: It says LockFile is a correct directive. I don't know why I'm getting the same error you are. So in terminal, I went to: /etc/apache2/extra and restored the httpd-mpm.conf file from before I loaded El Capitan. I used these commands: sudo mv httpd-mpm.conf httpd-mpm.conf....


15

Edit /private/etc/apache2/httpd.conf Find the line that says LoadModule php5_module libexec/apache2/libphp5.so and uncomment it by editing out the # at the beginning of the line. (Then save the file, obviously.) Go to Terminal and type sudo apachectl graceful at the console:


15

/etc/php.ini.default serves only as a reference and is not read out by PHP at all. The built-in PHP installation will look for the file /etc/php.ini instead. This file is not present by default, but you can copy /etc/php.ini.default to /etc/php.ini and make your modifications in there. You could also just create an empty file and only add any directives you ...


14

Instead of guessing which php.ini you need to alter, run this command to locate the file: php -r 'phpinfo();' | grep 'php.ini' Even though I use MAMP PRO, by default my command-line PHP commands are not executed using their copy of PHP. In my case it says the file is found at /etc/php.ini Once you have located the file, follow the instructions on all of ...


13

To start apache sudo apachectl start This will give you a basic Apache server with a DocumentRoot at /Library/WebServer/Documents/ You can enable things like PHP and virtualhosts by making use of the configuration file, which must be edited as root: /etc/apache2/httpd.conf Restart the apache server (like after editing the config file) with sudo apachectl ...


13

Removing system macOS binaries is not a good idea, they will be reinstalled during a next system upgrade and they could be needed by some system scripts. To enable the homebrew php from the command line, read the output of brew info php70: If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc, ~/.zshrc, ~/....


13

In my opinion you hosed your various httpd launch daemons/start mechanisms by executing too many httpd related commands. With homebrew and homebrew's apache-httpd installed and the default PATH you have six ways to start httpd. Apple's Apache: sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist sudo /usr/sbin/apachectl start ...


12

You should make sure that in your /etc/apache2/users/username.conf you have the following: <Directory "/Users/username/Sites/"> Options Indexes MultiViews FollowSymlinks AllowOverride All Order allow,deny Allow from all </Directory> The FollowSymlinks and AllowOverride are essential here. While you are hinting at both in your ...


12

Regarding homebrew httpd, one issue I recently ran into was an old leftover httpd.pid file that was preventing httpd from starting. Symptom was apachectl start said httpd is already running, but it was not. Cause was an old file here: /usr/local/var/run/httpd/httpd.pid Solution was to delete this pid file and then httpd started.


10

I had exactly the same problem. I started Apache without DocumentRoot(s). It did the trick. sudo apachectl -T


10

I update to macOSS Sierra, Version 10.12 I face the same issue, I did two things to fix it properly. Following is my approaches. 1) Please check "/private/etc/apache2/extra/httpd-userdir.conf" file. Change #Include /private/etc/apache2/users/*.conf to Include /private/etc/apache2/users/*.conf 2)**And edit your "/etc/apache2/httpd.conf" change ...


10

I had the same problem - it's based on mod_userdir exclusion after updating to Mac OS X Mojave. There are a few steps to repair that: Load the module mod_userdir in /etc/apache2/httpd.conf At the end of the httpd.conf make sure to load httpd-userdir.conf In httpd-userdir.conf include a local file in /etc/apache2/users/<username>.conf Put a directory ...


9

I generally fix this by setting the Apache user to myself in local environments and in machines where the only user who uses Apache is me. In /private/etc/apache2/httpd.conf, set User to your username from _www, e.g.: User _www -> User joao And then restart Apache: $ sudo apachectl restart Additional steps: If you have active sessions, they are going ...


9

There should be 3 files in /Library/WebServer/Documents: index.html.en PoweredByMacOSX.gif PoweredByMacOSXLarge.gif If these files are missing, it really shouldn't matter. As soon as you create your own HTML file and place it in that folder, the "It works!" message should be replaced with your new index.html file. Hope this helps.


9

I found a solution to your problem here. Using Terminal "How do I make Apache start automatically": sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist You were close to the solution just needed the -w override. the -w Overrides the Disabled key and sets it to false.


9

After updating to macOS Sierra, Apache httpd moves the old httpd.conf to httpd.conf.pre-update and place the new one. In order to work the localhost work please try the below procedure: cd /etc/apache2/ sudo mv httpd.conf httpd.conf-afterupdate sudo mv httpd.conf.pre-update httpd.conf sudo apachectl configtest sudo apachectl restart Then test: ...


8

1. How do you configure your vhosts? The "Lion way" to do so would be uncommenting the following line in your httpd.conf. #Include /private/etc/apache2/extra/httpd-vhosts.conf Now you can edit /private/etc/apache2/extra/httpd-vhosts.conf and put your vhosts in there. It's a good idea to start with a default one that will match all unqualified hosts, for ...


8

The file /etc/apache2/original/httpd.conf (in OS X 10.11.5) has the following content with three trailing empty lines: # # This is the main Apache HTTP server configuration file. It contains the # configuration directives that give the server its instructions. # See <URL:http://httpd.apache.org/docs/2.4/> for detailed information. # In particular, ...


8

This worked for me when I ran into the same problem. Please check "/private/etc/apache2/extra/httpd-userdir.conf" file. change #Include /private/etc/apache2/users/*.conf to Include /private/etc/apache2/users/*.conf and restart apache. From: https://stackoverflow.com/questions/39631351/apache-localhost-403-forbidden-with-macos-sierra


7

Generate a host key First, make a home for the new SSL files. I use /etc/apache2/ssl. Open up a terminal window, cd to the new directory and issue the following command to create a host key file. sudo ssh-keygen -f host.key Generate a certificate request file This command create a certificate request file. A certificate request file contains information ...


7

OK, so I found the culprit. It is amazing that no error message was visible in console or in the error logs, but I found a site which helped me a lot. http://blog.joshdick.net/2012/07/28/troubleshooting_apache_in_os_x_10.8_mountain_lion.html In that post, the author, Josh, suggested restarting apache using the following command: sudo bash -x /usr/sbin/...


7

It looks like you have nearly everything correct. I'm running Mavericks with a couple dozen virtual hosts, so this should work for you. First, and this might be all you need to do to fix things, you need to enclose your DocumentRoot in quotes. So, DocumentRoot /Users/gdboling/Sites/rocket-gen becomes DocumentRoot "/Users/gdboling/Sites/rocket-gen" ...


7

You have to edit the file /usr/local/etc/apache2/2.4/httpd.conf. Search for and uncomment the following two lines (remove the # at the beginning of the line): #LoadModule vhost_alias_module libexec/mod_vhost_alias.so #Include /usr/local/etc/apache2/2.4/extra/httpd-vhosts.conf Then edit the file /usr/local/etc/apache2/2.4/extra/httpd-vhosts.conf to suit ...


Only top voted, non community-wiki answers of a minimum length are eligible