Project D

Apache 2 - Installation for Local Server Reminder

This page is just my personal notes to remind me of how to configure apache2 web server for my local developing and testing server.

The information here may not fit to your need nor be the “right” way to install apache 2 server in your box, so use the information wisely.

Local Server Goal
1. Ability to use PHP
2. Clean urls capable
3. Multiple Vhosts with different ip address.
4. eliminate the need for 777 permission
5. Mysql database capability with phpmyadmin
6. auto restart during the reboot since this is a local server that is not online 24/7.
7. perhaps in the future combined with name server or domain name.

Emerging Packages

Installing apache 2 the gentoo way :
1. Setting up the apache 2 flag for my needs:

echo "www-servers/apache ssl -debug -doc -ldap -selinux -sni -static suexec -threads actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias -asis -auth_digest -authn_dbd -cern_meta -charset_lite -dbd -dumpio -ident -imagemap -log_forensic -proxy -proxy_ajp -proxy_balancer -proxy_connect -proxy_ftp -proxy_http -substitute -version -event -itk -peruser -prefork -worker" >> /etc/portage/package.use

2. emerge the package :

emerge apache

Installing PHP
1. Setting up php use flags :

echo "dev-lang/php  apache2 bcmath berkdb bzip2 calendar cdb cgi cjk cli crypt ctype curl curlwrappers filter ftp gd gdbm hash iconv imap json mysql mysqli ncurses nls pcre pdo posix postgres readline reflection session simplexml soap sockets spl ssl tidy truetype unicode xml xmlreader xmlrpc xmlwriter xsl zip zlib -adabas -birdstep -concurrentmodphp -db2 -dbase -dbmaker -debug -discard-path -doc -empress -empress-bcs -esoob -exif -fastbuild -fdftk -firebird -flatfile -force-cgi-redirect -frontbase -gd-external -gmp -inifile -interbase -iodbc -ipv6 (-java-external) -kerberos -kolab -ldap -ldap-sasl -libedit -mcve -mhash -msql -mssql -oci8 -oci8-instant-client -odbc -pcntl -pic -qdbm -recode -sapdb -sharedext -sharedmem -snmp -solid -spell -sqlite -suhosin -sybase -sybase-ct -sysvipc -threads -tokenizer -wddx -xpm -yaz -zip-external"

2. emerge the package :

emerge php

Installing mysql

1. Setting the right use flags :

echo "berkdb perl ssl -big-tables -cluster -debug -embedded -extraengine -latin1 -max-idx-128 -minimal -selinux -static"

2. emerge the package :
emerge dev-db/mysql

Configuring the package

Configuring Apache :
1. edit the /etc/apache2/http.conf :

LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule auth_basic_module modules/mod_auth_basic.s
LoadModule authn_alias_module modules/mod_authn_alias
LoadModule authn_anon_module modules/mod_authn_anon.s
LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_default_module modules/mod_authn_def
LoadModule authn_file_module modules/mod_authn_file.s
LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_default_module modules/mod_authz_def
LoadModule authz_groupfile_module modules/mod_authz_g
LoadModule authz_host_module modules/mod_authz_host.s
LoadModule authz_owner_module modules/mod_authz_owner
LoadModule authz_user_module modules/mod_authz_user.s
LoadModule autoindex_module modules/mod_autoindex.so
<ifdefine CACHE>
LoadModule cache_module modules/mod_cache.so
</ifdefine>
LoadModule cgi_module modules/mod_cgi.so
<ifdefine DAV>
LoadModule dav_module modules/mod_dav.so
</ifdefine>
<ifdefine DAV>
LoadModule dav_fs_module modules/mod_dav_fs.so
</ifdefine>
<ifdefine DAV>
LoadModule dav_lock_module modules/mod_dav_lock.so
</ifdefine>
LoadModule deflate_module modules/mod_deflate.so
LoadModule dir_module modules/mod_dir.so
<ifdefine CACHE>
LoadModule disk_cache_module modules/mod_disk_cache.s
</ifdefine>
LoadModule env_module modules/mod_env.so
LoadModule expires_module modules/mod_expires.so
LoadModule ext_filter_module modules/mod_ext_filter.s
<ifdefine CACHE>
LoadModule file_cache_module modules/mod_file_cache.s
</ifdefine>
LoadModule filter_module modules/mod_filter.so
LoadModule headers_module modules/mod_headers.so
LoadModule include_module modules/mod_include.so
<ifdefine INFO>
LoadModule info_module modules/mod_info.so
</ifdefine>
LoadModule log_config_module modules/mod_log_config.s
LoadModule logio_module modules/mod_logio.so
<ifdefine CACHE>
LoadModule mem_cache_module modules/mod_mem_cache.so
</ifdefine>
LoadModule mime_module modules/mod_mime.so
LoadModule mime_magic_module modules/mod_mime_magic.s
LoadModule negotiation_module modules/mod_negotiation
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule speling_module modules/mod_speling.so
<ifdefine SSL>
LoadModule ssl_module modules/mod_ssl.so
</ifdefine>
<ifdefine STATUS>
LoadModule status_module modules/mod_status.so
</ifdefine>
LoadModule unique_id_module modules/
mod_unique_id.so
<ifdefine USERDIR>
LoadModule userdir_module modules/mod_userdir.so
</ifdefine>
LoadModule usertrack_module modules/mod_usertrack.so
LoadModule vhost_alias_module modules/mod_vhost_alias

User apache
Group apache

Include /etc/apache2/modules.d/*.conf

AddType application/x-httpd-php   .php
AddHandler application/x-httpd-php .php

### OPTIONAL FOR SUPHP ####
suPHP_Engine On

<location />
SuPHP_AddHandler x-httpd-php

DirectoryIndex index.php index.htm index.html default.htm default.html

2. edit the /etc/conf.d/apache2 :

APACHE2_OPTS="-D DEFAULT_VHOST -D SUPHP -D REWRITE -D INFO -D LANGUAGE -D SSL -D SSL_DEFAULT_VHOST -D PHP5 -D USERDIR -D SUEXEC -D PROXY"

PIDFILE=/var/run/apache2.pid
SERVERROOT=/usr/lib/apache2
CONFIGFILE=/etc/apache2/httpd.conf

3. Create new vhost file in /etc/apache/vhosts.d/duckzland.vhost.conf

#<ifdefine DEFAULT_VHOST>
Listen 80

NameVirtualHost 192.168.2.8:80
<virtualhost 192.168.2.8:80>
        ServerName 192.168.2.8:80
        ServerAdmin duckzlandd@yahoo.com
        RewriteEngine On
        DocumentRoot /home/name1/public_html
        <directory "/home/name1/public_html">
          Options None
          AllowOverride All
          Order allow,deny
          Allow from all
#       AccessFileName .htaccess
        SuPHP_UserGroup masindot masindot
        </directory>
 </virtualhost>

NameVirtualHost 192.168.2.188:80
<virtualhost 192.168.2.188:80>
        ServerName 192.168.2.188:80
        ServerAdmin duckzlandd@yahoo.com
        RewriteEngine On
        DocumentRoot /home/name2/public_html
        <directory "/home/name2/public_html">
          Options None
          AllowOverride All
          Order allow,deny
          Allow from all
#AccessFileName .htaccess
        SuPHP_UserGroup duckzlan duckzlan
        </directory>
 </virtualhost>
NameVirtualHost 192.168.2.88:80
<virtualhost 192.168.2.88:80>
        ServerName 192.168.2.88:80
        ServerAdmin duckzlandd@yahoo.com
        RewriteEngine On
        DocumentRoot /home/name3/public_html
        <directory "/home/name3/public_html">
          Options None
          AllowOverride All
          Order allow,deny
          Allow from all
        </directory>
 </virtualhost>
</ifdefine>

4. renaming the /etc/apache2/vhosts.d/00_default_vhost.conf

mv /etc/apache2/vhosts.d/00_default_vhost.conf /etc/apache2/vhosts.d/00_default_vhost.conf.orig

5. adding apache to default runlevel

rc-update add apache2 default

6. creating the ifconfig aliases

echo "ifconfig wlan0:1 192.168.2.8 up" >> /etc/conf.d/local.start
echo "ifconfig wlan0:2 192.168.2.188 up" >> /etc/conf.d/local.start
echo "ifconfig wlan0:3 192.168.2.88 up" >> /etc/conf.d/local.start

configuring mysql

as for the now, the default mysql configuration file should works. But if in the future any modification needed, it will be logged here.

rc-update add mysql default

as for first time installation of the database, gentoo provides a script for this, just read the result that shown by ebuild in the finished emerge process.

the rest of adding or removing user or databases will be handled by phpmyadmin.

configuring php

Currently php works out of the box, if any modification is needed should be logged here

starting the process

we need to call the apache2 init.d scripts

/etc/init.d/apache2 start

Next if the mysql is not started

/etc/init.d/mysql start

installing additional feature

Phpmyadmin

you can either download phpmyadmin from its source and then untar in in /home/name1/public_html/phpmyadmin or use the emerge process and then move or copy or link the folder in /var/www/localhost/htdocs to /home/name1/public_html

This is because in the duckzland.vhost above apache root directory has been changed to /home/name1/public_html

CMS

You will need to do the same thing as the phpmyadmin to install CMS such as drupal / joomla / wordpress.

— to be continued —-

-= end transmission =-

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • LinkedIn
  • Slashdot
  • StumbleUpon
  • blinkbits
  • eKudos
  • Live
  • Share/Save/Bookmark

RSS Fresh Ebuild