Upload
claire-lawson
View
237
Download
0
Tags:
Embed Size (px)
Citation preview
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
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
Configuring Apache
The Apache web server has 3 configuration files
httpd.conf srm.conf access.conf
Linux
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
Configuring Apache
The parameters1.ServerType standalone Inetd
2. Port normally 80 Any free port can be used
Linux
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
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
Configuring Apache
The parameters
6.ServerAdmin
this indicates the e-mail address of the administrator of the site.
Linux
Configuring ApacheLinux
Configuring ApacheLinux
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
Configuring ApacheLinux
9.AccessFileName
This specifies the file name for the access control of the server. The typical entry is
AccessFileName .htaccess
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/
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/
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
Configuring ApacheLinux
A typical home directory configuration<Directory /home/myweb>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Configuring ApacheLinux
Directives in brief Allowoveride Order allow Options
Configuring ApacheLinux
Access Control
A typical .htaccess file has the follwing entries
AuthName Students Only
AuthUserFile /home/users
AuthGroupFile /home/groups
require group students
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…
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>
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