Friday, July 1, 2011

Using Linux, Apache, MySql, and Php For Application Deployment

Linux, Apache, MySql, and Php can all be used to produce software which runs on a web server, and thus eliminates the need for client software installations on a local computer. What this means is that the server contains both the database front end, the database back end, and the client front end all in one package. Upgrades to software based on Linux, Apache, MySql, and Php (Lamp) can be done with very petite time complex at all, since all of the primary software will only have to be installed one time, on one computer. In addition, Lamp software could very categorically be made available to individuals who are outside of a main office. These workers would plainly have to join together to a company's Vpn to run the intended software.

This tutorial will cover Lamp factory on a stand alone server, which will be able to run software designed for a Lamp environment. This tutorial will also cover basic MySql syntax, so that a server administrator can troubleshoot issues within a single application. This tutorial already assumes that a working factory of Linux is available, and that networking is already setup on the working factory of Linux. For the sake of this tutorial, all of the Lamp components will be installed from source code when needed, and from binary packages when appropriate. This tutorial should be applicable across all distributions of Linux. The first step is to successfully setup Apache.

Apache

Apache factory and Configuration

Apache can be downloaded from apache.org. In this example, Apache version 1.3.31 is used. First, create a directory on the root of your file ideas called src.

mkdir /src

Next, move the Apache software to the /src directory, and passage it.

mv apache_1.3.31.tar.gz /src
tar -xvzf apache_1.3.31.tar.gz

Once Apache is extracted to the /src/apache_1.3.31 directory (version numbering will probably differ), turn to that directory, and configure the Apache Http server.

cd apache_1.3.31
./configure --prefix=/usr/local/apache --enable-module=so
make
make install

You will by all means; of course need the Gnu C Compiler installed (Gcc), and Gnu Make (make) in order to setup Apache. This compilation of Apache will take quite some time, the configure options that were passed to Apache tell the configuration script to setup Apache to the /usr/local/apache directory, and to enable module sustain within Apache. Module sustain will later be used to load Php from. Once Apache is installed, the main configuration file should be copied to /usr/local/apache/conf/httpd.conf. You can then test the web server by issuing a start command to the Apache control script, apachectl:

/usr/local/apache/bin/apachectl start

You should now be able to view the default Apache page at the server's ip address, or domain name if applicable. Since Apache is fully up and running, MySql will be installed next.

MySql Installation

MySql can be either installed by source, or by binary packages. Since there is no need for customization to MySql, MySql can be safely installed from binary packages for this step. If you are using Red Hat Linux, the Rpms you will need to download comprise mysql-version, mysql-server-version, and mysql-client-version. You will also need to satisfy any dependencies requested by these packages. If you run Debian, you plainly will need to enter one command:

apt-get setup mysql-server

Apt-get will then fetch the required dependencies, and setup them. Once MySql is installed, you should first create a password, and a test database. This can be finished by:

mysql -u root -p
mysql> Set Password For root@localhost=Password('desired password');
mysql> create database mydb;
mysql> quit

Once you have created a test database, and assigned a password to the root user, you are ready to setup and configure Php to use MySql.

Php factory and Configuration

Php will need to be installed from source code, which may be downloaded from http://www.php.net. The most recent version as of this writing is 4.3.7. Move and passage Php to the same directory used before, /src:

mv php-4.3.7.tar.gz /src
cd /src
tar -xvzf php-4.3.7.tar.gz
cd php-4.3.7
./configure --with-mysql --with-apxs=/usr/local/apache/bin/apxs
make
make install

Once Php is installed, the configuration file for Php will need to be copied to the /usr/local/lib directory, and Php will need to be enabled within Apache. You can safely substitute the vi command below with whatever your beloved text editor is.

cp php.ini-dist /usr/local/lib/php.ini
vi /usr/local/apache/conf/httpd.conf

Create the following lines, in the respective sections of httpd.conf (the allowable locations will be under the [main] configuration, and generally don't matter where they are located, but for simplicity, you should place them in the sections which are populated by similar directives).

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
LoadModule php4_module libexec/libphp4.so

You will also want to modify the DirectoryIndex value to:

DirectoryIndex index.php index.html

Which will allow Apache to fetch the default index.php file when a directory is called which contains a file called index.php. Apache will now need to be restarted, via the apachectl script.

/usr/local/apache/bin/apachectl restart

Next, create a file under the default document directory (default is /usr/local/apache/htdocs) called index.php, and insert the following text into it.

print

Using Linux, Apache, MySql, and Php For Application Deployment

No comments:

Post a Comment