# Compile and configure Mysql First Download MySql from the following link. Here we use Mysql 4.1.22. Stable version.
Link: - http://linux.softpedia.com/get/Database/Database-Servers/MySQL-2323.shtmlAfter downloading it copy it to /usr/local/src/. You may copy it to any convinent location you want. I have copied it here.
First, we create the group and user that "owns" MySQL. For security purposes, we don't want MySQL running as root on the system. To be able to easily identify MySQL processes in top or a ps list, we'll make a user and group named mysql:groupadd mysql
useradd -g mysql -c "MySQL Server" mysql
If you get any messages about the group or user already existing, that's fine. The goal is just to make sure we have them on the system.
What the useradd command is doing is creating a user mysql in the group mysql with the "name" of MySQL Server. This way when it's showed in various user and process watching apps, you'll be able to tell what it is right away.Now follow the below steps to compile Mysql.
1) Go to the source directory. - cd /usr/local/src/mysql-4.1.22
2) chown -R root.root *`
To change the ownership of all files to root.
3) make clean
This will delete the old .config and Makefile,which will delete old config templete.4) ./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data \
--disable-maintainer-mode --with-mysqld-user=mysql --with-unix-socket-path=/tmp/mysql.sock \
--without-comment --without-debug --without-bench
Wait untill this is successfully completed.Then proceed further.5) make && make install
we are giving both make and make install command at a time.The make install will be done only make is done successfully.
6) make test
This is an additional process and takes some time to complete.Once this is done the installation process it completed,#Configuring MySQLMySQL is "installed" but we have a few more steps until it's actually "done" and ready to start. First run the script which actually sets up MySQL's internal database (named mysql). 1) ./scripts/mysql_install_db
Then we want to set the proper ownership for the MySQL directories and data files, so that only MySQL (and root) can do anything with them.2) chown -R root:mysql /usr/local/mysql
3) chown -R mysql:mysql /usr/local/mysql/data
Copy the default configuration file for the expected size of the database (small, medium, large, huge)cp support-files/my-medium.cnf /etc/my.cnf
chown root:sys /etc/my.cnf
chmod 644 /etc/my.cnf
If you get an error message about the data directory not existing, etc., something went wrong in the mysql_install_db step above. Go back and review that; make sure you didn't get some sort of error message when you ran it, etc.Now we have to tell the system where to find some of the dynamic libraries that MySQL will need to run. We use dynamic libraries instead of static to keep the memory usage of the MySQL program itself to a minimum.
echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
ldconfig
Now create a startup script, which enables MySQL auto-start each time your server is rebooted.cp ./support-files/mysql.server /etc/rc.d/init.d/mysql
chmod +x /etc/rc.d/init.d/mysql
chkconfig --add mysql
/sbin/chkconfig --level 3 mysql on
Then set up symlinks for all the MySQL binaries, so they can be run from anyplace without having to include/specify long paths, etc.cd /usr/local/mysql/bin
for file in *; do ln -s /usr/local/mysql/bin/$file /usr/bin/$file; done
Now every thing is done.just start your mysql. /etc/init.d/mysql start
Then connect to DB with below command bash:# mysql
mysql> show databases;
This should show below output.mysql> show databases;
+---------------+
| Database |
+---------------+
| mysql |
| test |
+---------------+
2 rows in set (0.01 sec)
Try creating some test DB.mysql> create database foo;
Mysql is now installed and configured on the server. Now let's move to Apache and PHP conpilation.
#Compiling Apache
Download/unpack Apache2 source from the Apache httpd server website, http://httpd.apache.org/
Go to Apache source directory for me it is /usr/local/src/httpd-2.0.40
1) make clean ( to delete old templet .config file and makefile)
./configure --prefix=/usr/local/apache --enable-so --enable-cgi --enable-info --enable-rewrite \
--enable-spelling --enable-usertrack --enable-deflate --enable-ssl --enable-mime-magic
Make Apache from the just-created Makefile: make
If make is successful, install Apache as root: make install
Now Apache installed on your server.Test it by starting it to verify if everything has gone correct./usr/loca/apache/bin/apachectl -k start
check the processes of Apache. ps -ef| grep httpd
Now We have MySQL and Apache installed and configured on your server. Now we just have to compile PHP and with Apache.
#Compiling PHP with Apache and Mysql : -
Download/unpack PHP source from the PHP website, http://www.php.net/
Pick the latest from the 4.x series or 5.x series.
The compilation procedure is the same as above. Go to the PHP directory, here it is /usr/local/src/php-versionmake clean
./configure --with-apxs2=/usr/local/apache/bin/apxs --with-mysql --prefix=/usr/local/apache/php \
--enable-force-cgi-redirect --disable-cgi --with-zlib --with-gettext --with-gdbm
You only need the --with-apxs2, and prefix lines. --with-mysql adds MySql (you need to specify the directory if it's in a unusual location (e.g., --with-mysql=/usr/local ), --with-config-file moves the php.ini file location, disable-cgi disables the CGI version, which is not needed if you use Apache modules. It also enables and installs the command line interface (CLI) version. --with-zlib allows use of gzip-type compression, --with-gettext is for internationalization, and --with-gdbm allows access to GDBM databases. For more information, type ./configure --help and see the "Installation" chapter in the PHP Manual, http://ww.php.net/docs.php Make PHP from the just-created Makefile: make
If make is successful, type this as root to install PHP: make install
If you are not root (I do not perform makes while root, for security and safety reasons), become root and type the following: make install-su
If file /usr/local/apache/modules/libphp5.so does not exist or is an older version, type this (change this to libphp4.so for PHP 4): cp -p .libs/libphp5.so /usr/local/apache/modules
Install the php.ini file: cp -p php.ini-recommended /usr/local/apache/php/php.ini
Add these directives are in /usr/local/apache/conf/httpd.conf (if already there, verify they are correct): # Make sure there's only **1** line for each of these 2 directives:
# Use for PHP 4.x:
#LoadModule php4_module modules/libphp4.so
#AddHandler php-script php
# Use for PHP 5.x:
LoadModule php5_module modules/libphp5.so
AddHandler php5-script php
# Add index.php to your DirectoryIndex line:
DirectoryIndex index.html index.php
AddType text/html php
# PHP Syntax Coloring
# (optional but useful for reading PHP source for debugging):
AddType application/x-httpd-php-source phps
You're now ready to try it out. Start Apache (httpd) as root: /usr/local/apache/bin/apachectl start
Perform these sanity checks to verify your install went OK: $ /usr/local/apache/bin/httpd -t
Syntax OK
$ /usr/local/apache/bin/httpd -v
Server version: Apache/2.2.2
Server built: May 29 2006 12:40:55
$ /usr/local/apache/bin/httpd -V
Server version: Apache/2.2.2
Server built: May 29 2006 12:40:55
Server's Module Magic Number: 20051115:2
Server loaded: APR 1.2.7, APR-Util 1.2.7
Compiled using: APR 1.2.7, APR-Util 1.2.7
Architecture: 32-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/usr/local/apache"
-D SUEXEC_BIN="/usr/local/apache/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_
status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
$ /usr/local/apache/bin/httpd -S
VirtualHost configuration:
. . .
$ /usr/local/apache/bin/httpd -l
Compiled in modules:
core.c
. . .
mod_so.c
$ /usr/local/apache/bin/httpd -M
Loaded Modules:
. . .
php5_module (shared)
Syntax OK
(the above works for Apache 2.2.x and higher only)
$ ps -ef |grep httpd
root 24069 1 0 09:17 ? 00:00:08 /usr/local/apache/bin/httpd -k s
apache 29917 24069 0 15:30 ? 00:00:00 /usr/local/apache/bin/httpd -k s
. .
Access your webserver with telnet. Type HEAD / HTTP/1.0 followed by a blank line: $ telnet localhost 80
Trying 127.0.0.1...
Connected to localhost (127.0.0.1).
Escape character is '^]'.
HEAD / HTTP/1.0
HTTP/1.1 200 OK
Date: Mon, 29 May 2006 23:28:18 GMT
Server: Apache/2.2.2 (Unix) mod_ssl/2.2.2 OpenSSL/0.9.7a PHP/5.1.4
X-Powered-By: PHP/5.1.4
Last-Modified: Wed, 15 Mar 2006 06:53:17 GMT
Vary: Accept-Encoding
Connection: close
Content-Type: text/html; charset=ISO-8859-1
Content-Language: en
Access your webserver with your favorite browser. The following is a good test page to use for PHP. You only need the one line in bold is needed to display PHP configuration information. Name the file anything you want, but it must end with .php, such as phpinfo.php, and move the file to your web server content directory (for me /usr/local/apache/htdocs), with read permission set: <html>
<head>
<title>PHP Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<h1>PHP Test</h1>
<p>
<b>An Example of PHP in Action</b><br />
<?php echo "The Current Date and Time is: <br>";
echo date("g:i A l, F j Y.");?>
</p>
<h2>PHP Information</h2>
<p>
<?php phpinfo(); ?>
</p>
</body>
</html>