Install And Change Apache2 And MySQL Default Directory In Ubuntu 12.04

get the Apache2, PHP5 and MySQL

1
2
3
sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install mysql-server

to move your default directory for your site in apache2 make directory where your new site will be stored, for this example i’ll use /home/www/

1
mdkir /home/www/

then set the permission

1
chown -R www-data:www-data /home/www

edit default file in /etc/apache2/sites-available/ to be like this, change the DocumentRoot and Directory to the new directory that you want, in this case im using /home/www

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /home/www
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /home/www/>
        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 ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/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>

restart the apache2

1
sudo service apache2 restart

done!

to change MySQL default data directory to new one, here’s the step

first stop the MySQL Service

1
sudo service mysql stop

make new directory to store your new data, in this example i’ll use /home/mysql

1
sudo mkdir /home/mysql

copy your mysql data from the old one to the new one

1
sudo cp -R /var/lib/mysql/* /home/mysql/

set the permission

1
sudo chown -R mysql:mysql /home/mysql

edit my.cnf file in /etc/mysql , just edit the data location from

1
datadir = /var/lib/mysql

to

1
datadir = /home/mysql

then edit /etc/apparmor.d/usr.sbin.mysqld

1
sudo gedit /etc/apparmor.d/usr.sbin.mysqld

change

1
2
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,

to

1
2
/home/mysql/ r,
/home/mysql/** rwk,

Reload apparmor

1
sudo /etc/init.d/apparmor reload

Then start mysql

1
sudo service mysql start

Good Luck!!

Install Squid 3 on uBuntu

#apt-get install squid3

Edit your squid.conf in /etc/squid3/squid.conf

http_port xxxx transparent #change xxxx with port number
cache_mgr Spearcross
visible_hostname Spearcross.net
cache_mem 64 MB
logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %h" "%{User-Agent}>h" %Ss:%Sh
access_log /var/log/squid3/access.log squid
cache_store_log none
cache_log /var/log/squid3/cache.log

acl apache rep_header Server ^Apache

cache_dir ufs /var/spool/squid3 5000 8 256
#For cache_dir use this formula
#(((x / y) / 256) / 256) * 2 = # Directory number
#example: you allocating 2GB for cache and 20KB average object size
#(((5.000.000 / 20) / 256) / 256) * 2 = 8
#so you write cache_dir like this
#
#cache_dir 5000 8 256

maximum_object_size 4194240 KB
maximum_object_size_in_memory 512 KB
negative_ttl 2 minutes half_closed_clients off

For Anonymous Proxy :

forwarded_for off
request_header_access Allow allow all
request_header_access Authorization allow all
request_header_access WWW-Authenticate allow all
request_header_access Proxy-Authorization allow all
request_header_access Proxy-Authenticate allow all
request_header_access Cache-Control allow all
request_header_access Content-Encoding allow all
request_header_access Content-Length allow all
request_header_access Content-Type allow all
request_header_access Date allow all
request_header_access Expires allow all
request_header_access Host allow all
request_header_access If-Modified-Since allow all
request_header_access Last-Modified allow all
request_header_access Location allow all
request_header_access Pragma allow all
request_header_access Accept allow all
request_header_access Accept-Charset allow all
request_header_access Accept-Encoding allow all
request_header_access Accept-Language allow all
request_header_access Content-Language allow all
request_header_access Mime-Version allow all
request_header_access Retry-After allow all
request_header_access Title allow all
request_header_access Connection allow all
request_header_access Proxy-Connection allow all
request_header_access User-Agent allow all
request_header_access Cookie allow all
request_header_access All deny all

Restart your Squid3

/etc/init.d/squid3 restart

Installing MRTG on uBuntu

apt-get install mrtg snmpd snmp

Edit the mrtg configuration file to edit some of the settings
File is located at /etc/mrtg.cfg you need to change the global settings as follows :
 

# Global Configuration

RunAsDaemon: yes
EnableIPv6: no
WorkDir: /var/www/mrtg
Options[_]: bits,growright
WriteExpires: Yes

Title[^]: Traffic Analysis for

Edit the snmp community name in snmp configration file /etc/snmp/snmpd.conf

# sec.name source community
# com2sec paranoid default public
com2sec readonly default public
#com2sec readwrite default private

Now you need to restart the snmp service
 

#/etc/init.d/snmpd restrat

Creating the configuration file using
 

#cfgmaker public@localhost > /etc/mrtg.cfg

Creating a configuration file for a device using
 

#cfgmaker public@192.168.0.1 >> /etc/mrtg.cfg

Create index file for the webserver
 

#indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html

 

Installing Apache2, MySql, and phpMyAdmin in uBuntu

sudo apt-get install mysql-server
sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install php5-mysql
sudo apt-get install phpmyadmin

To set up under Apache all you need to do is include the following line in /etc/apache2/apache2.conf, first type the following command to open up this file:
gksudo gedit /etc/apache2/apache2.conf

Add the following line of code inside apache2.conf:
Include /etc/phpmyadmin/apache.conf

Now restart Apache:
sudo /etc/init.d/apache2 restart