Senin, 08 Maret 2010

How To Install HTTPD PHP and MySQL OpenSUSE 11.1 x86_64

In This Tutorial, We will start to install and configure Apache Webserver, PHP and Mysql from Source / tar.gz in O/S OpenSUSE 11.1 x86_64 bit O/s
If you are searching how to install apache php and mysql for linux o/s 32bit, please click HERE

So I assume you already have OpenSUSE11 installed, up and running.
This tutorial also can be implemented in other O/S such as : Centos and Fedora or other 64bit Linux O/S.

Login into your server with root access.

Download and Extract All Packages and Dependencies

$cd /root
$vi files.sh
#!/bin/bash
# download and extract all packages and dependencies

cd /root
wget http://mirror.csclub.uwaterloo.ca/mysql/Downloads/MySQL-5.1/mysql-5.1.44...
wget http://www.alliedquotes.com/mirrors/apache/httpd/httpd-2.2.14.tar.gz
wget ftp://xmlsoft.org/libxml2/libxml2-2.7.6.tar.gz
wget http://www.ijg.org/files/jpegsrc.v8a.tar.gz
wget http://curl.haxx.se/download/curl-7.20.0.tar.gz
wget http://ftp.twaren.net/Unix/NonGNU/freetype/freetype-2.3.12.tar.gz
wget http://mirror.unej.ac.id/cpan/authors/id/T/TI/TIMB/DBI-1.609.tar.gz
wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.2.43.tar.gz
wget http://openssl.org/source/openssl-0.9.7g.tar.gz
wget http://www.zlib.net/zlib-1.2.3.tar.gz
wget http://www.libgd.org/releases/gd-2.0.35.tar.gz
wget http://www.php.net/distributions/php-5.3.1.tar.gz
wget ftp://ftp.cac.washington.edu/imap/imap-2007b.tar.Z

echo "Extracting All Packages "

tar -zxvf mysql-5.1.44.tar.gz
tar -zxvf httpd-2.2.14.tar.gz
tar -zxvf libxml2-2.7.6.tar.gz
tar -zxvf jpegsrc.v8a.tar.gz
tar -zxvf curl-7.20.0.tar.gz
tar -zxvf freetype-2.3.12.tar.gz
tar -zxvf DBI-1.609.tar.gz
tar -zxvf libpng-1.2.43.tar.gz
tar -zxvf openssl-0.9.7g.tar.gz
tar -zxvf zlib-1.2.3.tar.gz
tar -zxvf gd-2.0.35.tar.gz
tar -zxvf php-5.3.1.tar.gz
tar -zxvf imap-2007b.tar.Z

Chmod and Execute files.sh

$cd /root
$chmod 755 files.sh
$./files.sh

Install C compiler and Dependencies

$yast -i gcc gcc-c++ ncurses-devel pam-devel automake

Note : you can use yum, apt-get or etc to install c compiler.

Create MySQL user and Compiling MySQL Server

Create user and group mysql with yast

$yast
>> Security and Users >> User and Group Management
>> In Users Section >> Press tab to ADD a new user
>>> Input User Full Name "mysql", Username "mysql", Password and Confirm Password >> OK
>> In Group section >> Press tab to ADD a Group
>>> Input Group Name "mysql" >> OK
>> In users Section >> Edit user "mysql"
>>> In Existing Local User Choose Details Section
>>> Login Shell Change it to "/bin/false"
>>> Default Group Change it to "mysql" >> OK >> OK
>> press f9 to quit yast

Compiling MySQL Server

$cd /root
$cd mysql-5.1.37
$./configure --prefix=/usr/local/mysql \
--localstatedir=/usr/local/mysql/var \
--with-pthread --with-big-tables
$make && make install

Change mysql dir permission

$chown -R mysql.mysql /usr/local/mysql

Copy mysql cnf files from this directory below to /etc/
and change the file to my.cnf

$cd /usr/local/mysql/share/mysql
$cp my-small.cnf /etc/my.cnf

Install mysql DB

$/usr/local/mysql/bin/mysql_install_db --user=mysql

Starting mysql server

$/usr/local/mysql/bin/mysqld_safe --user=mysql &

Create mysql root password

$/usr/local/mysql/bin/mysqladmin -u root password 'new-password'

Compiling OpenSSL 0.9.7g

$cd /root/
$cd openssl-0.9.7g
$./config -fPIC
$make depend
$make install

Add /usr/local/include into ld.so.conf

$vi /etc/ld.so.conf
## add this line below ##
/usr/local/include

Reload ld.so.conf

$ldconfig

Compiling Apache/ HTTPD Web Server

$cd /root
$cd httpd-2.2.14
$./configure --prefix=/usr/local/apache2 \
--enable-so --enable-mods-shared=most \
--enable-ssl=static --with-ssl=/usr/local/ssl
$make && make install

Compiling Zlib, FreeType, GD, LibXML2,LIBJPEG, LIBPNG, CURL, DBI

$cd /root
$cd zlib-1.2.3
$./configure --shared && make && make install

$cd ..
$cd freetype-2.3.12
$./configure && make && make install

$cd ..
$cd jpeg-8a
$./configure --prefix=/usr/local --enable-shared
$make && make install

$cd ..
$cd libpng-1.2.43
$./configure && make && make install

$cd ..
$cd curl-7.20.0
$/configure && make && make install

$cd ..
$cd libxml2-2.7.6
$./configure && make && make install

$cd ..
$cd gd-2.0.35
$./configure --with-freetype=/usr/local \
--with-jpeg=/usr/local/lib \
--with-png=/usr/local/lib
$aclocal
$make && make install

$cd ..
$cd DBI-1.609
$perl Makefile.PL
$make && make install

$cd /root
$mv imap-2007b /usr/local/
$cd /usr/local/imap-2007b
$make lnp EXTRACFLAGS="-fPIC"
$mkdir include lib
$cp src/c-client/*.h include/
$cp c-client/c-client.a lib/libc-client.a
$cp c-client/osdep.h include/
$cp c-client/env_unix.h include/
$cp c-client/linkage.h include/

Compiling PHP

$cd /root
$cd php-5.3.1
$ ./configure --with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-gd=/usr/local \
--with-jpeg-dir=/usr/local/lib \
--with-zlib-dir=/usr/local \
--enable-ftp \
--with-png-dir=/usr/local/lib \
--with-freetype-dir=/usr/local \
--with-curl=/usr/local \
--with-imap=/usr/local/imap-2007b \
--with-imap-ssl=/usr/local/ssl \
--enable-mbstring
$make && make install

Copy php.ini

$cp php.ini-production /usr/local/lib/php.ini

Configure httpd.conf to support PHP

$cd /usr/local/apache2/conf/
$pico httpd.conf

### make sure this line below is already there
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php

Starting Up Apache and MySQL Webserver

$/usr/local/mysql/bin/mysqld_safe --user=mysql &
$/usr/local/apache2/bin/apachectl start

Added Apache and MySQL in Boot.local Init Script

$vi /etc/init.d/boot.local
### Add this line below into boot.local ###
/usr/local/apache2/bin/apachectl start
/usr/local/mysql/bin/mysqld_safe --user=mysql &

Create a test.php with phpinfo in file

$cd /usr/local/apache2/htdocs
$pico test.php


## save this file

$vim /usr/local/lib/php.ini (edit short_open_tag menjadi on)



Or We also can check php result from console

$php -v
PHP 5.3.1 (cli) (built: Mar 3 2010 10:07:54)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies

Open a test.php from your Browser

You can try to access test.php from your browser
Example your server ip address is 10.10.10.10

Http://10.10.10.10/test.php

Setup Suse 10.2 Server/DNS

Setup Suse 10.2 Server/DNS
Setting up bind


server:~ # smart install bind

This should install 2 packages, bind and bind-chrootenv.

Now edit /etc/named.conf and change the following settings:

options {
listen-on port 53 { 192.168.0.2; 127.0.0.1; }
listen-on-v6 { none; }
allow-query { any; }
};
include "/etc/named.d/logging.conf";
include "/etc/named.d/example.org.conf";

Now a bit of security for our DNS:

server:~ # dnssec-keygen > /etc/rndc.conf

Copy the outcommented part of `/etc/rndc.conf` into `/etc/named.conf`

Now create `/etc/named.d/example.org.conf` with the following content:

zone "example.org" {
type master;
file "personal/example.org.db";
allow-transfer { none; }:
};
zone "0.168.192.in-addr.arpa" IN {
type master;
file "reverse/192.168.0.0";
allow-query { any; };
allow-transfer { none; };
};

and `/etc/named.d/logging.conf`:

logging {

channel default_file { file "/var/log/named/default.log" versions 3 size 5m; severity dynamic; print-time yes; };
channel general_file { file "/var/log/named/general.log" versions 3 size 5m; severity dynamic; print-time yes; };
channel database_file { file "/var/log/named/database.log" versions 3 size 5m; severity dynamic; print-time yes; };
channel security_file { file "/var/log/named/security.log" versions 3 size 5m; severity dynamic; print-time yes; };
channel config_file { file "/var/log/named/config.log" versions 3 size 5m; severity dynamic; print-time yes; };
channel resolver_file { file "/var/log/named/resolver.log" versions 3 size 5m; severity dynamic; print-time yes; };
channel xfer-in_file { file "/var/log/named/xfer-in.log" versions 3 size 5m; severity dynamic; print-time yes; };
channel xfer-out_file { file "/var/log/named/xfer-out.log" versions 3 size 5m; severity dynamic; print-time yes; };
channel notify_file { file "/var/log/named/notify.log" versions 3 size 5m; severity dynamic; print-time yes; };
channel client_file { file "/var/log/named/client.log" versions 3 size 5m; severity dynamic; print-time yes; };
channel unmatched_file { file "/var/log/named/unmatched.log" versions 3 size 5m; severity dynamic; print-time yes; };
channel queries_file { file "/var/log/named/queries.log" versions 3 size 5m; severity dynamic; print-time yes; };
channel network_file { file "/var/log/named/network.log" versions 3 size 5m; severity dynamic; print-time yes; };
channel update_file { file "/var/log/named/update.log" versions 3 size 5m; severity dynamic; print-time yes; };
channel dispatch_file { file "/var/log/named/dispatch.log" versions 3 size 5m; severity dynamic; print-time yes; };
channel dnssec_file { file "/var/log/named/dnssec.log" versions 3 size 5m; severity dynamic; print-time yes; };
channel lame-servers_file { file "/var/log/named/lame-servers.log" versions 3 size 5m; severity dynamic; print-time yes; };

category default { default_file; };
category general { general_file; };
category database { database_file; };
category security { security_file; };
category config { config_file; };
category resolver { resolver_file; };
category xfer-in { xfer-in_file; };
category xfer-out { xfer-out_file; };
category notify { notify_file; };
category client { client_file; };
category unmatched { unmatched_file; };
category queries { queries_file; };
category network { network_file; };
category update { update_file; };
category dispatch { dispatch_file; };
category dnssec { dnssec_file; };
category lame-servers { lame-servers_file; };

};

PS: Thanks to the Gentoo Wiki for this :)

But logging will not work yet, we have to create the files and folders:

server:~ # mkdir /var/lib/named/var/log/named/
server:~ # touch /var/lib/named/var/log/named/client.log
server:~ # touch /var/lib/named/var/log/named/config.log
server:~ # touch /var/lib/named/var/log/named/database.log
server:~ # touch /var/lib/named/var/log/named/default.log
server:~ # touch /var/lib/named/var/log/named/dispatch.log
server:~ # touch /var/lib/named/var/log/named/dnssec.log
server:~ # touch /var/lib/named/var/log/named/general.log
server:~ # touch /var/lib/named/var/log/named/lame-servers.log
server:~ # touch /var/lib/named/var/log/named/network.log
server:~ # touch /var/lib/named/var/log/named/notify.log
server:~ # touch /var/lib/named/var/log/named/queries.log
server:~ # touch /var/lib/named/var/log/named/resolver.log
server:~ # touch /var/lib/named/var/log/named/security.log
server:~ # touch /var/lib/named/var/log/named/unmatched.log
server:~ # touch /var/lib/named/var/log/named/update.log
server:~ # touch /var/lib/named/var/log/named/xfer-in.log
server:~ # touch /var/lib/named/var/log/named/xfer-out.log
server:~ # chown -R named:named /var/lib/named/var/log/named/

Next start bind with `rcnamed start`. If any errors come up, you most probably forgot an `;` somewhere.

But... nobody knows, what adresses we have yet?

Now edit `/var/lib/named/personal/example.org.db`

$TTL 86400

@ IN SOA ns.example.org. your.email.example.org. (
2007020901 ; Serial
10800 ; Refresh
3600 ; Retry
604800 ; Expire
86400 ) ; Minimum
example.org. IN NS ns.example.org.
ns.example.org. IN A 192.168.0.2
example.org. IN A 192.168.0.2
mail.example.org. IN A 192.168.0.2
example.org. IN MX 10 mail.example.org.

and `/var/lib/named/reverse/192.168.0.0`:

$TTL 86400

@ IN SOA example.org. (
2007020901 ; Serial
10800 ; Refresh
3600 ; Retry
604800 ; Expire
86400 ) ; Minimum

IN NS example.org.
2 IN PTR example.org.
2 IN PTR server.example.org.

If you change and restart the name server, do not forget to increase the serial by 1!

Now we will test, if it actually works:

server:~ # rcnamed start
server:~ # nslookup example.org
Server: 192.168.0.2
Address: 192.168.0.2#53

Name: example.org
Address: 192.168.0.2

server:~ # host example.org
example.org has address 192.168.0.2
example.org mail is handled by 10 mail.example.org