Showing posts with label OS X. Show all posts
Showing posts with label OS X. Show all posts

Friday, 1 March 2013

MacPorts - PHP, Apache & MySQL

Hi,

These some tutorials how to install lamp server using MarPorts:
  1. Install MacPorts:
    1. Install Xcode
    2. Launch Xcode > Preferences > Downloads > Install 'Command Line Tools'
    3. Go to MacPorts website and follow their structure to install MacPorts: http://www.macports.org/install.php
  2. Install PHP & Apache:
    1. sudo port install php5 +apache2 +mcrypt +curl +tidy +pear
    2. sudo port load apache2
    3. cd /opt/local/apache2/modules
    4. sudo /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so
    5. sudo cp /opt/local/etc/php5/php.ini-development /opt/local/etc/php5/php.ini
    6. sudo nano /opt/local/apache2/conf/httpd.conf
      1. Go to line 119 (In Nano: CTRL+w then CTRL+t and write 119), and enter the following lines:
        • AddType application/x-httpd-php .php
        • AddType application/x-httpd-php-source .phps
    7. Now, change DocumentRoot from:
      1. From: DocumentRoot "/opt/local/apache2/htdocs"
      2. To: DocumentRoot "/Users/Shin/sites"
    8. Since we just change the documentRoot folder, we need to adjust some more settings
      1. From: <Directory “/opt/local/apache2/htdocs”>
      2. To: <Directory “/Users/Shin/Sites”>
    9. Now all we have left to do is setting the User and Group. Exchange the following:
      1. From:
        • User www
        • Group www
      2. To:
        • User Shin
        • Group staff
    10. sudo /opt/local/apache2/bin/apachectl restart
  3. Install MySQL:
    1. sudo port install mysql5 +server
    2. sudo -u mysql mysql_install_db5
    3. sudo chown -R mysql:mysql /opt/local/var/db/mysql5/
    4. sudo chown -R mysql:mysql /opt/local/var/run/mysql5/
    5. sudo chown -R mysql:mysql /opt/local/var/log/mysql5/
      • If that doesn’t work try this:
        • sudo mysql_install_db5 sudo chown -R mysql:mysql /opt/local/var/db/mysql5/
        • sudo chown -R mysql:mysql /opt/local/var/run/mysql5/
    6. sudo port load mysql5-server
    7. sudo ln -s /opt/local/bin/mysql5 /opt/local/bin/mysql
    8. sudo ln -s /opt/local/bin/mysqladmin5 /opt/local/bin/mysqladmin
    9. Change new root password:
      • mysqladmin5 -u root password 'new-password'
  4. Some small bugs:
    1. httpd: Could not reliably determine the server's fully qualified domain name, using <Computer-Name>.local for ServerName
      1. sudo vim /opt/local/apache2/conf/httpd.conf
        • ServerName localhost:80
    2. If you would like to be able to access web pages in the Sites directory of your home directory
      1. sudo vim /opt/local/apache2/conf/httpd.conf
        • Include conf/extra/httpd-userdir.conf
    3. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
      1. sudo vim /opt/local/etc/mysql5/my.cnf
        • [mysqld_safe]
        • socket = /tmp/mysql.sock
        • [client]
        • socket = /tmp/mysql.sock
      2. sudo vim /opt/local/etc/php5/php.ini 
        • mysqli.default_socket = "/tmp/mysql.sock"
Good luck!

Friday, 14 October 2011

PHP, Apache & MySQL

Hi,

There are some tutorials active Webserver environment:
  1. Apache:
    1. Root folder: /Library/WebServer/Documents/
    2. Start: sudo apachectl start
    3. Stop: sudo apachectl stop
    4. Restart: sudo apachectl graceful
  2. PHP:
    1. Install:
      1. cd /etc && sudo cp php.ini.default php.ini
      2. sudo vim httpd.conf
      3. Uncomment out the hash # to leave it like:
        • LoadModule php5_module libexec/apache2/libphp5.so
      4. Restart Apache
    2. Warning: date_default_timezone_get():
      • sudo vim /private/etc/php.ini
      • date.timezone = "UTC"
    3. autoconf:
      1. Install:
        • Install Xcode
        • Launch Xcode > Preferences > Downloads > Install 'Command Line Tools'
      2. Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script.
        • curl -O http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
        • tar xvfz autoconf-latest.tar.gz
        • cd autoconf-2.69/
        • ./configure
        • make
        • sudo make install
    4. Missing extension:
      • http://www.coolestguyplanettech.com/how-to-install-mcrypt-for-php-on-mac-osx-lion-10-7-development-server/
      • Download the PHP's source code. You'll need to download the one that matches the version already installed on your system. To find out which one you're using, type php -v from the command line.
      • Extract the archive you downloaded using tar -zxvf followed by the filename. Type cd php-5.4.x/ext/sqlite3/ (where "5.4.x" should be replaced with your version number and "sqlite3" can be any of the modules you want to install from your list above minus the "php_" prefix)
      • Type phpize
      • Type ./configure
      • Type make
      • Type sudo make install
      • Find shared extenstions folder:
        • E.G.: /usr/lib/php/extensions/no-debug-non-zts-20090626/
      • Add extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20090626" to your php.ini
      • Add extension=sqlite3.so to your php.ini (again make sure to replace sqlite3.so with the name of the other extensions if you compile the others).
      • Restart Apache
    5. Or you can try this tutorials:
      • http://php-osx.liip.ch/
  3. MySQL:
    1. Install:
      • Go to: http://dev.mysql.com/downloads/mysql/
      • Download DMG file for your current operation: Mac OS X ver. 10.6 (x86, 64-bit), DMG Archive
      • Open the downloaded file and double click the file called mysql-x.x.xx-osx10.x-x86_64.pkg and continue through the installation
        • App can’t be opened because it is from an unidentified developer: http://osxdaily.com/2012/07/27/app-cant-be-opened-because-it-is-from-an-unidentified-developer/
      • Installation: MySQL.prefPane, MySQLStartupItem.pkg
    2. Enable command line:
      • sudo vim /etc/paths
      • Appended the line:
        • /usr/local/mysql/bin
      • Restart OS
    3. Missing /var/mysql/mysql.sock file:
      • Check it at:
        • /private/tmp/mysql.sock
        • /tmp/mysql.sock
        • /usr/local/mysql/run/mysql_socket
      • Try create symbolic link for: /var/mysql/mysql.sock
        • sudo ln -s /private/tmp/mysql.sock /var/mysql/mysql.sock
        • sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
        • sudo ln -s /usr/local/mysql/run/mysql_socket /var/mysql/mysql.sock
    4. Reference:
      • http://blog.mclaughlinsoftware.com/2011/02/10/mac-os-x-mysql-install/
Good luck!