GETTING STARTED WITH PHP

  PHP P

  1 Interactive Web Sites

INTRODUCTION TO PHP

  Interactive Web sites contain Web pages that exchange information between the Web site and the user. Using PHP allows Web developers to easily create Web pages that process information from a user and then generate content depending on the information submitted by the user. Interactive Web sites allow Web developers to tailor the content of Web pages to better appeal to the user.

  Web Servers

  Because PHP code is processed by a Web server, a user cannot access the code used to create a PHP page. This makes it safer to work with sensitive data, such as login names and passwords. If a user views the source code of a Web page created using PHP within a Web browser, all the user will see is the HTML code that was generated by the Web server to create the page, not the PHP code itself.

  Increased Security

  Although PHP is not a true object-oriented language, PHP does support object-oriented programming concepts that allow Web developers to write code in an object-oriented fashion. Object-oriented programming is a type of programming that treats packages of code as distinct modules, or objects. Using objects can make a large Web application easier to manage, especially if there are multiple developers working on the same application.

  Object-Oriented

  A Web server processes all the PHP code in a Web page and translates the code into simple HTML code. This means that Web developers do not have to take into consideration the types of Web browsers used by clients. Any browser that can view Web pages can view pages containing PHP code processed by a Web server.

  Server-Side Processing

  You do not require any special development tools to create and view PHP pages. All you need is a text editor and a Web browser. Although there are some programming tools available that make creating PHP pages easier, these tools are typically used only by Webmasters who generate large amounts of PHP code on a continuous basis.

  Development Tools

  You do not require a dedicated Web server to publish the Web pages you create using PHP. You can simply install Web server software on your own computer. A popular example of Web server software that includes support for PHP is Apache. Microsoft's Web server products, Internet Information Server (IIS) and Personal Web Server (PWS), can also be used to store and serve PHP pages. If you cannot install Web server software on your computer, you can transfer your PHP pages to a Web hosting service on the Internet.

  PHP can be installed on computers using different Windows and Unix operating systems. While some specialized functions work only on specific platforms, the vast majority of PHP code will work equally as well on either platform. Many PHP developers write their code on Windows-based computers and then use the code on Web servers that run a Unix operating system.

  Database Manipulation

  HP is a popular scripting language used to create powerful and dynamic Web sites. PHP is currently in use on over five million Web sites around the world. PHP is open source software, which means it is available free of charge. There are also no costs or restrictions related to distributing the PHP scripts you create, whether the scripts are for development or commercial use.

  Dynamic Web sites contain Web pages that display constantly changing content. Using PHP, you can determine the content a Web page displays, depending on many different factors. For example, you can have a page automatically present different content to users depending on the current date or the user's location. Dynamic Web pages are more useful to each individual user than static Web pages.

  Dynamic Web Sites

  HyperText Markup Language (HTML) is the markup language used to create Web pages. PHP can be used to dynamically generate the HTML code for a Web page. PHP code can also be embedded into the HTML code for a Web page. PHP is embedded into HTML code with the use of special tags, called delimiters. Using the delimiters, you can add as many sections of PHP code to an HTML document as you need. Embedding PHP code in HTML code makes it possible to enhance existing Web pages on a Web site.

  HTML

  PHP is constantly evolving and a new version of the language is released every few years. Each new version of PHP offers more features than previous versions but is still compatible with the previous versions. This means that scripts you write using the current version of PHP will be compatible with future versions. PHP 4 is the current version of PHP and is used in the examples throughout this book.

  Versions

  PHP can also allow users to manipulate the data in a database. For example, a PHP page can be used to add, delete or edit records in a database depending on a user's request.

  One of the most important features of PHP is the ability to work with a number of different databases, including MySQL, Oracle and Sybase. PHP pages can be used to access a database and then make the information stored in the database available to users who visit the Web site. Using databases to store information and PHP code to access the information is an efficient method of displaying up-to-date information in a Web site.

  Cross Platform

INSTALL APACHE WEB SERVER ON WINDOWS

  On the Windows platform, Apache is installed using a standard Windows installation program. The Apache files must be installed in a folder on the computer. The default installation location is C:\Program Files\Apache Group\Apache. You can specify another destination folder, but it is recommended that you accept the default folder.

  An information dialog box may appear, providing information about this version of the Web server software. Click Next to continue.

  B

  efore you can publish PHP pages, you must install a Web server that can interpret and process PHP code. Apache Web server is an extremely reliable and robust

  Web server that can be used for serving a small intranet or a large commercial Web site. Since Apache is the most popular Web server used on the Internet, PHP has been developed to work well with Apache to make PHP pages available on the Web. A recent release of Apache Web server is included on the CD-ROM disc that accompanies this book, but you should make sure you install the latest release of the server. The latest version of Apache is available at the www.apache.org Web site.

  Before you can install Apache, you must install the TCP/IP protocol on your computer. For information about installing network protocols, refer to your operating system documentation.

  Apache Web server is relatively easy to install and maintain. Although the Windows version of Apache was designed primarily for use on computers running the Windows NT or Windows 2000 operating system, it can also be used on computers using Windows 95, 98, Me or XP.

  Apache includes several parts, such as documentation, modules that increase Web server efficiency and the source code of the application program itself. You may not need to install all the available components in order to use Apache. The setup program allows you to choose the type of installation you want to perform.

  Click Yes to accept the agreement and continue.

  1 When installing Apache Web server, you can choose

  one of three installation options. The Typical option installs the most commonly used files and is the recommended option. The Compact option installs only the files required to run Apache. This option is useful when installing Apache on a computer with limited hard drive space available. The Custom option allows advanced Web site developers to choose the Apache Web server files they want to install.

  If you are installing a more recent version of Apache Web server than the one included on the CD-ROM disc that accompanies this book, you should carefully read the Web server documentation, especially the areas that relate to PHP. Later versions of Apache may work differently with PHP than the version used in this book.

  Unlike commercial programs, which often include a support department to handle any problems with the application, there is no official support included with the Apache program, so you must troubleshoot any problems yourself. There are, however, many Web sites, user groups, newsgroups and books available that can be a source of information for Apache users. The Apache FAQ located at http://httpd.apache.org/docs/misc/FAQ.html is a good starting point when looking for help information.

INSTALL APACHE WEB SERVER ON WINDOWS

  CONTINUED Á Click Next to continue.

  ■

  C:\Program Files\Apache Group\Apache ■

  This area displays the folder where Apache Web server files will be installed.

  PHP

  ■

  You can click Browse to specify a different folder in which to install the files.

  › Click Next to continue.

  ˇ

  Click the type of installation you want to perform.

  Note: If you choose Custom, the following steps will be different for your installation.

  ⁄

  This area displays the license agreement you must read and accept before continuing.

  Double-click the icon for the Apache Web server installation program to start installing the program.

  ■

  A welcome dialog box appears.

  ■

  This area displays information about the Apache Web server program.

  ¤ Click Next to continue.

  ■

  ‹

INSTALL APACHE WEB SERVER ON WINDOWS

  can use the same method to stop Apache, except type apache -k shutdown at the prompt.

  Once Apache Web server is installed, you should install the Web server as a service. A service is a term used on Windows computers to describe a program that is automatically executed and managed by the operating system. When you install Apache as a service, the program will start automatically and run in the background each time the computer is started. Once the Web server has been installed as a service, you should restart the computer.

  To confirm that Apache Web server has been installed and started properly, you can have the server display a page in a Web browser. After starting the Web browser you want to use, you enter the name or IP number of your computer as the URL in the Web browser. The IP number indicates the computer that is running the Web server software. If you do not know the IP number of your computer, you can use 127.0.0.1, which is the IP number that computers running TCP/IP use to refer to themselves. If the Apache installation was successful, a default Web page will be displayed.

  1 After installing Apache Web server as a service,

  you can stop or restart Apache manually using Start menu commands. To stop or restart Apache on most Windows systems, click Start, select Programs and choose Apache Web Server. Then click Apache as a service and select Stop Service or Restart Service.

  You can also start and stop Apache Web server from within a command prompt window. In the command prompt window, change to the directory that contains the Apache program files, usually C:\Program Files\Apache Group\Apache, and type

  apache at the prompt to start the Web server. You

  If you are removing Apache Web server from your computer, you may want to first uninstall Apache as a service to ensure that the program is removed correctly. To uninstall Apache as a service, click Start, select Programs and choose Apache Web Server. Then click Apache as a service and select Uninstall service.

  hen installing Apache Web server on a computer running a Windows operating system, a folder containing shortcut commands for Apache Web server is added to the Programs folder on the Start menu. This folder allows you to quickly access commands that let you work with Apache from the Start menu.

  The Apache Web server program is written by a group of dedicated and talented volunteers who do not receive any payment for their work with Apache. Apache Web server is completely free to download, install and use. Unlike many free programs that require a fee to be paid if the software is used for business purposes, there are no restrictions on the use of Apache.

INSTALL APACHE WEB SERVER ON WINDOWS (CONTINUED)

  ‹ Type the IP number of

  your computer or 127.0.0.1 and then press Enter.

  ■

  The Web browser displays a Web page generated by Apache Web server.

  The installation program allows you to choose whether you want to view a README file that contains information about the release of Apache you installed. If you choose to display the file, it will open when the installation is complete. You should carefully review the README file for any new release of Apache you install.

  My Documents My Computer Online Services Outlook Express Programs Apache Web Server Apache as a service Install service Jack Smith... Accessories Apache Games Online Services StartUp

  INSTALL APACHE AS A SERVICE ⁄ Click Start.

  highlight the current Web page address and then

  ¤ Click Programs. ‹ Click Apache Web Server. › Click Apache as a service.

  ˇ Click Install service. Á Restart the computer.

  Apache Web server will start automatically each time the computer is started.

  ⁄ Start the Web browser

  you want to use to test Apache Web server.

  ¤ Click this area to

  PHP

  · Click Finish to close the dialog box.

  ■

  This area displays the folder where program icons for Apache will be installed.

  ‡ Click Next to install Apache on your computer.

TEST APACHE

  ■

  A dialog box appears, indicating that the installation is complete.

  ° If you do not want to

  display the README file after the dialog box closes, click the box beside this option ( changes to ).

  W

  1 GETTING STARTED WITH PHP PHP

INSTALL APACHE WEB SERVER ON UNIX

  pache Web server was originally developed and The configure command allows you to set up some To confirm that Apache has been installed and started On some Unix systems, such as Red Hat configured to run optimally on computers using Apache installation settings to suit your needs. You may properly, you can have the server display a page in a Linux, you can use the Red Hat Package the UNIX operating system, which makes Apache need to precede the configure command with ./ to Web browser. The Lynx Web browser is a text-based Manager (RPM) to install Apache Web server.

  A an ideal server to use to interpret and process PHP code indicate the location of the command on the computer.

  browser available on most Unix computers. To display RPM is an easy-to-use application that allows on a Unix computer. To specify a directory where you want Apache program a test page generated by Apache, type lynx http:// you to quickly install, update and remove files to be installed, you use the --prefix parameter followed by the IP number or name of your computer applications from your computer. More

  A recent release of Apache is available on the CD-ROM with the configure command, specifying the name at the prompt. You can also use 127.0.0.1, which is information about RPM is available at the disc that accompanies this book, but you can check the and location of the directory as the value of the --prefix the IP number computers using TCP/IP commonly www.rpm.org Web site. www.apache.org Web site for the latest release of the parameter. use to refer to themselves. server. The steps for installing Apache will depend on the UNIX operating system and the version of Apache After you run the configure command, you must execute

  The tar command can be used to combine you are using. You should carefully read the installation the make command to prepare Apache Web server for multiple files into a single, more manageable

  You can restart or stop Apache using the same instructions included with the software. installation. You then use the make install command file. The letters xvf indicate settings you can method you use to start the server. To restart to install the Apache files on the computer. specify for the tar command. To display

  The Apache program files are usually stored in a compressed Apache, type /user/local/apache/bin/apachectl restart information about the settings you can use file with the .Z extension. To access the Apache files, Once the Apache software has been installed, you can at the prompt. To stop Apache, type with the tar command, type man tar at the you must first uncompress the compressed file using the use the start command to start the Web server.

  /usr/local/apache/bin/apachectl stop .

  prompt. When you finish reviewing the gunzip command. The files are then archived into a single settings, press q to quit. file with the .tar extension. You must extract the files from the archive using the tar xvf command. The extracted files are automatically saved in a new directory, which you can access using the cd command.

INSTALL APACHE WEB SERVER ON UNIX

  ⁄ ¤ ‹ ›

  At the command To retrieve the unzipped To work in the directory To specify a directory where Á To install the Apache This message appears START APACHE

  ■

  prompt, type gunzip files from the archive, type that contains the Apache you want to install the Apache files on the computer, type when Apache has been

  ‡

  To start Apache, type followed by the name tar xvf followed by the name files, type cd followed by files, type ./configure – –prefix= . make install and then press successfully installed. the name and location of the of the file you want to of the tar file that contains the the name of the directory. Then type the name and Enter. directory you specified in unzip. Then press Enter. Apache files. Then press Enter. Then press Enter. location of the directory and the --prefix parameter in press Enter. step 4, immediately followed

  Note: A directory with the same name

  by /bin/apachectl start . Then

  ˇ

  To prepare Apache for

  as the tar file is automatically created press Enter.

  installation, type make and

  to store the files retrieved from the

  1 GETTING STARTED WITH PHP PHP CONFIGURE APACHE WEB SERVER TO WORK WITH PHP

  The name and location of the Apache configuration To set up PHP as an Apache module, you should hen you configure Apache Web server to work To ensure that Apache Web server processes PHP files file depends on the operating system the computer first move the php4ts.dll file, which is located in with PHP, you can set up PHP as a CGI binary correctly, you use the AddType directive to specify the uses. The name of the configuration file is usually the main PHP directory, to your system directory. or as an Apache module. Setting up PHP as an Multimedia Internet Mail Extensions (MIME) type used httpd.conf. On Windows operating systems, the file The name of the system directory depends on your

  W

  Apache module allows you to access additional capabilities for PHP files. MIME types are a set of accepted file types is typically located in the conf subdirectory of the operating system. On computers running Windows of the PHP program, but for most installations it is sufficient typically used by Internet applications. PHP files use main Apache program directory. On Unix-based NT or 2000, you can move the file to the WINNT to set up PHP as a CGI binary. To set up PHP as a CGI application/x-httpd-php as the MIME type. When using computers, the file is usually found in the /etc directory. To indicate that you want to use PHP binary, you need to specify certain settings, or directives, the AddType directive, you also indicate the file extensions directory. as an Apache module, you must then add the in the Apache configuration file. you want to associate with PHP. PHP files commonly use following code to the Apache configuration file: the .php extension, but may also use other extensions,

  When you specify a file path in the Apache LoadModule php4_module c:/php/sapi/php4apache.dll Initially, Apache Web server cannot access PHP program such as .phtml and .php3.

  AddType application/x-httpd-php .php .phtml

  configuration file, you should use slashes (/) instead files because the files are stored in a location outside the of backslashes (\) in the path name. For example, server's directory structure. The ScriptAlias directive The Action directive allows you to specify that Apache the filename c:\php\php.exe should be typed as allows you to create a virtual path Apache can use to access should pass PHP files to the PHP program for processing c:/php/php.exe. the directory that stores PHP program files. For example, before displaying the files in a Web browser. When using on Windows computers, you can create the virtual path the Action directive, you specify the MIME type of the /php/ to allow you to access files in the C:\PHP directory. files you want to pass to PHP as well as the name and location of the program that will process the files.

  CONFIGURE APACHE WEB SERVER TO WORK WITH PHP Save ⁄ ‹ ˇ ‡ ° ‚ —

  Open the Apache Type the virtual path To specify which file Type the extensions To specify that Apache should Type the name and Save the Apache You can now use

  ■

  configuration file in a text you want to use. extensions Apache should you want to use for pass files to the PHP program location of the PHP configuration file. Apache Web server editor. process as PHP files, type PHP files. before displaying the files in a program file that will to process and display

  ›

  Type the actual location AddType .

  Web browser, type Action . process the files, enclosed PHP pages you create.

  ¤

  To create a virtual path of the PHP files, enclosed in quotation marks.

  Á ·

  that will allow Apache to in quotation marks. Type application/x-httpd-php Type application/x-httpd-php access PHP program files, to specify the MIME type used to specify the MIME type of the type ScriptAlias . for PHP files. files you want to pass to PHP.

  1 GETTING STARTED WITH PHP PHP

  Before installing IIS, you should log on to the After IIS is installed, the Internet

INSTALL INTERNET INFORMATION SERVER

  computer using the administrator account, Information Services window provides since a user account may not have permission tools that allow you to administer your icrosoft Internet Information Server (IIS) 5.0 Internet Information Services Snap-In, which provides an to install all the components that IIS requires. Web sites. Display the Control Panel and is Web server software that allows you to interface you can use to administer your Web sites; and Logging on to the computer as administrator double-click Administrative Tools. In the host multiple Web sites on the Internet or World Wide Web Server, which allows users to access

  M

  will ensure that you have all the necessary Administrative Tools window, double-click on a network, such as a corporate intranet. your Web sites. permissions to install IIS. Internet Services Manager to display the

  IIS 5.0 is designed for use with the Windows 2000

  IIS may affect the performance of an existing or new service Internet Information Services window. operating system and is available on the Windows 2000 pack you install on the computer. If you need to install a Professional CD-ROM disc. IIS 5.0 offers many advanced service pack, you should check the support.microsoft.com

  The Internet Information Services component features that allow you to effectively host and manage Web site to determine whether the service pack should be includes several optional parts you can install. You can remove IIS from a computer. even the busiest Web sites. Although IIS 5.0 is powerful installed before or after IIS is installed.

  Documentation provides help files regarding Perform steps 2 to 9 below, except select server software, it can still be used to learn about Web the use of IIS and should be installed. File each part of the Internet Information

  After IIS has been installed, you may have to restart the servers and PHP. IIS 5.0 can be used to perform all the Transfer Protocol (FTP) Server allows IIS to host Services component you want to remove computer. IIS starts automatically each time the computer examples in this book.

  FTP sites. Personal Web Manager provides a in step 6 ( changes to ). Removing is started. graphical interface you can use to administer

  IIS from a computer does not remove the To install IIS on a computer, you must add parts of the PHP can be installed either before or after installing IIS. your Web sites. SMTP Service allows IIS to Inetpub\wwwroot directory and the files Internet Information Services component to the computer.

  You can have multiple installations of IIS on a computer, send e-mail messages. it stores from the computer. The parts of the component that must be added are but you can have only one installation of PHP.

  Common Files, which are the files required to run IIS; My Do

INSTALL INTERNET INFORMATION SERVER

  Change or Programs Remove My Do Programs Change or Remove My Do Change or Programs Remove My Do Programs Change or Remove My C My N P Add/Remove Programs Add New Windows My C My N P Add/Remov Programs Windows Add New Internet Information Services (IIS) 18.3 MB My C My N P Add/Remov Programs Windows Add New World Wide Web Server 1.9 MB My C My N P Add/Remov Programs Add New Windows Recy Int Ex Components Recy Int Ex Component Recy Ex Int Component 5.6 Recy Int Ex Component

  ⁄ ¤ ˇ Á ‡

  Insert the Windows 2000 In the Control Panel, › Click Internet Information Click Details to display Click the box ( ) beside each Click OK to confirm When the installation is You should restart the

  ■ ■

  Professional CD-ROM disc double-click Add/Remove Services (IIS). the Internet Information part of the Internet Information your selections. complete, a message indicates computer before using into a drive. Programs to display the Services (IIS) dialog box. Services component you want to that you have successfully Internet Information

  °

  This area displays a Click Next to install

  ■

  Add/Remove Programs install ( changes to ). completed the Windows Server. description of the Internet the parts of the Internet

  Note: If the Microsoft Windows 2000 window.

  Components Wizard. Information Services

  In this example, Common Files, Information Services

  CD dialog box appears, click to

  ‹ Click Add/Remove component.

  Internet Information Services component you selected. · Click Finish to close the close the dialog box. Windows Components Snap-In and World Wide Web wizard. to display the Windows Server are selected. Components Wizard.

  1 GETTING STARTED WITH PHP PHP ADD A VIRTUAL DIRECTORY TO

INTERNET INFORMATION SERVER

  You can also use Windows Explorer to add a You can easily remove a virtual directory hen Internet Information Server (IIS) is installed, virtual directory to IIS. Start Windows Explorer you no longer need from IIS. Perform alias is often used to shorten a long directory name. For a number of directories are created that can and then select the directory you want to add steps 1 and 2 below to display the Internet example, a directory named '2001_marketing_information' be used to store Web pages and PHP pages. as a virtual directory. Click the File menu and Information Services window and then could be assigned the alias 'marketing'. Short directory

  W

  By default, these directories are stored in the document then choose Properties. In the Properties select the virtual directory you want to names can help make a Web site easier for users to root directory C:\Inetpub\wwwroot. Only pages stored dialog box, click the Web Sharing tab and then remove. Click the Delete button ( ) navigate. in the document root directory or its subdirectories can select the Share this folder option. In the Edit and then click Yes in the dialog box that

  Virtual directories allow IIS to make a directory accessible be displayed by users. You can create a virtual directory Alias dialog box that appears, type an alias for appears. Removing a virtual directory to users of a Web site regardless of the location of the to make pages that are not stored in the document root the virtual directory and then select the access prevents users from accessing pages directory. For example, the directory C:\datapages can be directory or its subdirectories available for viewing. and application permissions you want to use stored in the directory but does not added to the abccorp.com Web site as a virtual directory for the directory. Then click OK. Click OK in remove the directory and its contents

  In order for PHP pages stored in a virtual directory to be with the alias 'data'. Users can then use the address the Properties dialog box to add the virtual from the computer. processed by the Web server, the virtual directory must be www.abccorp.com/data/ to access pages in the virtual directory to IIS. properly configured. The Virtual Directory Creation Wizard directory. Users accessing a virtual directory you have can help you add and configure a virtual directory. added to IIS will not be able to determine the actual location of the directory on the computer.

  You must give the virtual directory an alias, which is a name users will use to access pages in the directory. An

  ADD A VIRTUAL DIRECTORY TO INTERNET INFORMATION SERVER Default Web Site New Virtual Directory Site ⁄ ‹ ˇ ‡

  ° · ‚ In the Control Panel, Click to display Click Action. Click Virtual Directory. The Virtual Directory Click Next to continue. Type an alias for the Click Next to continue.

  ■

  double-click Administrative a list of Web sites on the Creation Wizard appears. virtual directory.

  Á Click New.

  Tools to display the Web server ( changes Administrative Tools window. to ).

  ¤ ›

  Double-click Internet Click the Web site Services Manager to display you want to add a virtual the Internet Information directory to.

  CONTINUED Services window.

  1 GETTING STARTED WITH PHP PHP ADD A VIRTUAL DIRECTORY TO

INTERNET INFORMATION SERVER

  ou must specify the location of the directory you The Browse permission allows users to view a list of all You can later change the execute permissions After adding a virtual directory to want to add as a virtual directory to IIS. You must the subdirectories and pages the virtual directory contains. for a virtual directory you have added to IIS. Internet Information Server, you can also specify the access permissions for the directory. When a user specifies a directory but does not specify the Display the Internet Information Services enable or disable the logging function

  Y

  Access permissions determine how the Web pages, PHP name of the page they want to display, the user can select window and then select the virtual directory for the directory. Display the Internet pages and other files in the directory can be utilized. a page, including a PHP page, from the list. you want to change. Click the Properties Information Services window and then

  The Read permission allows users to access Web or After a virtual directory is created, all the pages and files in button ( ) to display the Properties dialog select the virtual directory you want to PHP pages and must be turned on for a virtual directory the directory will be available to users accessing the Web box and then click the Virtual Directory tab. change. Click the Properties button ( ) containing content you want to be displayed. The Read site. You should be careful to store only files and Web or Click in the Execute Permissions area and to display the Properties dialog box permission is turned on by default. PHP pages you want users to be able to view in the virtual select the option you want to use. The Scripts and then click the Virtual Directory directory. and Executables option allows all file types to tab. Click the Log visits option to

  The Run scripts permission allows scripts to run in the be accessed or executed in the directory. The enable ( ) or disable ( ) the directory and must be turned on for virtual directories A virtual directory you add to IIS may be affected by folder Scripts only option allows only scripts, such as recording of visits to the directory that contain PHP pages. The Run scripts permission is permissions set by the Windows operating system. Folder PHP files, to be run. The None option allows in a log file. turned on by default. permissions restrict who can access the folder and how the access to only static files, such as HTML or files in the folder can be used. For more information about image files. The Execute permission allows applications to run in folder permissions, see page 132. the virtual directory. For security reasons, the Execute permission is rarely enabled.

  The Write permission allows files to be created in the directory and must be turned on for virtual directories containing PHP pages that create files.

  ADD A VIRTUAL DIRECTORY TO INTERNET INFORMATION SERVER (CONTINUED) sales

  — £

  ¢

  Type the path of the You can also click the ¡ Click an access ™ Click Next to continue. A message appears, Click Finish. The virtual directory is Click to close

  ■ ■

  ■

  directory you want to Browse button to locate the permission in this area indicating that you have added to Internet Information the Internet Information add as a virtual directory. directory on the computer. to turn the permission successfully completed Server and appears in this area. Services window. on ( ) or off ( ). the Virtual Directory ± Click Next to continue.

  Creation Wizard.

  1 GETTING STARTED WITH PHP PHP SET WINDOWS FILE AND

  Great care must be taken when setting file and If you no longer wish a user or group to folder permissions on a Web server. To gain a full have permission to access a file or folder,

FOLDER PERMISSIONS

  understanding of file and folder permissions and the you can remove the user or group. Perform consequences of changing these permissions, you steps 1 to 4 below to display the Security ou can change permissions to grant users and groups as change permissions. Modify allows users to modify, add, should consult the operating system and Web server tab of the Properties dialog box. Click the of users different types of access to a file or folder move and delete files. Read & Execute allows users to run documentation. Incorrectly setting file and folder user or group that you no longer want to on Internet Information Server (IIS). The types of applications, such as PHP pages. List Folder Contents allows permissions on a Web server can leave the server be able to access the file or folder and then

  Y permissions that can be set for a file or folder depend on users to display a list of files and folders stored in a folder.

  vulnerable to a range of problems, from accidental click Remove. the operating system and file system installed on the Web Read allows users to display files and Write allows users to data deletion to serious security breaches. Incorrect server. The steps below are for use on a server running the change files. file and folder permissions can also prevent all users Windows 2000 operating system with the NTFS file system. from accessing the Web server. Windows file and folder permissions work with the access

  When IIS is installed, a user account is created called permissions set in IIS. Access permissions set for a folder in

  IUSR_ followed by the name of the computer, such as

  IIS apply to all users who access the folder. Windows folder If you develop your PHP pages on a different Web IUSR_WEBSRV. This user account is part of the Everyone permissions apply only to the users and groups you specify. server than you publish the pages on, you must group. If you deny the Everyone group access to a file or When Windows file and folder permissions and IIS access ensure that the appropriate file and folder permissions folder, you can use the IUSR account to allow users to permissions are set differently, the Web server uses the are set on the Web server on which the pages are access information in the file or folder. most restrictive permissions. For more information about published. The permissions will not be transferred to IIS access permissions, see page 14. the Web server when you transfer the files for the

  You can allow or deny permissions for a user or group PHP pages. to specify how a file or folder can be accessed. Full Control allows users to modify, add, move and delete files, as well My Documents SET WINDOWS FILE AND FOLDER PERMISSIONS My Documents Administrator (PHP-WIN2000\Administrator) My Documents My Documents

  My Computer My Network Places Properties phone_extensi ons My Computer My Network Places My Computer My Network Places IUSR_PHP-WIN2000 PHP-WIN2000 My Computer My Network Places Internet Guest Account (PHP-WIN2000\I...

  Recycle Bin Explorer Internet Recycle Bin Explorer Internet Recycle Bin Explorer Internet Recycle Bin Explorer Internet ⁄ ¤ › ˇ Á

  · ‚

  Click the file or folder Click File. Click the Security tab. Click Add to display the Click a user or group in You can repeat steps 6 Click a user or group Click an option to allow

  ■

  you want to change the Select Users, Computers, this area you want to have and 7 for each user or in this area to view their or deny the permission.

  ‹

  Click Properties to ■ This area lists the users permissions for. or Groups dialog box. access to the file or folder. group you want to be able permissions.

  —

  display the Properties and groups that can access Click OK to confirm to access the file or folder.

  ‡ dialog box. the file or folder.

  Click Add.

  This area displays the your changes.

  ■ °

  Click OK to confirm permissions granted to The user or group you

  ■ your selection. the user or group.

  selected appears in this area.

  1 GETTING STARTED WITH PHP PHP

INSTALL PERSONAL WEB SERVER

  icrosoft Personal Web Server (PWS) allows you to The C:\Inetpub\wwwroot directory is automatically set as the host a single Web site on your own computer to home directory for PWS. The home directory is where you

  In addition to Windows 98, PWS can be used on You can double-click the Personal Web make Web and PHP pages available for viewing. will store all the Web and PHP pages you want to be able to a computer running the Windows 95 or Windows Server icon ( ) on the taskbar to display

  M

  This allows you to test and troubleshoot any problems display. If you do not want to use the C:\Inetpub\wwwroot NT Workstation operating system. If you do not have the Personal Web Manager window. The before transferring the pages to a Web hosting service directory as the home directory, you can set another your Windows 98 CD-ROM installation disc or you Personal Web Manager window allows you on the Internet. Personal Web Server 4.0 is available on directory as the home directory. This is useful if you already are using Windows 95 or Windows NT Workstation, to administer your Web site. For example, the Windows 98 CD-ROM installation disc. have a directory that stores the pages you want users to be you can obtain Personal Web Server 4.0 at the to stop PWS and make your Web site able to display and you do not want to copy the pages to the www.microsoft.com Web site. PWS is part of the unavailable to users, click the Stop button. PWS is not suitable for making information available directly default home directory.

  Windows NT 4.0 Option Pack. To restart PWS, click the Start button. to users on the Internet, but can be used to share documents on small networks or intranets.

  After PWS and PHP are installed, you can begin creating and accessing Web and PHP pages. You can access pages using a You do not have to start PWS manually each time In addition to wwwroot, several other

  When installing PWS, you can choose the installation option Web browser installed on the same computer that is running you want to use the software. Once you have directories are created when PWS is that best suits your needs. The Minimum option installs only

  PWS or a Web browser installed on another computer on the installed the Web server software, PWS will start installed. In the Personal Web Manager the files required to run PWS and is useful when installing same network. To install PHP on a Windows-based computer, automatically each time you start your computer. window, you can click C:\Inetpub\wwwroot PWS on a computer with limited hard drive space available. see page 22. to display these directories. The Typical option installs the most commonly used PWS files and is the recommended option. The Custom option allows advanced Web site developers to choose the PWS files they want to install.

INSTALL PERSONAL WEB SERVER

  C:\Inetpub\wwwroot

  ˇ

⁄ Locate and double-click The Microsoft Personal Click the type of Note: If you choose Custom, This area displays the If you want to use When the installation is Click Finish to exit

  ■ ■ ■

  the setup.exe file for the Web Server Setup dialog installation you want location of the Personal a different directory as complete, a message appears the setup program.

  the following steps will be Personal Web Server setup box appears, displaying to perform.

  Web Server home directory. the home directory, click thanking you for choosing different for your installation.

  A message will appear

  ■

  program. information about Personal Browse to specify the Microsoft software. asking you to restart your Web Server. directory you want to use.

  The Personal Web Server computer. Click Yes to

  Note: On the Windows 98 CD-ROM ■ ¤ Click Next to continue.

  › Click Next to continue. icon appears on the taskbar. restart your computer. disc, the setup.exe file is located in the add-ons directory in the pws subdirectory.

GETTING STARTED WITH PHP

  This area displays information about the PHP program.

  1 CONTINUED Á Click Next to continue.

  INSTALL PHP ON A WINDOWS-BASED COMPUTER

  You must also choose the directory where you want the main PHP files to be stored. The default installation location is C:\PHP. You can specify another destination folder, but it is recommended that you accept the default folder.

  When you start installing PHP, you must first accept a license agreement before the installation will continue. The setup program then allows you to choose the type of installation you want to perform. The Standard option is recommended for most users. The Advanced option allows experienced Web site developers to specify additional options for installing PHP.

  The computer on which you install PHP does not need to be connected to the Internet. You can use a stand-alone computer that has Web server software and the PHP program installed to develop PHP pages. The pages can then be transferred to a Web server connected to the Internet or an intranet. The Web server to which you transfer the PHP pages can use any type of operating system, such as UNIX.