[[PageOutline]] [wiki:howto <- Back to the HOWTO section] 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 For information on integration '''Apache''' with '''MySQL''' and '''PHP''', see:''' [[howto/MAMP]]''' = Step 1: Install PHP 56 = #install {{{ $ sudo port install php56-apache2handler $ sudo port install php56-mysql }}} '''''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. = Step 2: PHP Configuration file setup = Set up your PHP configuration files. For development purposes use: {{{ $ cd /opt/local/etc/php56 $ sudo cp php.ini-development php.ini }}} or for a production server: {{{ $ cd /opt/local/etc/php56 $ sudo cp php.ini-production php.ini[[PageOutline]] [wiki:howto <- Back to the HOWTO section] 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 For information on integration '''Apache''' with '''MySQL''' and '''PHP''', see:''' [[howto/MAMP]]''' = Step 1: Install PHP 56 = #install {{{ $ sudo port install php56-apache2handler $ sudo port install php56-mysql }}} '''''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. = Step 2: PHP Configuration file setup = Set up your PHP configuration files. For development purposes use: {{{ $ cd /opt/local/etc/php56 $ sudo cp php.ini-development php.ini }}} or for a production server: {{{ $ cd /opt/local/etc/php56 $ sudo cp php.ini-production php.ini }}} then make changes to that newly created php.ini file - ''/opt/local/etc/php56/php.ini'' = Step 3: Install phpMyAdmin = #phpmyadmin Use MacPorts to install the latest version of `phpMyAdmin`. {{{ $ sudo port install phpmyadmin }}} '''phpMyAdmin''' must be configured before it can be used. We do this in Step 5 below. = Step 4: Visit [[howto/MAMP]] for integration information = [[howto/MAMP]] must be consulted next for modifications to the Apache Configuration file to enable PHP and MySQL. = Trouble shoot = If 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. Typically, 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. == Verify your config file again! == Verify 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" All files in that directory should be "-rw-r--r--" {{{ $ /opt/local/apache2/bin/apachectl -t }}} This will return either "Syntax OK" or a specific line by line error listing. The typical error message: ''"Could not open configuration file /opt/local/apache2/conf/extra/httpd-mod_php56.conf: Permission denied"'' After correcting any config errors and saving the updated config file, simply run: {{{ $ sudo port unload apache2 }}} to stop apache (even though it is not running) and then start it using {{{ $ sudo port load apache2 }}} to start it again. If 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: {{{ }}} And then add the following two lines before the end of that block. {{{ AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps }}} Then restart the server. As a last check, reboot and verify that everything has autostarted and is running (i.e., repeat the above tests). = Step 5: Configure phpMyAdmin = Edit the phpMyAdmin configuration file at ''/opt/local/www/phpmyadmin/config.inc.php''. \\ A sample configuration file is installed at /opt/local/www/phpmyadmin/config.sample.inc.php. Consult the documentation on your server at ''"/opt/local/www/phpmyadmin/doc/html/config.html"'' NOTE: This option expects ''"/opt/local/www/phpmyadmin/doc/html"'' to be accessible under "." This can be accomplished by {{{ $ cd $ ln -s /opt/local/www/phpmyadmin/doc/html/ phpmyadmin-doc }}} and then accessing ''http:///phpmyadmin-doc/'' Finally, you need to set up the `phpMyAdmin` configuration to access MySQL. First create the config.inc.php file: {{{ $ cd /opt/local/www/phpmyadmin/ $ sudo cp config.sample.inc.php config.inc.php }}} This will create a file `config.inc.php` in the `phpMyAdmin` directory. \\ Next, Edit that file, and locate the line: {{{ $cfg['Servers'][$i]['auth_type'] = 'config'; // Authentication method (config, http or cookie based)? - default is Cookie. }}} It will be right at the beginning in the section labeled: "/* Authentication type */" You will need to add the following two lines immediately after it. {{{ $cfg['Servers'][$i]['user'] = 'root'; // MySQL user $cfg['Servers'][$i]['password'] = ''; // MySQL password (only needed with auth_type = 'config') }}} Where ' ' is an empty password; fill it with your MySQL root password. \\ '''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. (I.e. leaving it in plain text in this config file.) \\ However, as this is to simply get you "up-and-running," details for configuring those two authorization options are not given here. Details on "Using Authentication Modes" can be found at "''https://docs.phpmyadmin.net/en/latest/setup.html#using-authentication-modes''." There is also an interactive setup, see http://www.phpmyadmin.net/documentation/#setup_script and the demo at http://www.phpmyadmin.net/documentation/setup/ 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). = Step 6: Install pmadb = #pmadb Some consider the installation of pmadb "optional." \\ However, phpMyAdmin will flag the fact that it is missing and therefore certain features not functional, with the message: {{{ The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. Find out why. Or alternately go to 'Operations' tab of any database to set it up there. }}} For additional features provided by pmadb (http://wiki.phpmyadmin.net/pma/pmadb), first run {{{ $ mysql -u root -p < /opt/local/www/phpmyadmin/examples/create_tables.sql }}} Next: create a file ''"mysql_phpMyAdmin_pmaSetup.sql"'' - containing the following SQL code: (change the 'pmapass' to your password)\\ - 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.) {{{ -- HOW TO USE THIS FILE (with MacPorts installation) -- mysql -u root -p < /opt/local/www/phpmyadmin/examples/create_tables.sql -- mysql -u root -p < mysql_phpMyAdmin_pmaSetup.sql CREATE USER 'pma'@'localhost' IDENTIFIED BY 'pmapass'; GRANT USAGE ON mysql.* TO 'pma'@'localhost' IDENTIFIED BY 'pmapass'; GRANT SELECT ( Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv, Repl_client_priv ) ON mysql.user TO 'pma'@'localhost'; GRANT SELECT ON mysql.db TO 'pma'@'localhost'; GRANT SELECT ON mysql.host TO 'pma'@'localhost'; GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv) ON mysql.tables_priv TO 'pma'@'localhost'; -- Privileges GRANT SELECT, INSERT, DELETE, UPDATE ON `phpmyadmin`.* TO 'pma'@localhost; }}} Then run this SQL to setup the pma 'controluser' . {{{ -- mysql -u root -p < mysql_phpMyAdmin_pmaSetup.sql }}} Finally, verify that the config file, at ''/opt/local/www/phpmyadmin/config.inc.php'', is like this:\\ '''Note:''' The database name is ''pma underscore underscore'' -- two underscores! {{{ /* User used to manipulate with storage */ // $cfg['Servers'][$i]['controlhost'] = ''; // $cfg['Servers'][$i]['controlport'] = ''; $cfg['Servers'][$i]['controluser'] = 'pma'; $cfg['Servers'][$i]['controlpass'] = 'pmapass'; /* Storage database and tables */ // $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin'; // $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark'; // $cfg['Servers'][$i]['relation'] = 'pma__relation'; // $cfg['Servers'][$i]['table_info'] = 'pma__table_info'; // $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords'; // $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages'; // $cfg['Servers'][$i]['column_info'] = 'pma__column_info'; // $cfg['Servers'][$i]['history'] = 'pma__history'; // $cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs'; // $cfg['Servers'][$i]['tracking'] = 'pma__tracking'; // $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig'; // $cfg['Servers'][$i]['recent'] = 'pma__recent'; // $cfg['Servers'][$i]['favorite'] = 'pma__favorite'; // $cfg['Servers'][$i]['users'] = 'pma__users'; // $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups'; // $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding'; // $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches'; // $cfg['Servers'][$i]['central_columns'] = 'pma__central_columns'; }}} }}} then make changes to that newly created php.ini file - ''/opt/local/etc/php56/php.ini'' = Step 3: Install phpMyAdmin = #phpmyadmin Use MacPorts to install the latest version of `phpMyAdmin`. {{{ $ sudo port install phpmyadmin }}} '''phpMyAdmin''' must be configured before it can be used. We do this in Step 5 below. = Step 4: Visit [[howto/MAMP]] for integration information = [[howto/MAMP]] must be consulted next for modifications to the Apache Configuration file to enable PHP and MySQL. = Trouble shoot = If 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. Typically, 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. == Verify your config file again! == Verify 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" All files in that directory should be "-rw-r--r--" {{{ $ /opt/local/apache2/bin/apachectl -t }}} This will return either "Syntax OK" or a specific line by line error listing. The typical error message: ''"Could not open configuration file /opt/local/apache2/conf/extra/httpd-mod_php56.conf: Permission denied"'' After correcting any config errors and saving the updated config file, simply run: {{{ $ sudo port unload apache2 }}} to stop apache (even though it is not running) and then start it using {{{ $ sudo port load apache2 }}} to start it again. If 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: {{{ }}} And then add the following two lines before the end of that block. {{{ AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps }}} Then restart the server. As a last check, reboot and verify that everything has autostarted and is running (i.e., repeat the above tests). = Step 5: Configure phpMyAdmin = Edit the phpMyAdmin configuration file at ''/opt/local/www/phpmyadmin/config.inc.php''. \\ A sample configuration file is installed at /opt/local/www/phpmyadmin/config.sample.inc.php. Consult the documentation on your server at ''"/opt/local/www/phpmyadmin/doc/html/config.html"'' NOTE: This option expects ''"/opt/local/www/phpmyadmin/doc/html"'' to be accessible under "." This can be accomplished by {{{ $ cd $ ln -s /opt/local/www/phpmyadmin/doc/html/ phpmyadmin-doc }}} and then accessing ''http:///phpmyadmin-doc/'' Finally, you need to set up the `phpMyAdmin` configuration to access MySQL. First create the config.inc.php file: {{{ $ cd /opt/local/www/phpmyadmin/ $ sudo cp config.sample.inc.php config.inc.php }}} This will create a file `config.inc.php` in the `phpMyAdmin` directory. \\ Next, Edit that file, and locate the line: {{{ $cfg['Servers'][$i]['auth_type'] = 'config'; // Authentication method (config, http or cookie based)? - default is Cookie. }}} It will be right at the beginning in the section labeled: "/* Authentication type */" You will need to add the following two lines immediately after it. {{{ $cfg['Servers'][$i]['user'] = 'root'; // MySQL user $cfg['Servers'][$i]['password'] = ''; // MySQL password (only needed with auth_type = 'config') }}} Where ' ' is an empty password; fill it with your MySQL root password. \\ '''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. (I.e. leaving it in plain text in this config file.) \\ However, as this is to simply get you "up-and-running," details for configuring those two authorization options are not given here. Details on "Using Authentication Modes" can be found at "''https://docs.phpmyadmin.net/en/latest/setup.html#using-authentication-modes''." There is also an interactive setup, see http://www.phpmyadmin.net/documentation/#setup_script and the demo at http://www.phpmyadmin.net/documentation/setup/ 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). = Step 6: Install pmadb = #pmadb Some consider the installation of pmadb "optional." \\ However, phpMyAdmin will flag the fact that it is missing and therefore certain features are not functional with the message: {{{ The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. Find out why. Or alternately go to 'Operations' tab of any database to set it up there. }}} For additional features provided by pmadb (http://wiki.phpmyadmin.net/pma/pmadb), run {{{ $ mysql -u root -p < /opt/local/www/phpmyadmin/examples/create_tables.sql }}} 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.) {{{ -- HOW TO USE THIS FILE (with MacPorts installation) -- mysql -u root -p < /opt/local/www/phpmyadmin/examples/create_tables.sql -- mysq5 -u root -p < mysql_phpMyAdmin_pmaSetup.sql CREATE USER 'pma'@'localhost' IDENTIFIED BY 'pmapass'; GRANT USAGE ON mysql.* TO 'pma'@'localhost' IDENTIFIED BY 'pmapass'; GRANT SELECT ( Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv, Repl_client_priv ) ON mysql.user TO 'pma'@'localhost'; GRANT SELECT ON mysql.db TO 'pma'@'localhost'; GRANT SELECT ON mysql.host TO 'pma'@'localhost'; GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv) ON mysql.tables_priv TO 'pma'@'localhost'; -- Privileges GRANT SELECT, INSERT, DELETE, UPDATE ON `phpmyadmin`.* TO 'pma'@localhost; }}} Then run this SQL to setup the pma 'controluser' (change the 'pmapass' to your password). Finally, verify that the config file, at ''/opt/local/www/phpmyadmin/config.inc.php'', is like this:\\ '''Note:''' The database name is ''pma underscore underscore'' -- two underscores! {{{ /* User used to manipulate with storage */ // $cfg['Servers'][$i]['controlhost'] = ''; // $cfg['Servers'][$i]['controlport'] = ''; $cfg['Servers'][$i]['controluser'] = 'pma'; $cfg['Servers'][$i]['controlpass'] = 'pmapass'; /* Storage database and tables */ // $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin'; // $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark'; // $cfg['Servers'][$i]['relation'] = 'pma__relation'; // $cfg['Servers'][$i]['table_info'] = 'pma__table_info'; // $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords'; // $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages'; // $cfg['Servers'][$i]['column_info'] = 'pma__column_info'; // $cfg['Servers'][$i]['history'] = 'pma__history'; // $cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs'; // $cfg['Servers'][$i]['tracking'] = 'pma__tracking'; // $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig'; // $cfg['Servers'][$i]['recent'] = 'pma__recent'; // $cfg['Servers'][$i]['favorite'] = 'pma__favorite'; // $cfg['Servers'][$i]['users'] = 'pma__users'; // $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups'; // $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding'; // $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches'; // $cfg['Servers'][$i]['central_columns'] = 'pma__central_columns'; }}}