Changes between Initial Version and Version 1 of howto/PHP


Ignore:
Timestamp:
Dec 29, 2014, 8:44:43 PM (10 years ago)
Author:
larryv (Lawrence Velázquez)
Comment:

move contents of "howto/PhP"

Legend:

Unmodified
Added
Removed
Modified
  • howto/PHP

    v1 v1  
     1[[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 = #php
     11
     12{{{
     13sudo port install php56-apache2handler
     14sudo 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{{{
     25cd /opt/local/etc/php56
     26sudo cp php.ini-development php.ini
     27}}}
     28or for a production server:
     29{{{
     30cd /opt/local/etc/php56
     31sudo cp php.ini-production php.ini
     32}}}
     33then make changes to that newly created php.ini file - ''/opt/local/etc/php56/php.ini''
     34
     35= Step 3: Install phpMyAdmin  = #phpmyadmin
     36
     37Use MacPorts to install the latest version of `phpMyAdmin`.
     38
     39{{{
     40sudo port install phpmyadmin
     41}}}
     42
     43'''phpMyAdmin''' must be configured before it can be used. We do this in Step 5 below.
     44
     45= Step 4: Visit [[howto/MAMP]] for integration information =
     46 [[howto/MAMP]] must be consulted next for modifications to the Apache Configuration file to enable PhP and MySQL.
     47
     48= Trouble shoot =
     49If by some reason the server still doesn't interpret PHP files (your web client tries to download them) it means the PHP configurations, as described above, are not taking effect and in that case you should open the Apache httpd.conf file once again and search for the block
     50
     51{{{
     52<IfModule mime_module>
     53}}}
     54
     55And then add before the end
     56
     57{{{
     58AddType application/x-httpd-php .php
     59AddType application/x-httpd-php-source .phps
     60}}}
     61
     62Then restart the server.
     63
     64As a last check, reboot and verify that everything has autostarted and is running (i.e., repeat the above tests).
     65
     66= Step 5: Configure phpMyAdmin =
     67
     68Edit the PhpMyAdmin configuration file at ''/opt/local/www/phpmyadmin/config.inc.php''. \\
     69A sample configuration file is installed at /opt/local/www/phpmyadmin/config.sample.inc.php.
     70
     71Consult the documentation at file:///opt/local/www/phpmyadmin/doc/html/config.html \\
     72Note that this file will not be accessible to your browser until it is linked in to your Document root.
     73
     74Finally, you need to set up the `phpMyAdmin` configuration to access mySQL.
     75
     76First create the config.inc.php file:
     77{{{
     78cd /opt/local/www/phpmyadmin/
     79sudo cp config.sample.inc.php config.inc.php
     80}}}
     81
     82This will create a file `config.inc.php` in the `phpMyAdmin` directory. Edit that file, and locate the lines:
     83
     84{{{
     85$cfg['Servers'][$i]['auth_type']      = 'config';    // Authentication method (config, http or cookie based)? - default is Cookie.
     86$cfg['Servers'][$i]['user']              = 'root';      // MySQL user
     87$cfg['Servers'][$i]['password']      = '';          // MySQL password (only needed
     88                                                    // with 'config' auth_type)
     89}}}
     90
     91Where ' ' is an empty password; fill it with your MySQL root password. You can either change the 'auth_type' from 'config' to 'cookie' or 'httpd', or alternatively provide the password you selected for the root user in the 'password' option.
     92
     93There is also an interactive setup, see http://www.phpmyadmin.net/documentation/#setup_script and the demo at http://www.phpmyadmin.net/documentation/setup/
     94
     95To 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).
     96
     97
     98= Optional pmadb = #phpMyAdmin_pmadb
     99
     100For additional features provided by pmadb (http://wiki.phpmyadmin.net/pma/pmadb), run
     101{{{
     102mysql5 -u root -p < /opt/local/www/phpmyadmin/examples/create_tables.sql
     103}}}
     104
     105Then run this SQL to setup the pma 'controluser' (change the 'pmapass' to your password).
     106{{{
     107-- HOW TO USE THIS FILE (with MacPorts installation)
     108-- mysql5 -u root -p < /opt/local/www/phpmyadmin/examples/create_tables.sql
     109-- mysql5 -u root -p < mysql_phpMyAdmin_pmaSetup.sql
     110
     111CREATE USER 'pma'@'localhost' IDENTIFIED BY 'pmapass';
     112
     113GRANT USAGE ON mysql.* TO 'pma'@'localhost' IDENTIFIED BY 'pmapass';
     114GRANT SELECT (
     115    Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv,
     116    Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv,
     117    File_priv, Grant_priv, References_priv, Index_priv, Alter_priv,
     118    Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv,
     119    Execute_priv, Repl_slave_priv, Repl_client_priv
     120    ) ON mysql.user TO 'pma'@'localhost';
     121GRANT SELECT ON mysql.db TO 'pma'@'localhost';
     122GRANT SELECT ON mysql.host TO 'pma'@'localhost';
     123GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv)
     124    ON mysql.tables_priv TO 'pma'@'localhost';
     125
     126-- Privileges
     127GRANT SELECT, INSERT, DELETE, UPDATE ON `phpmyadmin`.* TO 'pma'@localhost;
     128}}}
     129
     130Finally, edit the config file, at {{{/opt/local/www/phpmyadmin/config.inc.php}}}, so it's like this:
     131{{{
     132/* User for advanced features */
     133$cfg['Servers'][$i]['controluser'] = 'pma';
     134$cfg['Servers'][$i]['controlpass'] = 'pmapass';
     135/* Advanced phpMyAdmin features */
     136$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
     137$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
     138$cfg['Servers'][$i]['relation'] = 'pma__relation';
     139$cfg['Servers'][$i]['table_info'] = 'pma__table_info';
     140$cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
     141$cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
     142$cfg['Servers'][$i]['column_info'] = 'pma__column_info';
     143$cfg['Servers'][$i]['history'] = 'pma__history';
     144$cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
     145}}}