Linux Debian LAMP Server

From Nonecks Docs

Jump to: navigation, search

Install Apache2, MySQL, and phpMyAdmin

# apt-get install apache2 libapache2-mod-php5 php5-mysql mysql-server mysql-client php5 phpmyadmin

Don't forget to add the correct include config for PhpMyAdmin.

vi /etc/apache2/apache2.conf

Add the following to the bottom of /etc/apache2/apache.conf

Include /etc/phpmyadmin/apache.conf 

# apache2ctl restart

If you plan on creating or using virtual hosts, do yourself a favor and edit the default site to include NameVirtualHost

  1. Edit default site include file to allow virtual hosts
NameVirtualHost 10.10.10.2
<VirtualHost *>
    ServerAdmin it@auctiva.com
    DocumentRoot /var/www/default/
<Directory />
    Options FollowSymLinks
    AllowOverride None
 </Directory>
<Directory /var/www/default/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
 </Directory>
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
 </Directory>
    ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
    LogLevel warn
    CustomLog /var/log/apache2/access.log combined
    Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
 </Directory>
</VirtualHost>
  1. Create Apache Site config files
vi /etc/apache2/sites-available/mynewsite
<VirtualHost 10.10.10.2>
       ServerAdmin webmaster@example.com
       ServerName  www.mynewsite.com
       ServerAlias mynewsite.com

       # Indexes + Directory Root.
       DirectoryIndex index.php
       DocumentRoot /var/www/mynewsite/
       ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

       <Directory "/usr/lib/cgi-bin">
               AllowOverride None
               Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
               Order allow,deny
               Allow from all
       </Directory>

       ErrorLog  /var/www/mynewsite/logs/error.log
       CustomLog  /var/www/mynewsite/logs/access.log combined

</VirtualHost>

Before we can activate this config we need to make sure the directories exist.

mkdir -p /var/www/mynewsite/logs
touch /var/www/mynewsite/logs/error.log
touch /var/www/mynewsite/logs/access.log

Now activate/enable the site config using a2ensite

# a2ensite mynewsite
Enabling site mynewsite.
Run '/etc/init.d/apache2 reload' to activate new configuration!
# apache2ctl restart

If you need to deactivate use a2dissite

# a2dissite mynewsite
Disabling site mynewsite.
Run '/etc/init.d/apache2 reload' to activate new configuration!
# apache2ctl restart