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!!

WordPress Permalink With IIS 6 Using IIRF

Previously i’m using Isapi_Writer 3.0 from HeliconTech to use permalink for WordPress but sadly it not goes smoothly, i got problem with the permalink, it turn off randomly and get another 404 page, so i try another method, now i try using IIRF (can be download it here) and use this in IIRF.ini :

1
2
3
4
5
6
7
8
9
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d                                
RewriteRule ^/sitemap.xml$   - [L]

RewriteRule ^wp-(.*)$ /wp-$1 [L]
RewriteRule ^xmlrpc(.*)$ /xmlrpc$1 [L]

RewriteRule ^(index.php)*(.*)$ index.php/$2 [NC,L]

Now it’s really fixed, i hope 😀

Update : Again i got another 404 Page
so i change the RewriteRule to

1
RewriteRule ^(index.php)*(.*)$ index.php/$1 [NC,L]

WordPress Permalink With IIS 6

Update : Please see this wordpress-permalink-with-iis-6-using-iirf/ i got problem using isapi_writer 3.0 method.

Ok, After i’m moving my site to the new server that run on windows server 2003, i got problem using the WordPress Permalink. Previously i’m using Windows Server 2008 hosting and got no problem with the permalink, on Windows Server 2008 with IIS 7 and Mod_Writer plugin, i only need to put this on my web.config :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<system.webServer>
        <rewrite>
          <rules>
            <rule name="Main Rule" stopProcessing="true">
              <match url=".*" />
              <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
              </conditions>
              <action type="Rewrite" url="index.php" />
            </rule>
          </rules>
        </rewrite>
</system.webServer>

And when i move to new server, there’s no Mod_Writer for IIS 6, so alternatively i use ISAPI_Rewrite 3.0 from HeliconTech. But When i follow the instruction how to install it in permalink-for-wordpress-iis-6-mod_rewrite-fixed-free, i got 404 Page when i follow my post. So after a week finding solution, i finally see this 404-wordpress-permalinks-iis-with-isapi-rewrite and just put this on my httpd.conf

1
2
3
4
5
6
RewriteBase /
RewriteCond ${REQUEST_FILENAME} !-f
RewriteCond ${REQUEST_FILENAME} !-d
RewriteRule /wp-(.*) /wp-$1 [L]

RewriteRule ^(index.php)*(.*)$ index.php/$2 [NC,L]

and voila… my site is fixed 😀

IIS5 : php No input file specified on Virtual Directory

I got the problem when installing PHP5 with WPI and install it on IIS5 Windows XP, i can’t execute php file in my virtual directory, and got “No input file specified” when it try execute the file.

After i search it finally i got the solution for this problem, and it’s very simple, just edit this line in PHP.ini file :

1
2
3
4
5
6
; The root of the PHP pages, used only if nonempty.
; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root
; if you are running php as a CGI under any web server (other than IIS)
; see documentation for security issues. The alternate is to use the
; cgi.force_redirect configuration below
doc_root =

change it to :

1
2
3
4
5
6
;The root of the PHP pages, used only if nonempty.
; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root
; if you are running php as a CGI under any web server (other than IIS)
; see documentation for security issues.  The alternate is to use the
; cgi.force_redirect configuration below
;doc_root =

Goodluck for trying it.