Changes between Version 1 and Version 2 of howto/MAMP


Ignore:
Timestamp:
May 31, 2008, 10:09:19 PM (16 years ago)
Author:
jaguarcy+macports@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • howto/MAMP

    v1 v2  
    8686Restart Apache ({{{sudo /opt/local/apache2/bin/apachectl -k restart}}}) and verify that everything's running. You should now be able to go to http://localhost/manual/ to access the manual, and you should be able to access your personal user web site at http://localhost/~username/, where "username" is your login id.
    8787
     88  '''''Note:''''' When you upgrade your Apache installation (e.g., `sudo port upgrade apache2`), be aware that the upgrade will not affect your `http.conf` file, but '''it will overwrite the other configuration files''', such as the `httpd-userdir.conf` file. Therefore, if you've made any changes to those files (e.g., activating User web pages), you will need to save your `httpd-userdir.conf` file before upgrading and then reapply your changes after the upgrade. However, it would probably be a good idea to save your `http.conf` file too, just to be safe.
     89
     90=== Step 3: Install MySQL ===
     91
     92{{{
     93sudo port install mysql5 +server
     94}}}
     95
     96Activate your MySQL server installation so that it autostarts when you boot your machine:
     97
     98{{{
     99sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
     100}}}
     101
     102Set up the main database
     103
     104{{{
     105sudo mysql5 mysql_install_db5
     106sudo chown -R mysql:mysql /opt/local/var/db/mysql5/
     107sudo chown -R mysql:mysql /opt/local/var/run/mysqld5/
     108sudo chown -R mysql:mysql /opt/local/var/log/mysql5/
     109}}}
     110
     111  ''If that doesn't work try this:''
     112  {{{
     113sudo mysql_install_db5
     114sudo chown -R mysql:mysql /opt/local/var/db/mysql5/
     115sudo chown -R mysql:mysql /opt/local/var/run/mysqld5/
     116  }}}
     117
     118Start the MySQL daemon
     119
     120{{{
     121sudo /opt/local/bin/mysqld_safe5 &
     122}}}
     123
     124and then verify that it's running
     125
     126{{{
     127ps –ax | grep mysql
     128}}}
     129
     130Set the MySQL `root` password (it's currently empty)
     131
     132{{{
     133mysqladmin5 –u root –p password <new-password>
     134}}}
     135
     136where `<new-password>` is your new desired root password.
     137
     138Test everything by logging in to the server.
     139
     140{{{
     141mysql5 -u root -p
     142}}}
     143
     144Once you're logged in, simply exit the session
     145
     146{{{
     147mysql> exit
     148}}}
     149
     150As a last test, reboot your machine and then run
     151
     152{{{
     153ps –ax | grep mysql
     154}}}
     155
     156again to verify that the daemon is still active.
     157
     158=== Step 4: Install PHP ===
     159
     160'''Note: Currently, the PHP5 installer uses wget to install the PEAR environment, but the installer does not list wget as a dependent component. So, the installation will fail during the staging operations if you do not manually install wget first.'''
     161
     162{{{
     163sudo port install wget
     164sudo port install php5 +apache2 +mysql5
     165}}}
     166
     167Register PHP with Apache
     168
     169{{{
     170cd /opt/local/apache2/modules
     171sudo /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so
     172}}}
     173
     174Update Apache's `httpd.conf` file to enhance the "DirectoryIndex" directive to include additional "index" files:
     175
     176{{{
     177DirectoryIndex index.html index.cgi index.php
     178}}}
     179
     180Also, at the end of the `httpd.conf` file, add the following lines so that Apache includes the mod_php "AddType" configurations
     181
     182{{{
     183#
     184# Include PHP configurations
     185#
     186Include conf/extras-conf/mod_php.conf
     187}}}
     188
     189You may also need to load the PHP module '''before''' including `mod_php.conf` as described above:
     190
     191{{{
     192# Load the PHP module
     193LoadModule php5_module modules/libphp5.so
     194}}}
     195
     196Set up your PHP configuration files
     197
     198{{{
     199cd /opt/local/etc
     200sudo cp php.ini-dist php.ini
     201sudo cp pear.conf.sample pear.conf
     202}}}
     203
     204Restart Apache so that your changes take effect
     205
     206{{{
     207cd /opt/local/apache2/bin/
     208sudo ./apachectl -k restart
     209}}}
     210
     211Create a file named `phpinfo.php` that contains the following three lines
     212
     213{{{
     214!#php
     215<?php
     216phpinfo();
     217?>
     218}}}
     219
     220and place it in your Apache "`DocumentRoot`" directory (should be "`/opt/local/apache2/htdocs`") or your own user "`Sites`" directory if you activated user directories as specified above. Point your browser to http://localhost/phpinfo.php (or http://localhost/~username/phpinfo.php if applicable) and verify that the correct version of PHP is active (v5.2.6 as of this writing) and that MySQL support is active (you may want to search the page for "`mysql`").
     221
     222As a last check, reboot and verify that everything has autostarted and is running (i.e., repeat the above tests).
     223
     224=== Step 5: Install phpMyAdmin (optional) ===
     225
     226Use MacPorts to install the latest version of `phpMyAdmin`.
     227
     228{{{
     229sudo port install phpmyadmin
     230}}}
     231
     232Update Apache's `httpd.conf` file to find `phpmyadmin`. First add the following lines to the end of the file:
     233
     234{{{
     235# Local access to phpmyadmin installation
     236Include conf/extra/httpd-phpmyadmin.conf
     237}}}
     238
     239and then create a file `/opt/local/apache2/conf/extra/httpd-phpmyadmin.conf` containing this text:
     240
     241{{{
     242AliasMatch ^/phpmyadmin(?:/)?(/.*)?$ "/opt/local/www/data/phpmyadmin$1"
     243
     244<Directory "/opt/local/www/data/phpmyadmin">
     245  Options -Indexes
     246  AllowOverride None
     247  Order allow,deny
     248  Allow from all
     249 
     250  LanguagePriority en de es fr ja ko pt-br ru
     251  ForceLanguagePriority Prefer Fallback
     252</Directory>
     253}}}
     254
     255Finally, you need to set up the `phpMyAdmin` configuration to access mySQL. First, set up the config file:
     256
     257{{{
     258cd /opt/local/www/data/phpmyadmin/
     259cp libraries/config.default.php ./config.inc.php
     260}}}
     261
     262This will create a file `config.inc.php` in the `phpMyAdmin` folder. Edit that file, and locate the lines:
     263
     264{{{
     265$cfg['Servers'][$i]['auth_type']     = 'config';    // Authentication method (config, http or cookie based)?
     266$cfg['Servers'][$i]['user']          = 'root';      // MySQL user
     267$cfg['Servers'][$i]['password']      = ;            // MySQL password (only needed
     268                                                    // with 'config' auth_type)
     269}}}
     270
     271You 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.
     272
     273To check your phpMyAdmin installation, point your browser to http://localhost/phpmyadmin (or http://localhost/~username/phpmyadmin if applicable) and verify that phpMyAdmin loads and can access your database (by providing a username and password, depending on the authentication method you selected).
     274
    88275[wiki:howto <- Back to the HOWTO section]