SOURCE: http://todsul.com/lamp-mac-os-x-lion
Another instructions: http://coolestguyplanettech.com/downtown/install-and-configure-apache-mysql-php-and-phpmyadmin-osx-108-mountain-lion
1. Configure Apache
Use vi to configure the httpd.conf file.
sudo vi /etc/apache2/httpd.conf
Enable PHP and virtual hosts by uncommenting these lines:
LoadModule php5_module libexec/apache2/libphp5.so Include /private/etc/apache2/extra/httpd-vhosts.conf Include /private/etc/apache2/extra/httpd-ssl.conf
Give your user permissions.
sudo vi /etc/apache2/users/[username].conf
<Directory />
Options FollowSymLinks Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
2. Install & Configure Git
Download the latest verion of Git for Mac here.
reboot git config --global user.name 'username' git config --global user.email 'email'
Initialize the Git directory and pull the latest code.
cd /path/to/website git init git remote add origin https://github.com/path/to/repo.git git pull origin master
Use the OSX Keychain to save the password.
curl -s -O http://github-media-downloads.s3.amazonaws.com/osx/git-credential-osxkeychain chmod u+x git-credential-osxkeychain which git sudo mv git-credential-osxkeychain /usr/local/git/bin/ git config --global credential.helper osxkeychain
3. Configure Virtual Hosts
sudo vi /etc/hosts
Add a virtual hostname for each website.
127.0.0.1 [example].localhost
Configure directories and logs for apache.
sudo vi /etc/apache2/extra/httpd-vhosts.conf
Configure HTTP virtual hosts.
<VirtualHost *:80>
DocumentRoot "/path/to/web/folder"
ServerName [example].localhost
</VirtualHost>
4. Setup Self-Signed SSL Certificate
cd /etc/apache2 sudo ssh-keygen -f server.key sudo openssl req -new -key server.key -out request.csr sudo openssl x509 -req -days 365 -in request.csr -signkey server.key -out server.crt sudo openssl rsa -in server.key -out server.nopass.key sudo vi /etc/apache2/extra/httpd-ssl.conf
Configure HTTPS virtual hosts.
DocumentRoot "/path/to/web/folder" ServerName [example].localhost SSLCertificateFile "/etc/apache2/server.crt" SSLCertificateKeyFile "/etc/apache2/server.nopass.key"
5. Install & Configure MySQL
- Download the Mac OS X package from the MySQL download page
- Make sure it's the 64-bit DMG archive version
- Install MySQL, the pref pane and the startup scripts.
Create config, set timezone to UTC and set storage to ramdisk.
sudo cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf sudo vi /etc/my.cnf
[mysqld] ... default_time_zone = '+00:00' datadir = /Volumes/ramdisk/data innodb_flush_log_at_trx_commit = 2 innodb_data_home_dir = /Volumes/ramdisk/data
Add the mysql path to your profile.
sudo vi ~/.bash_profile
Add this line to the file:
export PATH="/usr/local/mysql/bin:$PATH"
Reload the profile.
su - [username]
Run the ramdisk script found here.
6. Configure php.ini
Enable the php.ini file and open it for editing.
sudo cp /etc/php.ini.default /etc/php.ini sudo vi /etc/php.ini
Change the timezone and uni socket path for MySql to ramdisk:
date.timezone = UTC ... pdo_mysql.default_socket=/tmp/mysql_ram.sock ... detect_unicode = Off (at end, doesn't yet exist)
7. Start Services
sudo apachectl restart cd /usr/local/mysql ./bin/mysqld_safe
8. Dev Extras
Remove sudo password.
sudo visudo
[username] ALL=(ALL) NOPASSWD: ALL
Install composer.
curl -s http://getcomposer.org/installer | php php composer.phar install
Set permissions on cache and logs.
sudo rm -rf app/cache/* sudo rm -rf app/logs/* sudo chmod +a "www allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
Install Java by initiating the installer.
java -version
No comments:
Post a Comment