Apache PHP MySQL

De Memo
Aller à : navigation, rechercher


sudo su -

Enable Apache on Mac OS X

sudo apachectl start



Enable PHP for Apache

First, make a backup of the default Apache configuration

cd /etc/apache2/

cp httpd.conf httpd.conf.bak

Now edit the Apache configuration

nano httpd.conf

Uncomment the following line (for php 5.5 only):

LoadModule php5_module libexec/apache2/libphp5.so

Restart Apache:

sudo apachectl restart

Default DocumentRoot

for Mac OS X Yosemite is /Library/WebServer/Documents.

sudo nano /etc/apache2/httpd.conf

You can verify this from your Apache configuration. => crtl + w on nano / DocumentRoot

phpinfo() in DocumentRoot

echo '<?php phpinfo();' > /Library/WebServer/Documents/phpinfo.php

Connect PHP and MySQL

cd /var 

mkdir mysql

cd mysql

ln -s /tmp/mysql.sock mysql.sock

Install MySQL

Install MySQL with Homebrew:

brew install -v mysql

Copy the default my-default.cnf file to the MySQL Homebrew Cellar directory where it will be loaded on application start:

cp -v $(brew --prefix mysql)/support-files/my-default.cnf $(brew --prefix)/etc/my.cnf
cat >> $(brew --prefix)/etc/my.cnf <<'EOF'
# Echo & Co. changes
max_allowed_packet = 1073741824
innodb_file_per_table = 1

Uncomment the sample option for innodb_buffer_pool_size to improve performance:

sed -i  's/^#space:*\(innodb_buffer_pool_size\)/\1/' $(brew --prefix)/etc/my.cnf

brew tap homebrew/services

brew services start mysql

Create Virtual Host

nano /etc/apache2/httpd.conf

Uncomment the following line:

Include /private/etc/apache2/extra/httpd-vhosts.conf

Edit httpd-vhosts.conf

nano /etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80>
   DocumentRoot "/Library/WebServer/Documents"

  DocumentRoot "/Users/francois/Development/Sites/sb"
  ServerName sb.local
  ErrorLog "/Users/francois/error_log"
  CustomLog "/Users/francois/access_log" common
  <Directory />
      Options FollowSymLinks
      AllowOverride All
      Require all granted
      Allow from all
      DirectoryIndex index.html index.php

Restart Apache

apachectl restart

Edit hosts file

sudo nano /etc/hosts

Add line to bottom       jason.local

Flush cache

dscacheutil -flushcache

Install phpMyAdmin

cd /Development/Sites
mv phpMyAdmin-4.6.4-all-languages phpmyadmin
cd phpmyadmin

backup config.sample.inc.php

create config file


Access MySQL

echo $PATH
mysql -h localhost -u root -p

Change password

ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';

Local site install

sudo nano /etc/apache2/extra/httpd-vhosts.conf
sudo apachectl restart
sudo nano /etc/hosts

VirtualHosts Folder

Find php.ini

php -i | grep php.ini

php --ini

Tuto Apache


WP local permalinks

sudo nano /etc/apache2/httpd.conf

Uncomment :

#LoadModule rewrite_module libexec/apache2/mod_rewrite.so

Search for :

<Directory />
   AllowOverride None
   Require all denied
and replace AllowOverride None for AllowOverride All

Finally Search for the section Document Root

and inside this section replace AllowOverride None for AllowOverride All