31
Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Embed Size (px)

Citation preview

Page 1: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Apache, PHP, MySQL

Installation and configuration

Web Programming with PHP,TITAS PROJECTIICT,BUET

Page 2: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Operating Systems

Author:Sayeef Salahuddin

Operating Systems

Windows Linux

Installation Configuration Installation Configuration

Page 3: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Installation

The Apache web-server is by default installed in most of the modern day linux systems.

Apache web server is available in rpm format from which automatic installation will be performed

Apache web-server is also available in both source and binary distribution format.

Apache Web Server(Linux)

Page 4: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Installation

For the source distribution we follow the following steps

edit the Configuration file (AddModule ) configure (EXTRA_CFLAGS, LIBS, LDFLAGS, INCLUDES )

make copying and configuration (to be discussed)

For the binary distribution only the 4th step of the previous point is necessary.

Apache Web Server(Linux)

Page 5: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Installation

The Apache is available in .msi format The installation is quite straight forward. Apache is best suited for Windows NT and

Windows2000-when used as a service Apache is best suited when used from the

console window for Windows95/98

Apache Web Server(Windows)

Page 6: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Installation

In most of the today’s linux systems PHP is by default installed.

Lots of RPM packages are available which will automatically install PHP.

Binary and Source distributions are also available.

PHP(Linux)

Page 7: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Installation

For a source distribution a typical configure option for installing with MySQl and apache will look like

./configure --with-mysql –with-apxs=/www/bin/apxs make

make install

PHP(Linux)

Page 8: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Installation

Key things to remember edit the php.ini file for options. The php.ini file is normaly

located in /usr/local/lib/php.ini. Add the following lines to the httpd.conf or srm.conf if not

already present AddType application/x-httpd-php .php LoadModule php4_module libexec/libphp4.so

PHP(Linux)

Page 9: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Installation

There are two ways to install PHP for windows As a CGI As a module

To install as a CGI the following things should be present in the httpd.conf

ScriptAlias /php/ "c:/php/" AddType application/x-httpd-php .php .phtml Action application/x-httpd-php "/php/php.exe"

It is assumed here that the package is for this particular case is in the c:\php directory.

PHP(Windows)

Page 10: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Installation

To install as a module the following things should be taken care of php4ts.dll should be copied to windows\system directory

replacing any older file The following should be added to the httpd.conf file

LoadModule php4_module c:/php/sapi/php4apache.dll AddType application/x-httpd-php .php .phtml

It is assumed here that the package is for this particular case is in the c:\php directory.

PHP(Windows)

Page 11: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Installation

The recommended way to install MySQL on Linux is by using an RPM file

The RPM files you may want to use are: MySQL-VERSION.i386.rpm The MySQL server. MySQL-client-VERSION.i386.rpm The standard MySQL client

programs. MySQL-bench-VERSION.i386.rpm Tests and benchmarks. MySQL-devel-VERSION.i386.rpm Libraries and include files. MySQL-VERSION.src.rpm This contains the source code for all of

the above packages.

MySQL(Linux)

Page 12: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Installation

The recommended way to install MySQL on Windows is to use the precompiled binary distributions.

The installation procedure is quite straight forward. The MySQL is by default set up to run from c:\mysql If connecting to MySQL from some other programs

is necessary MyODBC driver will be required.

MySQL(Windows)

Page 13: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Configuring Apache

The Apache web server has 3 configuration files

httpd.conf srm.conf access.conf

Linux

Page 14: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Configuring Apache

httpd.confThis is used to set the general settings such as the port number

as well as to load modules. srm.conf

This file sets the root documents, rules and other general settings

access.confThis file deals with the access control of the server.

Linux

Page 15: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Configuring Apache

The parameters1.ServerType standalone Inetd

2. Port normally 80 Any free port can be used

Linux

Page 16: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Configuring Apache

The parameters

3.User & Group user nobody group nobody

Normally the httpd process is fired by the root but this does not listen for connections.

This launches one or more child processes as the user and the group indicated with these configuration directives.

Linux

Page 17: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Configuring Apache

The parameters

4.ServerRootbase directory for the configuration files--- normally

/etc/httpd

5. ServerNamethe name of the Web Server

for example www.buet.ac.bd

Linux

Page 18: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Configuring Apache

The parameters

6.ServerAdmin

this indicates the e-mail address of the administrator of the site.

Linux

Page 19: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Configuring ApacheLinux

Page 20: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Configuring ApacheLinux

Page 21: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Configuring ApacheLinux

7.DocumentRoot

this identifies the directory where the root directory is located.

8.DirectoryIndex

the index file name which will be accessed by the user.The normal entries for this is

index.html,index.htm, index.shtml,index.php

Page 22: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Configuring ApacheLinux

9.AccessFileName

This specifies the file name for the access control of the server. The typical entry is

AccessFileName .htaccess

Page 23: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Configuring ApacheLinux

10.ScriptAlias

This specifies the directory name where the scripts will be saved. A typical entry is like

ScriptAlias /cgi-bin/ /home/httpd/cgi-bin/

Page 24: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Configuring ApacheLinux

11. Alias

This specifies the directory name which can be accessed by the name specified. Atypical entry will be

Alias /icons/ etc/httpd/icons/

Page 25: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Configuring ApacheLinux

12. AddHandler and Addtype The AddHandler directive allows a file with a specific extension

to be mapped to a particular action in the server or an external action.

AddType creates a new MIME type for a specific extension.

A typical entry is

AddType text/html .shtml

AddHandler server-parsed .shtml

Page 26: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Configuring ApacheLinux

A typical home directory configuration<Directory /home/myweb>

Options Indexes FollowSymLinks MultiViews

AllowOverride None

Order allow,deny

Allow from all

</Directory>

Page 27: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Configuring ApacheLinux

Directives in brief Allowoveride Order allow Options

Page 28: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Configuring ApacheLinux

Access Control

A typical .htaccess file has the follwing entries

AuthName Students Only

AuthUserFile /home/users

AuthGroupFile /home/groups

require group students

Page 29: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Configuring ApacheLinux

AuthName this will prompt the specified value. in this case Students Only

AuthUserFile path of the user file

AuthGroupFile path of the group file

Require this is used to restrict access. In this case only students group is allowed. the syntax is require user user1,user2… or require group grou1,group2…

Page 30: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Configuring ApacheLinux

Virtual Hosting There are two types of virtual hosting The name based virtual hosting The IP based vitual hosting A typical name-based virtual hosting could be performed by

adding the following lines to httpd.confListen 9000

<VirtualHost _default_:9000>

##the host parameters and rules and directives

</virtualhost>

Page 31: Apache, PHP, MySQL Installation and configuration Web Programming with PHP,TITAS PROJECTIICT,BUET

Refences

[1] The Apache User’s Manual (www.apache.org)

[2] The MySQL User’s Maunual (ww.mysql.org)

[3] The PHP user’s Manual (www.php.net)

[4] Mastering Linux By Arman Danesh ,Cybex

[5] Linux Unleashed By David Pitts & Bill Boll,Tech Media

Authored By

-Sayeef Salahuddin

Student No: 9606039