Install Php

  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Install Php as PDF for free.

More details

  • Words: 4,484
  • Pages: 25
http://www.angelfire.com/members/bondbloke001/php.html

Install PHP OK, up to now things have been pretty easy, Apache, MySQL and MySQL Tools have pretty much done all of the work themselves, with a few changes here and there. Now the going gets just a little tougher, we are going to install PHP. There is only one way to do this and that is manually; forget the Windows Binary that comes with a msi (Microsoft Installer – now known as Windows Installer) as this does not provide what we want. The msi binary installs PHP as a CGI run application and we want PHP to run as an Apache module. The other problem with the installer version is one of security, and it is for both of these reasons that I recommend installing PHP manually. Actually we now arrive at the main reason for installing all of the previous applications, without Apache PHP would be useless as it needs the server to operate, and PHP is the language we’re going to use for development of dynamic web pages. Also it is extremely difficult, if not impossible to create dynamic web pages without a database, which is where MySQL enters the equation; and PHP makes connecting to a database pretty simple. The first thing we need to do is locate and open the .zip file that we downloaded, then to extract its contents into the C:\server\php\ folder that we created at the beginning of the whole process. This extraction process will create the necessary directory structure within the php folder and you should end up with a directory structure looking like this:-

If one expanded this directory structure to a sort of tree form it would look something like this:• • • • • • • • • • • • • • • • • • • • •

c:\server\php\ +--dev -php5ts.lib +--ext -php_bz2.dll -... along with numerous other .dll files +--extras +--mibs -- support files for SNMP - assorted files +--openssl -- support files for Openssl - assorted files +--pdf-related -- support files for PDF - assorted files -mime.magic +--pear -- initial copy of PEAR -go-pear.bat -- PEAR setup script -fdftk.dll -... -php-cgi.exe -- CGI executable -php-win.exe -- executes scripts without an opened command prompt -php.exe -- CLI executable - ONLY for command line scripting

• • • • • • • • •

-... -php.ini-dist -- default php.ini settings -php.ini-recommended -- recommended php.ini settings -php5activescript.dll -php5apache.dll -php5apache2.dll -… -php5ts.dll -- core PHP DLL -...

Now within your php folder create two new folders named uploadtemp and sessiondata. The uploadtemp folder will be a temporary folder to store HTTP uploaded files, and the sessiondata folder will be used for storing all session files. The paths to these folders will read c:\server\php\uploadtemp\ and c:\server\php\sessiondata\ respectively. And, basically, that is PHP installed, it wasn’t too painful was it? But, there is still some work to do before everything is as it should be and PHP is fully functioning, next comes the configuration process. We now need to set up a valid configuration file for PHP, the php.ini file; there are two .ini files distributed with PHP, php.ini-dist and php.ini-recommended. I recommend using the php.inirecommended as the default settings are optimised for performance and security. The best way to use this file is to open it with Notepad, then save it to c:\server\php\ with the file name php.ini, making very sure that the .txt extension is not included on the end of the file name. Now we need to re-open the php.ini file that we have just created to make some changes, it will open in Note pad by default now. Warning: be very careful when making any changes in this file, if you are not sure of the change you are making then it is best not to make it. The changes one could make to the configuration file are many and varied, and far to complex to be covered in a simple tutorial like this as the descriptions and explanations would be quite lengthy; if you really need to know then the online PHP documentation is the place to look. However, for now, the following changes will be sufficient to get up and running. Find and change the following lines:find - ;upload_tmp_dir = and change it to - upload_tmp_dir =c:\server\php\uploadtemp\ find - ;session.save_path = "N;/path" and change it to - "session.save_path = "c:\server\php\sessiondata\" find - doc_root = and change it to = doc_root =.c:\server\Apache2\htdocs\ find - extension_dir = "./" and change it to - extension_dir = "C:/server/php/ext/" find - ;extension=php_mbstring.dll and change it to - extension=php_mbstring.dll find - ;extension=php_mysql.dll and change it to - extension=php_mysql.dll find - ;extension=php_mysqli.dll and change it to - extension=php_mysqli.dll Warning: be very careful when entering paths like .c:\server\Apache2\htdocs\, and ensure that they are entered exactly as shown above, as even the smallest typo can cause all sorts of problems, and be the very devil to track down. One of the problems I find with typo’s is that you can be looking at a line with a typo

in it and miss it due to the fact that you are seeing what you expect to see. Check everything twice and then check it again for good measure. Next we need to tell the computer where php.ini is located by setting the path to it. This sounds more complex than it actually is Start > Control Panel > Performance and Maintenance > System - this will open the System Properties window click on the “Advanced” tab then click the “Environment Variables” button In the lower box locate and highlight “Path” and click “Edit” By now you should have an array of open windows like that below:-

In the Edit System Variable window which should look exactly like the screen below, although without the c\server\php at the end because this is what you are now going to add:-

Click in the “Variable value:” box and go to the end of the string within it, ensuring that it is no longer highlighted, and add c:\server\php\; Click OK and restart your computer. Right, that’s the basic configuration of PHP completed, now all we have to do is ensure that Apache knows where to find the files it needs to enable it work with our .php files. To do this we need to open the

httpd.conf Apache configuration file, the easiest way to do this is Start > All Programs > Apache HTTP Server 2.2 > Configure Apache Server > Edit the httpd.conf Configuration File - as seen below:-

As this is a plain old text file it will open in Notepad by default, just go to the end of the document and add the following lines:LoadModule php5_module "c:/server/php/php5apache2_2.dll" AddType application/x-httpd-php .php PHPIniDir "c:/server/php/" Warning: again ensure that you enter this correctly without typo’s otherwise Apaches will not recognise your PHP installation. The first line tells Apache where to find the PHP installation and the relevant .dll file to enable PHP with Apache, the second line tells Apache to recognise .php as a valid file extension, and the third line tells Apache where the php.ini file is located. All that is left to do now is to Restart Apache using the same method we used earlier when we installed it. Now all it remains to do is to check that PHP is working properly. For that we need to create a .php file, so open Notepad and type in the following code exactly as it appears here: Now we need to save this file, naming it “phpinfo.php” again ensuring that there is no .txt extension at the end of the file name. The file has to go in the web root directory of Apache, c:\server\Apache2\htdocs\ as is seen in the screenshot below:-

Again we need to fire up our favourite browser (as you know I prefer Firefox) and type “http://localhost/phpinfo.php” into the location address bar. If you see a page that looks like the image below, then you have successfully managed to install and setup PHP correctly on your server.

Don’t worry if the page you see is not exactly the same as this, as it varies according to how PHP has been configured; as long as this is the sort of result you get that is fine. If this is not the result you get, then I am afraid that you are going to have to work through all of the configuration changes you made to find the error.

Previous < Install MySQL tools - Next > Install phpMyAdmin

Install MySQL Tools MySQL management would be an absolute nightmare if the only tool available to us was the Command Line Client (although it does have its place in an emergency), which is why we will be installing phpMyAdmin later. However, MySQL have developed a set of tools with a Windows interface that we can also add to our armoury of weapons, and which are probably much more appropriate to use in a learning/development environment (especially for learning MySQL) than phpMyAdmin, but that is not to say that phpMyAdmin is useless, far from it as it is indispensable for the more mundane everyday tasks. So let’s get started, find the MySQL Tools file that you downloaded and double click it.

This will bring up a window telling us exactly what is going to be done. Click Next >

Before we continue we have to accept the license agreement, if we don’t the process will terminate without installing the tools we want. Select the radio button "I Accept the terms in the license agreement" then Click Next >

Once more we are going to change the default location for installation to the location of our choice. Click Change...

We have seen this window a couple of time before now, so explaining what to do yet again seem pointless. This time we want to install MySQL Tools in the same folder as MySQL so we want C:\server\MySQL\ under the “Folder Name:” then Click OK

This will return us to the previous window which should now be displaying our change of installation location. Click Next >

The next choice we are offered is whether we want to select which components to install (Custom) or if we want to install all of the components (Complete). In these situations I always choose Complete, for

the simple reason that past experience has told me that I will invariably want something that I have not installed. Select the Complete radio button then Click Next >

It’s that time again, time to go off and get a cup of tea, chase the wife around the bedroom or whatever turns you on… Click Install

That’s it, done, it is as simple as falling off a log. All of the MySQL Tools can be found in the usual place Start > All Programs > MySQL, as is shown below:-

Previous < Install MySQL - Next > Install PHP

Install phpMyAdmin We are now on the last leg of our journey, the installation of phpMyAdmin. This, I would say, is the easiest bit, as most of the configuration that needs doing has been done, and all this involves is copying

some files and putting some information into a small configuration file to make phpMyAdmin work with MySQL. Find and open the zip file that you downloaded then extract its contents to c:server\Apache2\htdocs\, all of the files will extract into the directory structure needed, however the main folder will have a name which, depending on the version you downloaded, will look something like phpMyAdmin-2.11.7-alllanguages, now rename the main folder “phpmyadmin” ending up with the directory structure shown below.

We now have everything that we need installed in the one location, which will make life so much easier if any future problems are encountered. We no need to make sure that phpMyAdmin is working, so fie up your favourite browser once more and enter http://localhost/phpmyadmin/index.php into the address bar. You may get an error message like the one below;-

which means that you missed a bit in the configuration of PHP, and did not uncomment (that is to remove the ; from the beginning of a line) these lines in the php.ini file:;extension=php_mbstring.dll ;extension=php_mysql.dll ;extension=php_mysqli.dll

So, open up the php.ini file once more, find the lines above and make sure that the ; is removed from the beginning of each line. Now save the file and Restart Apache, re-open your browser and try http://localhost/phpmyadmin/index.php once again and all should be well, but with the error shown below:-

this is because we have not yet configured phpMyAdmin to recognise MySQL properly, and that phpMyAdmin needs the password created when installing MySQL to connect. We now need to navigate to c:server\Apache2\htdocs\phpmyadmin\ and find a file named config.inc.php, if it is not there you will see a file named config.sample.inc.php, simply rename this file to config.inc.php by removing the .sample immediately after the config bit, then open it, it should look something like this. >?php /* * Generated configuration file * Generated by: phpMyAdmin 2.11.7 setup script * Version: $Id: setup.php 10748 2007-10-10 07:30:59 * Date: Fri, 27 Jun 2008 08:49:24 GMT */ $cfg['PmaAbsoluteUri'] = ''; // path for phpMyAdmin /* Servers configuration */ $i = 0; /* Server localhost (config:root) [1] */ $i++; $cfg['Servers'][$i]['host'] = ''; $cfg['Servers'][$i]['extension'] = 'mysql'; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['compress'] = false; $cfg['Servers'][$i]['auth_type'] = 'config'; $cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password'] = ''; $cfg['Servers'][$i]['pmadb'] = ''; // Database used for Relation, Bookmark and PDF Features /* End of servers configuration */ ?<

This sample was copied from my installation, but I removed all of the settings that need to be entered to show what the basic config.inc.php file will look like, at least more or less, as they tend to differ from version to version. Now we need to tell phpMyAdmin the location of installation, so find this line:$cfg['PmaAbsoluteUri'] = ''; and change it to:$cfg['PmaAbsoluteUri'] = 'http://localhost/phpmyadmin/'; If this line is not there then you can either type it in or copy and paste the line above into the file. phpMyAdmin uses three authentication methods 1. config method (the default method) 2. http method 3. cookie method (recommended method) As we are installing into a learning/development environment I will concentrate on the first (default) authentication method. If we were installing into a production environment where security were of the utmost importance then we would use the third most secure method. Now do the following:find - $cfg['Servers'][$i]['host'] = ''; and change it to - $cfg['Servers'][$i]['host'] = 'localhost'; find - $cfg['Servers'][$i]['auth_type'] = ' '; and change it to - $cfg['Servers'][$i]['auth_type'] = 'config'; - (that is if it is not already set at the config (default) setting) find - $cfg['Servers'][$i]['user'] = ' '; and change it to - $cfg['Servers'][$i]['user'] = 'root'; - (again if it is not already set to ‘root’) find - $cfg['Servers'][$i]['password'] = ' '; and change it to - $cfg['Servers'][$i]['password'] = 'Put your password in here'; find - $cfg['Servers'][$i]['pmadb'] = ''; // Database used for Relation, Bookmark and PDF Features and change it to - $cfg['Servers'][$i]['pmadb'] = 'pmadb'; - (or whatever you want to call your phpMyAdmin database) Once again we need to fire up our favourite browser and point it to http://localhost/phpmyadmin/index.php, there is a possibility that you may get the following error message:-

if you have not on the two previous occasions uncommented this line:;extension=php_mbstring.dll

in the php.ini file; if this is the case then that is the next thing that needs doing. Don’t Forget: every time you alter the php.ini file you need to Restart Apache. Having made the change, if necessary re-open you browser and point it once again at http://localhost/phpmyadmin/index.php, and if all is well you should see the following screen, or something like it:-

If you are seeing this then everything is working as it should, if not then some troubleshooting of the configuration files is needed. Although I am sure that if you have followed all of the above instructions closely there will not be a problem, but if there is it is probably one that I have not encountered and have not covered here. In which case I would suggest heading off to a forum like PHP Freaks, where there are any number of solutions to any number of problems, and very many talented people who will help find the answer to your specific problem.

Previous < Install PHP

B.1.4.1.1. Resetting the Root Password on Windows Systems Use the following procedure for resetting the password for any MySQL root accounts on Windows: 1. Log on to your system as Administrator. 2. Stop the MySQL server if it is running. For a server that is running as a Windows service, go to the Services manager: 3. Start Menu -> Control Panel -> Administrative Tools -> Services Then find the MySQL service in the list, and stop it. If your server is not running as a service, you may need to use the Task Manager to force it to stop. 4. Create a text file and place the following statements in it. Replace the password with the password that you want to use. 5. UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; 6. FLUSH PRIVILEGES; The UPDATE and FLUSH statements each must be written on a single line. The UPDATE statement resets the password for all existing root accounts, and the FLUSH statement tells the server to reload the grant tables into memory.

7. Save the file. For this example, the file will be named C:\mysql-init.txt. 8. Open a console window to get to the command prompt: 9. Start Menu -> Run -> cmd

10. Start the MySQL server with the special --init-file option: 11. C:\> C:\mysql\bin\mysqld --init-file=C:\mysql-init.txt If you installed MySQL to a location other than C:\mysql, adjust the command accordingly. The server executes the contents of the file named by the --init-file option at startup, changing each root account password. You can also add the --console option to the command if you want server output to appear in the console window rather than in a log file. If you installed MySQL using the MySQL Installation Wizard, you may need to specify a --defaults-file option: C:\> "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld.exe" --defaults-file="C:\Program Files\MySQL\MySQL Server 5.1\my.ini" --init-file=C:\mysql-init.txt

The appropriate --defaults-file setting can be found using the Services Manager: Start Menu -> Control Panel -> Administrative Tools -> Services

Find the MySQL service in the list, right-click on it, and choose the Properties option. The Path to executable field contains the --defaults-file setting.

12. After the server has started successfully, delete C:\mysql-init.txt. 13. Stop the MySQL server, then restart it in normal mode again. If you run the server as a service, start it from the Windows Services window. If you start the server manually, use whatever command you normally use.

You should now be able to connect to MySQL as root using the new password.

Overview A majority of popular PHP applications use MySQL Server as a back end data storage. This requires hosting providers to include MySQL database support into the hosting packages. This section provides a set of basic instructions on how to setup and configure MySQL Server on Windows Server® 2008 for use in shared hosting environments. For detailed documentation about MySQL Server, refer to MySQL documentation. This article contains: • • • •

Installing MySQL Server on Windows Server 2008 Configuring MySQL Instance Securing MySQL Server on Windows Server 2008 User and Database Provisioning

Installing MySQL Server on Windows Server 2008 It is recommended to install MySQL server on a dedicated server machine rather than having it on the same server with IIS 7.0. This separation of database server and web server makes overall installation more secure and manageable and avoids resource contentions between database and web server processes. MySQL Server binaries and installation package can be downloaded from the official MySQL web site. For the purposes of this guide, the MySQL Community Server v 5.0.45 was used. MySQL can be installed either by using the installer package or by manually copying binaries onto a server file system. For detailed set of instructions on how to install MySQL on Windows, refer to these articles: Using the MySQL Installation Wizard or Installing MySQL from a Noinstall Zip Archive.

Configuring MySQL Instance Once MySQL installer completes, it will offer an option of launching a MySQL Server Configuration Wizard. Note: If you plan to enable network access to your database server, then you must open a TCP port in Windows Firewall before running the configuration wizard. By default MySQL uses TCP port 3306, but it can be changed via Configuration Wizard or manually in my.ini file. To create a Firewall rule for the default MySQL TCP port, run this command from Windows command line prompt: C:\>netsh advfirewall firewall add rule name="MySQL Server" action=allow protocol=TCP dir=in localport=3306 Once the Firewall port has been opened, run the MySQL Server Configuration Wizard and choose the configurations options that most closely match your environment. Some of the configuration options that you may want to set when configuring MySQL for shared hosting are described below. For a detailed list of all settings provided in Configuration Wizard, refer to MySQL Server Configuration Wizard.

Server Type

When choosing a server type, select either “Server Machine” or “Dedicated MySQL Server Machine”, depending on what kind of server setup you have. In general, it is recommended to have a database server setup on a separate machine and use “Dedicated MySQL Server Machine” option.

Database Usage Database usage options control what kind of database storage engine is used on the server: • •

MyISAM – Optimized for high performance SELECT operations. It has low overhead in terms of memory usage and disk utilization, but at the cost of not supporting transactions InnoDB – Provides fully ACID transactional capabilities, but at the cost of more aggressive usage of disk space and memory

For an in-depth comparison of these database engines, refer to MySQL Storage Engine Architecture. As a general recommendation – if web applications on your server require multi-statement transactions, advanced isolation levels and row-level locking, foreign key constraints, or otherwise have a requirement for ACID features -- use InnoDB. Otherwise, use MyISAM.

InnoDB Data File Location For the InnoDB storage engine, it is possible to change the location of the database data files. Usually, this is recommended when your system has higher capacity or higher performance storage devices available, such as the RAID storage system. This option is not available for MyISAM storage engine.

Concurrent Connections Choose the option that sets the number of concurrent connection you need. Note: Connections take memory, so if the number you choose is too big, then the server may not be able to handle too many connections.

Modifying my.ini File My.ini file, located in %ProgramFiles%\MySQL\MySQL Server 5.0\ contains the startup variables for the MySQL service. Modify settings in that file to fine tune server performance. In the same folder, you may find several other .ini files, including these two: • •

my-large.ini – Contains recommended configuration settings for running MySQL service on dedicated server with 512 MB of RAM my-huge.ini – Contains recommended configuration settings for running MySQL service on dedicated server with 1 to 2 GB or RAM

Depending on your server configuration, use some of the recommended settings from those files.

Configuring PHP to Work with MySQL Server In order for PHP to work with MySQL it is necessary to perform the following modifications to php.ini file: • •

Set extension_dir to point to the folder where all PHP loadable extensions are located, frequently in the ext folder, e.g. extension_dir=”.\ext”. Enable dynamic extension for MySQL by un-commenting the corresponding line, e.g. extension=mysql.dll.

Securing MySQL Server on Windows Server 2008 The following guidelines describe how to tighten the security of MySQL Server on Windows Server 2008.

Change the MySQL Service Account By default, MySQL service is installed to run as a highly privileged Local System account. However, it is recommended to run the service under a more restricted service account. You can create a dedicated account for it or you can use a Windows built-in “Local Service” account. To change the MySQL service account follow these steps (you must be logged in as Windows Server Administrator): 1. Stop MySQL service by typing this command: C:\>net stop mysql

2. Grant new service account permissions to MySQL installation folder. C:\>icacls "c:\Program Files\MySQL\MySQL Server 5.0" /grant "NT AUTHORITY\LOCAL SERVICE":(OI)(CI)(M)

3. Configure MySQL service to use a more restricted service account by going Services and opening properties of MySQL◊ Administrative Tools ◊to Start service. Open the Log On Tab and enter “Local Service” in the “This account” text box. Leave the Password and Confirm password fields empty.

4. Start MySQL service by typing this command: C:\>net start mysql

Remove Anonymous Database Account If It Exists 1. Open the MySQL command prompt by typing: mysql –u root –p 2. Once logged on to MySQL, use the following sequence of commands: mysql> use mysql; Database changed mysql> DELETE FROM user WHERE user = ''; Query OK, 2 rows affected (0.03 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.05 sec)

Restrict Root Account to Login Only from localhost 1. Open MySQL command prompt by typing: mysql –u root –p 2. Once logged on to MySQL use the following sequence of commands: mysql> use mysql; Database changed mysql> DELETE FROM user WHERE user = 'root' AND host = '%'; Query OK, 2 rows affected (0.03 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.05 sec)

Change the Name of the Root User 1. Open MySQL command prompt by typing: mysql –u root –p 2. Once logged on to MySQL use the following sequence of commands: mysql> USE mysql; Database changed mysql> UPDATE user SET user='johndoe' WHERE user='root'; Query OK, 1 row affected (0.19 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.23 sec)

User and Database Provisioning The following examples demonstrate how to provision new user and database on MySQL Server.

User Provisioning To provision a new user to MySQL server database follow these steps: 1. Open MySQL command prompt by typing: Mysql –u root –p 2. Once logged on to MySQL use the following command: mysql>CREATE USER ‘some_username’ IDENTIFIED BY ‘some_password’; Query OK, 0 rows affected (0.00 sec) Note: The newly created user by default does not have any privileges on MySQL Server.

Database Provisioning To create a new database and grant user access to it follow these steps: 1. Open MySQL command prompt by typing: Mysql –u root –p 2. Once logged on to MySQL use the following command: mysql>CREATE DATABASE IF NOT EXISTS some_database_name; Query OK, 1 row affected (0.00 sec)

To grant access to this database for a particular user, use this command: mysql> -> -> -> -> -> -> -> -> -> -> -> -> -> -> ON

GRANT ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TEMPORARY TABLES, CREATE VIEW, DELETE, DROP, EXECUTE, INDEX, INSERT, LOCK TABLES, SELECT, UPDATE, SHOW VIEW some_database_name.* TO 'some_username';

Related Documents

Install Php
May 2020 2
Php Install
November 2019 25
Install
October 2019 35
Install
November 2019 33
Install
November 2019 33