Changes between Version 8 and Version 9 of howto/PHP


Ignore:
Timestamp:
Jan 7, 2015, 1:24:17 AM (9 years ago)
Author:
magill@…
Comment:

upd

Legend:

Unmodified
Added
Removed
Modified
  • howto/PHP

    v8 v9  
    11[[PageOutline]]
     2
     3[wiki:howto <- Back to the HOWTO section]
     4
     5This page describes the installation of the PHP 5.6 server under OSX (Yosemite 10.10.2) via MacPorts (version 2.3).   Date 28 December 2014
     6
     7For information on integration '''Apache''' with '''MySQL''' and '''PHP''', see:''' [[howto/MAMP]]'''
     8
     9
     10= Step 1: Install PHP 56 = #install
     11
     12{{{
     13$ sudo port install php56-apache2handler
     14$ sudo port install php56-mysql
     15}}}
     16
     17
     18  '''''Note:''''' the php56 port contains the core PHP features, but there are many optional features available in separate ports, some of which you may want to install as well . Use `port search php56` to see all the ports that are available.
     19
     20
     21= Step 2: PHP Configuration file setup =
     22
     23Set up your PHP configuration files. For development purposes use:
     24{{{
     25$ cd /opt/local/etc/php56
     26$ sudo cp php.ini-development php.ini
     27}}}
     28or for a production server:
     29{{{
     30$ cd /opt/local/etc/php56
     31$ sudo cp php.ini-production php.ini[[PageOutline]]
    232
    333[wiki:howto <- Back to the HOWTO section]
     
    137167= Step 6: Install pmadb = #pmadb
    138168Some consider the installation of pmadb "optional." \\
    139 However, phpMyAdmin will flag the fact that it is missing and therefore certain features are not functional with the message:
     169However, phpMyAdmin will flag the fact that it is missing and therefore certain features not functional, with the message:
    140170{{{
    141171The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. Find out why.
     
    143173}}}
    144174
    145 For additional features provided by pmadb (http://wiki.phpmyadmin.net/pma/pmadb), run
     175For additional features provided by pmadb (http://wiki.phpmyadmin.net/pma/pmadb), first run
    146176{{{
    147177$ mysql -u root -p < /opt/local/www/phpmyadmin/examples/create_tables.sql
    148178}}}
    149179
    150 Next: create a file: ''mysql_phpMyAdmin_pmaSetup.sql'' - it is a one-time use scratch file so you can place it anywhere. (It is not included with the phpMyAdmin distribution.)
     180Next: create a file ''"mysql_phpMyAdmin_pmaSetup.sql"'' - containing the following SQL code: (change the 'pmapass' to your password)\\
     181- this is a one-time use scratch file so you can place it anywhere and delete it after use. (It is not included with the phpMyAdmin distribution.)
     182
    151183{{{
    152184-- HOW TO USE THIS FILE (with MacPorts installation)
    153185-- mysql -u root -p < /opt/local/www/phpmyadmin/examples/create_tables.sql
    154 -- mysq5 -u root -p < mysql_phpMyAdmin_pmaSetup.sql
     186-- mysql -u root -p < mysql_phpMyAdmin_pmaSetup.sql
    155187
    156188CREATE USER 'pma'@'localhost' IDENTIFIED BY 'pmapass';
     
    173205}}}
    174206
    175 Then run this SQL to setup the pma 'controluser' (change the 'pmapass' to your password).
     207Then run this SQL to setup the pma 'controluser' .
     208{{{
     209-- mysql -u root -p < mysql_phpMyAdmin_pmaSetup.sql
     210}}}
    176211
    177212Finally, verify that the config file, at ''/opt/local/www/phpmyadmin/config.inc.php'', is like this:\\
     
    203238// $cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';       
    204239}}}
     240}}}
     241then make changes to that newly created php.ini file - ''/opt/local/etc/php56/php.ini''
     242
     243= Step 3: Install phpMyAdmin  = #phpmyadmin
     244
     245Use MacPorts to install the latest version of `phpMyAdmin`.
     246
     247{{{
     248$ sudo port install phpmyadmin
     249}}}
     250
     251'''phpMyAdmin''' must be configured before it can be used. We do this in Step 5 below.
     252
     253= Step 4: Visit [[howto/MAMP]] for integration information =
     254 [[howto/MAMP]] must be consulted next for modifications to the Apache Configuration file to enable PHP and MySQL.
     255
     256= Trouble shoot =
     257If by some reason the server still doesn't interpret PHP files (i.e. your web client tries to download them) it means the PHP configurations, as described at [[howto/MAMP#job1]], are not taking effect.
     258Typically,  the file ''"Include conf/extra/mod_php56.conf"'' - is not being processed; the file is missing; or the contents incorrect. That file contains the two "AddType" lines below.
     259
     260==  Verify your config file again! ==
     261Verify any changes you have made to the config file: /opt/local/apache2/conf/httpd.conf - The most common problem is that the files in the "extra" directory are not "readable"
     262All files in that directory should be "-rw-r--r--"
     263
     264{{{
     265$ /opt/local/apache2/bin/apachectl -t
     266}}}
     267This will return either "Syntax OK" or a specific line by line error listing.
     268 The typical error message:  ''"Could not open configuration file /opt/local/apache2/conf/extra/httpd-mod_php56.conf: Permission denied"''
     269After correcting any config errors and saving the updated config file, simply run:
     270{{{
     271$ sudo port unload apache2
     272}}}
     273
     274to stop apache (even though it is not running) and then start it using
     275
     276{{{
     277$ sudo port load apache2
     278}}}
     279
     280to start it again.
     281
     282If the above fails to cause php files to be interpreted, you can edit the Apache httpd.conf file itself again and search for the block:
     283{{{
     284<IfModule mime_module>
     285}}}
     286
     287And then add the following two lines before the end of that block.
     288
     289{{{
     290AddType application/x-httpd-php .php
     291AddType application/x-httpd-php-source .phps
     292}}}
     293
     294Then restart the server.
     295
     296As a last check, reboot and verify that everything has autostarted and is running (i.e., repeat the above tests).
     297
     298= Step 5: Configure phpMyAdmin =
     299
     300Edit the phpMyAdmin configuration file at ''/opt/local/www/phpmyadmin/config.inc.php''. \\
     301A sample configuration file is installed at /opt/local/www/phpmyadmin/config.sample.inc.php.
     302
     303Consult the documentation on your server at ''"/opt/local/www/phpmyadmin/doc/html/config.html"''
     304
     305NOTE: This option expects ''"/opt/local/www/phpmyadmin/doc/html"'' to be accessible under "<Document Root>." This can be accomplished by
     306{{{
     307$ cd <Document Root>
     308$ ln -s /opt/local/www/phpmyadmin/doc/html/ phpmyadmin-doc
     309}}}
     310and then accessing ''http://<servername>/phpmyadmin-doc/''
     311
     312Finally, you need to set up the `phpMyAdmin` configuration to access MySQL.
     313
     314First create the config.inc.php file:
     315{{{
     316$ cd /opt/local/www/phpmyadmin/
     317$ sudo cp config.sample.inc.php config.inc.php
     318}}}
     319
     320This will create a file `config.inc.php` in the `phpMyAdmin` directory. \\
     321Next, Edit that file, and locate the line:
     322{{{
     323$cfg['Servers'][$i]['auth_type']   = 'config';    // Authentication method (config, http or cookie based)? - default is Cookie.
     324}}}
     325It will be right at the beginning in the section labeled: "/* Authentication type */"
     326
     327You will need to add the following two lines immediately after it.
     328{{{
     329$cfg['Servers'][$i]['user']        = 'root';      // MySQL user
     330$cfg['Servers'][$i]['password']    = '';          // MySQL password (only needed with auth_type = 'config')
     331}}}
     332
     333Where ' ' is an empty password; fill it with your MySQL root password. \\
     334'''NOTE:''' You should change the 'auth_type' from 'config' to 'cookie' or 'httpd' so that you do not need to  provide the password you selected for the MySQL root user in the 'password' option.
     335(I.e. leaving it in plain text in this config file.) \\
     336However, as this is to simply get you "up-and-running," details for configuring those two authorization options are not given here.
     337Details on "Using Authentication Modes" can be found at "''https://docs.phpmyadmin.net/en/latest/setup.html#using-authentication-modes''."
     338
     339
     340There is also an interactive setup, see http://www.phpmyadmin.net/documentation/#setup_script and the demo at http://www.phpmyadmin.net/documentation/setup/
     341
     342To check your phpMyAdmin installation, point your browser to http://localhost/phpmyadmin and verify that phpMyAdmin loads and can access your database (by providing a username and password, depending on the authentication method you selected).
     343
     344
     345= Step 6: Install pmadb = #pmadb
     346Some consider the installation of pmadb "optional." \\
     347However, phpMyAdmin will flag the fact that it is missing and therefore certain features are not functional with the message:
     348{{{
     349The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. Find out why.
     350      Or alternately go to 'Operations' tab of any database to set it up there.
     351}}}
     352
     353For additional features provided by pmadb (http://wiki.phpmyadmin.net/pma/pmadb), run
     354{{{
     355$ mysql -u root -p < /opt/local/www/phpmyadmin/examples/create_tables.sql
     356}}}
     357
     358Next: create a file: ''mysql_phpMyAdmin_pmaSetup.sql'' - it is a one-time use scratch file so you can place it anywhere. (It is not included with the phpMyAdmin distribution.)
     359{{{
     360-- HOW TO USE THIS FILE (with MacPorts installation)
     361-- mysql -u root -p < /opt/local/www/phpmyadmin/examples/create_tables.sql
     362-- mysq5 -u root -p < mysql_phpMyAdmin_pmaSetup.sql
     363
     364CREATE USER 'pma'@'localhost' IDENTIFIED BY 'pmapass';
     365
     366GRANT USAGE ON mysql.* TO 'pma'@'localhost' IDENTIFIED BY 'pmapass';
     367GRANT SELECT (
     368    Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv,
     369    Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv,
     370    File_priv, Grant_priv, References_priv, Index_priv, Alter_priv,
     371    Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv,
     372    Execute_priv, Repl_slave_priv, Repl_client_priv
     373    ) ON mysql.user TO 'pma'@'localhost';
     374GRANT SELECT ON mysql.db TO 'pma'@'localhost';
     375GRANT SELECT ON mysql.host TO 'pma'@'localhost';
     376GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv)
     377    ON mysql.tables_priv TO 'pma'@'localhost';
     378
     379-- Privileges
     380GRANT SELECT, INSERT, DELETE, UPDATE ON `phpmyadmin`.* TO 'pma'@localhost;
     381}}}
     382
     383Then run this SQL to setup the pma 'controluser' (change the 'pmapass' to your password).
     384
     385Finally, verify that the config file, at ''/opt/local/www/phpmyadmin/config.inc.php'', is like this:\\
     386'''Note:''' The database name is ''pma underscore underscore'' -- two underscores!
     387{{{
     388/* User used to manipulate with storage */
     389// $cfg['Servers'][$i]['controlhost'] = '';                                                                                             
     390// $cfg['Servers'][$i]['controlport'] = '';   
     391$cfg['Servers'][$i]['controluser'] = 'pma';
     392$cfg['Servers'][$i]['controlpass'] = 'pmapass';
     393/* Storage database and tables */
     394// $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';                                                                                         
     395// $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';                                                                             
     396// $cfg['Servers'][$i]['relation'] = 'pma__relation';                                                                                   
     397// $cfg['Servers'][$i]['table_info'] = 'pma__table_info';                                                                               
     398// $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';                                                                           
     399// $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';                                                                                 
     400// $cfg['Servers'][$i]['column_info'] = 'pma__column_info';                                                                             
     401// $cfg['Servers'][$i]['history'] = 'pma__history';                                                                                     
     402// $cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';                                                                         
     403// $cfg['Servers'][$i]['tracking'] = 'pma__tracking';                                                                                   
     404// $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';                                                                               
     405// $cfg['Servers'][$i]['recent'] = 'pma__recent';                                                                                       
     406// $cfg['Servers'][$i]['favorite'] = 'pma__favorite';                                                                                   
     407// $cfg['Servers'][$i]['users'] = 'pma__users';                                                                                         
     408// $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';                                                                               
     409// $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';                                                                   
     410// $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';                                                                         
     411// $cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';       
     412}}}