ubuntuϵÄnginx+php+mysqlÅäÖÃ
ÕâЩÌìÓÖ¿´ÁËһЩubuntuÏÂphp+nginxµÄÅäÖ÷½ÃæµÄ×ÊÁÏ£¬½ñÌì¼Ç¼ÓÚ´Ë£¬´ó¼ÒÓÐʱ¼ä¶à²Ù×÷Ï¡£PS£º¶ÔÓÚ±àÒë°æµÄµÈÎÒʵ¼Ê²Ù×÷ºó»áÔÙÌùһƪÎÄÕ£¡
1¡¢¸üÐÂ
sudo apt-get update2¡¢°²×°nginx
sudo apt-get intsall nginxUbuntu°²×°Ö®ºóµÄÎļþ½á¹¹´óÖÂΪ:
* ËùÓеÄÅäÖÃÎļþ¶¼ÔÚ/etc/nginxÏÂ,²¢ÇÒÿ¸öÐéÄâÖ÷»úÒѾ°²ÅÅÔÚÁË/etc/nginx/sites-availableÏÂ
*³ÌÐòÎļþÔÚ/usr/sbin/nginx * ÈÕÖ¾·ÅÔÚÁË/var/log/nginxÖÐ
*²¢ÒѾÔÚ/etc/init.d/Ï´´½¨ÁËÆô¶¯½Å±¾nginx
* ĬÈϵÄÐéÄâÖ÷»úµÄĿ¼ÉèÖÃÔÚÁË/var/www/nginx-default
ÏÂÃæ¿ÉÒÔÆô¶¯nginxÀ´¿´¿´Ð§¹û(ÇëÈ·±£80¶Ë¿ÚûÓÐÆäËû·þÎñÔÚʹÓÃ):
sudo /etc/init.d/nginx start »òÕß service nginx startÈ»ºó´ò¿ªä¯ÀÀÆ÷,²é¿´http://localhost/ ¿´¿´ÊÇ·ñ¿´µ½ÁË¡±Welcome to nginx!¡± Èç¹û¿´µ½ÁË,˵Ã÷°²×°³É¹¦.
µ±È»,»ù±¾ÉÏ,Õâ¿é¶ù¶¼²»»á³öÎÊÌâ. Èç¹ûÔËÐв»³É¹¦,¿ÉÒÔÏÈ
sudo killall apache2ɱµôapache½ø³Ì
3¡¢°²×°php
sudo apt-get install php5 php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-pspell php5-recode php5-snmp php5-tidy php5-xmlrpc php5-sqlite php5-xsl4¡¢°²×°spawn-fcgi
ΪʲôҪ°²×°spawn-fcgiÄØ,ËüÓÃÀ´¿ØÖÆphp-cgi½ø³Ì,ÒÔ·ÀÖ¹½ø³Ì±ÀÀ£»òÊǵ¥½ø³ÌµÄЧÂÊÌ«µÍ.
ÍøÉϺܶàÈ˶¼ËµÒªÊ¹ÓÃspawn-fcgi±ØÐëµÃ°²×°lighttpd,ʵ¼ÊÉϲ»±ØÒª,¿ÉÒÔÖ±½Ó°²×°spawn-fcgi
ÔËÐÐ:
sudo apt-get install spawn-fcgi5¡¢ÅäÖÃ
½ÓÏÂÀ´¾ÍÊÇ×îÈÃÈËÍ·ÌÛµÄÅäÖÃ.
ÅäÖÃNginxºÍspawn-fcgiÅäºÏÔËÐÐ
(1).ÔÚ/etc/nginx/fastcgi_params Îļþ×îºó,¼ÓÈëÒ»ÐÐ,¿ÉÒÔÓÃ
sudo vi /etc/nginx/fastcgi_params ¼ÓÈë´ËÐÐ: fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
(2).ÁíÍâÐèÒªÔÚPHP-CGIµÄÅäÖÃÎļþ(Ubuntu ÉÏ´ËÅäÖÃÎļþλÓÚ/etc/php5/cgi/php.ini)ÖÐ,ÕÒµ½cgi.fix_pathinfoÑ¡Ïî,ÐÞ¸ÄΪ:
cgi.fix_pathinfo=1;ÕâÑùphp-cgi·½ÄÜÕý³£Ê¹ÓÃSCRIPT_FILENAMEÕâ¸ö±äÁ¿.
(3).´ò¿ª/etc/nginx/sites-available/defaultÎļþÔÚ
server { listen 80; server_name localhost;
ÏÂÃæÌí¼Óweb¸ùĿ¼µÄ¾ø¶ÔµØÖ·,ÕâÀïÊÇʹÓõÄÊÇnginxµÄĬÈϵØÖ·
root /var/www/nginx-default¼´rootºÍserver_nameͬ¼¶Õâ¶Î¼´Ï൱ÓÚapacheµÄĬÈÏĿ¼
Èç¹ûûÓÐÕâ¸öµÄ»°,ÈÝÒ×ÔÚÖ´ÐÐphp ÎļþµÄʱºò,»áÌáʾ¡±No input file specified¡±.
ÎÒ¾ÍÔøÔÚ´ËÈÆÁ˺ôó¸öȦ×Ӳŷ¢ÏÖÎÊÌâ.È»ºóÐÞ¸Ä
#location ~ .php$ { #fastcgi_pass 127.0.0.1:9000; #fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; #includefastcgi_params; #}
Ð޸ijÉ
location ~ .php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/nginx-default$fastcgi_script_name;include /etc/nginx/fastcgi_params; #°üº¬fastcgiµÄ²ÎÊýÎļþµØÖ·
6¡¢¿ªÊ¼fast_cgi½ø³Ì
sudo /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid
7¡¢ÉèÖÿª»úÆô¶¯fastcgi½ø³Ì²¢Æô¶¯
sudo vi /etc/rc.local
Ìí¼ÓÏÂÒ»ÐÐ
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid
Èç¹û´ò¿ªphpÎļþ³öÏÖ:No input file specifiedÇë¼ì²éphp.iniµÄÅäÖÃÖÐ
cgi.fix_pathinfo=1 doc_root=
»¹ÓÐ,ÿ¸öÐé»úÒª¸ù¾Ý×Ô¼º²»Í¬µÄÐé»úÉèÖò»Í¬µÄĿ¼,Òª±£Ö¤Õâ¸ö·¾¶ÕýÈ·.
¼ì²é/etc/nginx/sites-availableϵÄÅäÖÃÎļþÖÐ,serverÄÚ°üº¬ root ¼°µØÖ· ¶ø·ÇlocationÄÚµÄroot
Æô¶¯
fast-cgisudo /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid²ÎÊýº¬ÒåÈçÏÂ
* -f Ö¸¶¨µ÷ÓÃFastCGIµÄ½ø³ÌµÄÖ´ÐгÌÐòλÖÃ,¸ù¾ÝϵͳÉÏËù×°µÄPHPµÄÇé¿ö¾ßÌåÉèÖÃ
* -a °ó¶¨µ½µØÖ·addr
* -p °ó¶¨µ½¶Ë¿Úport
* -s °ó¶¨µ½unix socketµÄ·¾¶path
* -C Ö¸¶¨²úÉúµÄFastCGIµÄ½ø³ÌÊý,ĬÈÏΪ5(½öÓÃÓÚPHP)
* -PÖ¸¶¨²úÉúµÄ½ø³ÌµÄPIDÎļþ·¾¶
* -uºÍ-g FastCGIʹÓÃʲôÉí·Ý(-u Óû§ -g Óû§×é)ÔËÐÐ,UbuntuÏ¿ÉÒÔʹÓÃwww-data,ÆäËûµÄ¸ù¾ÝÇé¿öÅäÖÃ,Èçnobody¡¢apacheµÈÏÖÔÚ¿ÉÒÔÔÚweb¸ùĿ¼Ï·Ÿö̽Õë»òphpÎļþ²âÊÔÒ»ÏÂÁË
8¡¢°²×°mysql
sudo apt-get install mysql-server mysql-clientÖмä»áÌáʾÊäÈëRootÓû§ÃÜÂë,ÒÀ´ÎÊäÈë¼´¿É.
Æô¶¯MySQL
sudo /etc/init.d/mysql start²âÊÔmysql·þÎñÊÇ·ñÕý³£:
ÔËÐÐ
mysql -uroot -p
ÊäÈëmysqlÃÜÂë
show databases;Èç¹û¿´µ½ÏÂÃæµÄÄÚÈÝ
| Database |
| information_schema |
| mysql |
ÔòmysqlÒÑÕýÈ·°²×°ÁË.
ÖÁ´Ë,ubuntuϵÄnginx+php+mysql¾Í°²×°Íê³ÉÁË.
ÍƼöÐÅÏ¢
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
ÆÀÂÛ