| 1 | [[PageOutline]] |
| 2 | |
| 3 | [wiki:howto <- Back to the HOWTO section] |
| 4 | |
| 5 | This 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 | |
| 7 | For information on integration '''Apache''' with '''MySql''' and '''PhP''', see:''' [[howto/MAMP]]''' |
| 8 | |
| 9 | |
| 10 | = Step 1: Install PHP 56 = #php |
| 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 | |
| 23 | Set 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 | }}} |
| 28 | or for a production server: |
| 29 | {{{ |
| 30 | cd /opt/local/etc/php56 |
| 31 | sudo cp php.ini-production php.ini |
| 32 | }}} |
| 33 | then make changes to that newly created php.ini file - ''/opt/local/etc/php56/php.ini'' |
| 34 | |
| 35 | = Step 3: Install phpMyAdmin = #phpmyadmin |
| 36 | |
| 37 | Use MacPorts to install the latest version of `phpMyAdmin`. |
| 38 | |
| 39 | {{{ |
| 40 | sudo 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 = |
| 49 | If 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 | |
| 55 | And then add before the end |
| 56 | |
| 57 | {{{ |
| 58 | AddType application/x-httpd-php .php |
| 59 | AddType application/x-httpd-php-source .phps |
| 60 | }}} |
| 61 | |
| 62 | Then restart the server. |
| 63 | |
| 64 | As 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 | |
| 68 | Edit the PhpMyAdmin configuration file at ''/opt/local/www/phpmyadmin/config.inc.php''. \\ |
| 69 | A sample configuration file is installed at /opt/local/www/phpmyadmin/config.sample.inc.php. |
| 70 | |
| 71 | Consult the documentation at file:///opt/local/www/phpmyadmin/doc/html/config.html \\ |
| 72 | Note that this file will not be accessible to your browser until it is linked in to your Document root. |
| 73 | |
| 74 | Finally, you need to set up the `phpMyAdmin` configuration to access mySQL. |
| 75 | |
| 76 | First create the config.inc.php file: |
| 77 | {{{ |
| 78 | cd /opt/local/www/phpmyadmin/ |
| 79 | sudo cp config.sample.inc.php config.inc.php |
| 80 | }}} |
| 81 | |
| 82 | This 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 | |
| 91 | Where ' ' 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 | |
| 93 | There is also an interactive setup, see http://www.phpmyadmin.net/documentation/#setup_script and the demo at http://www.phpmyadmin.net/documentation/setup/ |
| 94 | |
| 95 | To 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 | |
| 100 | For additional features provided by pmadb (http://wiki.phpmyadmin.net/pma/pmadb), run |
| 101 | {{{ |
| 102 | mysql5 -u root -p < /opt/local/www/phpmyadmin/examples/create_tables.sql |
| 103 | }}} |
| 104 | |
| 105 | Then 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 | |
| 111 | CREATE USER 'pma'@'localhost' IDENTIFIED BY 'pmapass'; |
| 112 | |
| 113 | GRANT USAGE ON mysql.* TO 'pma'@'localhost' IDENTIFIED BY 'pmapass'; |
| 114 | GRANT 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'; |
| 121 | GRANT SELECT ON mysql.db TO 'pma'@'localhost'; |
| 122 | GRANT SELECT ON mysql.host TO 'pma'@'localhost'; |
| 123 | GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv) |
| 124 | ON mysql.tables_priv TO 'pma'@'localhost'; |
| 125 | |
| 126 | -- Privileges |
| 127 | GRANT SELECT, INSERT, DELETE, UPDATE ON `phpmyadmin`.* TO 'pma'@localhost; |
| 128 | }}} |
| 129 | |
| 130 | Finally, 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 | }}} |