A brief checklist of common things you would like to configure in your Apache webserver.
httpd.conf file on Mac OsX
httpd.conf file is located at
Activate PHP modules
If you have installed the Liip’s PHP version, take care of the paths!
#LoadModule rewrite_module libexec/apache2/mod_rewrite.so #LoadModule php5_module libexec/apache2/libphp5.so
Uncomment the lines, set the right path to PHP if you are using the Liip’s one and add the support for
LoadModule rewrite_module libexec/apache2/mod_rewrite.so LoadModule php5_module /usr/local/php5/libphp5.so AddType application/x-httpd-php .php .phtml
Configure the Apache user group
Change the default
_www user to your username and add the
Group: this will ease your work when dealing, for example, with the upload of files.
# # If you wish httpd to run as a different user or group, you must run # httpd as root initially and it will switch. # # User/Group: The name (or #number) of the user/group to run httpd as. # It is usually good practice to create a dedicated user and group for # running httpd, as with most system services. #
User _www Group _wwwUser Aerendir Group #-1
Configure the ServerName
The comments are really clear: uncomment the
ServerName directive and set it to
# # ServerName gives the name and port that the server uses to identify itself. # This can often be determined automatically, but we recommend you specify # it explicitly to prevent problems during startup. # # If your host doesn't have a registered DNS name, enter its IP address here. #
ServerName www.example.com:80ServerName localhost:80
Open the access to directories in the
# # Deny access to the entirety of your server's filesystem. You must # explicitly permit access to web content directories in other # blocks below. # <Directory/> Options Indexes FollowSymLinks AllowOverride none </Directory>
# # DocumentRoot: The directory out of which you will serve your # documents. By default, all requests are taken from this directory, but # symbolic links and aliases may be used to point to other locations. # DocumentRoot "/path/to/your/document/root" <Directory "/path/to/your/document/root"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.4/mod/core.html#options # for more information. #
Options FollowSymLinks Multiviews MultiviewsMatch AnyOptions All # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # AllowOverride FileInfo AuthConfig Limit # AllowOverride NoneAllowOverride All # # Controls who can get stuff from this server. # Require all grantedOrder allow,deny Allow from all </Directory>
index.php as default Index
# # DirectoryIndex: sets the file that Apache will serve if a directory # is requested. # <IfModule dir_module> DirectoryIndex index.html index.php </IfModule>
Configure the use of
Immediately below the
IfModule dir_module block, add the following one:
# # AccessFileName: The name of the file to look for in each directory # for additional configuration directives. See also the AllowOverride # directive. # AccessFileName .htaccess
The following lines about
FilesMatch can be modified as so:
# # The following lines prevent .htaccess and .htpasswd files from being # viewed by Web clients. #
<FilesMatch "^\.([Hh][Tt]|[Dd][Ss]_[Ss])"> Require all denied<FilesMatch "^\.ht"> Order allow,deny Deny from all Satisfy All </FilesMatch>
Add the following block immediately below:
<Files ~ "^\.DS_Store"> Order allow,deny Deny from all </Files>
I prefer to have logs in the same folder of my
# # ErrorLog: The location of the error log file. # If you do not specify an ErrorLog directive within a # container, error messages relating to that virtual host will be # logged here. If you *do* define an error logfile for a # container, that host's errors will be logged there and not here. #
ErrorLog "/private/var/log/apache2/error_log"ErrorLog "/path/to/your/document/root/logs/apache_error_log"
Set the level of logging
# # LogLevel: Control the number of messages logged to the error_log. # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. #
LogLevel warnLogLevel debug
and comment the subsequent
# # The location and format of the access logfile (Common Logfile Format). # If you do not define any access logfiles within a # container, they will be logged here. Contrariwise, if you *do* # define per- access logfiles, transactions will be # logged therein and *not* in this file. # #CustomLog "/private/var/log/apache2/access_log" common
Set the default MIME type of served files
Find the line
< IfModule mime_module > and immediately above copy the following block:
# # DefaultType: the default MIME type the server will use for a document # if it cannot otherwise determine one, such as from filename extensions. # If your server contains mostly text or HTML documents, "text/plain" is # a good value. If most of your content is binary, such as applications # or images, you may want to use "application/octet-stream" instead to # keep browsers from trying to display binary files as though they are # text. # DefaultType text/plain
# # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for all requests that do not # match a ServerName or ServerAlias in any block. # NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin email@example.com DocumentRoot "/Users/Aerendir/Documents/JooServer/" ServerName localhost ServerAlias localhost
ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log" CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common<Directory /path/to/your/document/root/> DirectoryIndex index.php Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
Delete or the other blocks.
$ sudo apachectl restart
And now, maybe you’d like to update the Mac OsX built-in version of PHP.
Here there are other information about the Mac OsX built-in Apache webserver.
If you have any problems starting Apache after the editings, use
configtest typing in the Terminal:
$ apachectl configtest
Remember to “Make. Ideas. Happen.”.
I wish you flocking users, see you soon!
[…] once you have configure your php.ini, maybe you want to configure your Mac Osx built-in Apache or want to install MySQL in your Mac (as it is not shipped by […]