Skip to content

Instantly share code, notes, and snippets.

@chen206
Last active December 19, 2015 13:39
Show Gist options
  • Save chen206/5963687 to your computer and use it in GitHub Desktop.
Save chen206/5963687 to your computer and use it in GitHub Desktop.
ubuntu 12.04.2, os x, nginx, php5-fpm, php5-cli, php5-mysql, phpmyadmin

Ubuntu

sudo apt-get install nginx -y
sudo apt-get install php5-fpm php5-cli php5-mysql -y
sudo apt-get install phpmyadmin -y

cd /etc/php5/cli
sudo mv php.ini php.ini.backup
sudo ln -s ../fpm/php.ini

sudo vi /etc/php5/fpm/pool.d/www.conf

sudo vi /etc/nginx/sites-available/php82
sudo vi /etc/nginx/nginx.conf

sudo service nginx restart
sudo service php5-fpm restart

cd /usr/share/nginx/www
sudo ln -s /usr/share/phpmyadmin

/usr/share/nginx/www/index.php

<?php
phpinfo();
?>

/etc/nginx/nginx.conf

http {
    charset utf-8;

    upstream php {
        server unix:/tmp/php5-fpm.sock;
    }

/etc/nginx/sites-available/php82

server {
  listen 82 default; ## listen for ipv4; this line is default and implied
	listen [::]:82 default ipv6only=on; ## listen for ipv6

	# Make site accessible from http://localhost/ or server IP-address
	server_name localhost;
	server_name_in_redirect off;

	charset utf-8;

	access_log /usr/share/nginx/access.log;
	error_log /usr/share/nginx/error.log;

	root /usr/share/nginx/www;
	index index.php index.html index.htm;

	location / {
		# First attempt to serve request as file, then
		# as directory, then trigger 404
		try_files $uri $uri/ =404;
	}

  # pass the PHP scripts to FPM socket
  location ~ \.php$ {
    try_files $uri =404;
  
  	fastcgi_split_path_info ^(.+\.php)(/.+)$;
  	# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
  	
  	fastcgi_pass php;
  
  	fastcgi_index index.php;
  
  	fastcgi_param SCRIPT_FILENAME /usr/share/nginx/www$fastcgi_script_name;
  	fastcgi_param DOCUMENT_ROOT /usr/share/nginx/www;
  
  	# send bad requests to 404
  	fastcgi_intercept_errors on;
  
  	include fastcgi_params;
  }
}

/etc/php5/fpm/pool.d/www.conf

listen = /tmp/php5-fpm.sock

OS X

https://coderwall.com/p/lbaf6q

download by xunlei:

http://us2.php.net/distributions/php-5.4.22.tar.bz2

mv php-5.4.22.tar.bz2 `brew --cache php54`
$ /usr/local/Cellar/mysql/5.6.10/bin/mysqladmin -u root password 'xxxx'
mysql.server start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment