Sunday, June 14, 2009

John Paul Tutorial (Apache in LInux)

Apache in Linux

These installation instructions assume


Commands are Unix-compatible.

The source path is /var/tmp, other paths are possible.

Installations were tested on Red Hat Linux 6.1 and 6.2.

All steps in the installation will happen in super-user account root.

Apache version number is 2.0.2

Mod_SSL version number is 2.6.4-1.3.12

Mod_Perl version number is 1.24

Mod_PHP version number is 5.0.0


Apache + PHP5

Compile and Optimize

Apache Web Server, like many applications we'll install, cannot run as super-user root. For this reason we must create a special user that has minimal access to the system, and still function enougn to run the Apache web Server. It is best to choose and create a new user just for the purpose of running the web server daemon.

[root@deep ]/# useradd -c "Apache Server" -u 80 -s /bin/false -r -d /home/httpd www 2>/dev/null || :


You have to apply mod-ssl to Apache source tree, if you want to use and include the SSL data encryption support in your Apache web server, then move into the new mod_ssl source directory cd mod_ssl-version-version/ and type the following commands on your terminal:

CC="egcs" \
CFLAGS="-O9 -funroll-loops -ffast-math -malign-double -mcpu=pentiumpro -march=pentiumpro -fomit-frame-pointer -fno-exceptions" \
./configure \
--with-apache=../apache_1.3.12 \
--with-crt=/etc/ssl/certs/server.crt \
--with-key=/etc/ssl/private/server.key

Improve the MaxClients Parameter of Apache, by default in the Apache configuration file; httpd.conf, the maximum number you can set for the MaxClients Parameter is 256. For a busy site, and for better performance, its recommended that you increase the limit of this parameter. You can do it by editing the src/include/httpd.h file in the source directory of Apache and changing the default value. Move into the new Apache source directory, cd ../apache_2.0.2/ and edit the httpd.h file:

#define HARD_SERVER_LIMIT 256

Pre-configure Apache for PHP5 configure step if you want to use and include the PHP4 server-side scripting language support on your Apache web server, then move into the new Apache source directory cd apache_1.3.12/ if you are not already in it and type the following commands on your terminal:

CC="egcs" \
OPTIM="-O9 -funroll-loops -ffast-math -malign-double -mcpu=pentiumpro -march=pentiumpro -fomit-frame-pointer -fno-exceptions" \
CFLAGS="-DDYNAMIC_MODULE_LIMIT=0" \
./configure \
--prefix=/home/httpd \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--libexecdir=/usr/lib/apache \
--includedir=/usr/include/apache \
--sysconfdir=/etc/httpd/conf \
--localstatedir=/var \
--runtimedir=/var/run \
--logfiledir=/var/log/httpd \
--datadir=/home/httpd \
--proxycachedir=/var/cache/httpd \
--mandir=/usr/man

After you configure Apache server in linux.

Try these simple script with PHP+MYSQL

$con=mysql_connect("localhost","Username", "Password");
if(!$con)
{
die('cannot connect'. mysql_error());
}
mysql_select_database("db1",$con);
mysql_query("INSERT INTO nametbl(Firstname, Lastname) VALUES('John', 'Paul')");
mysql_close($con);
php?>