linuxÏÂthinkphpÔõôÔËÐÐ
ÔÚ linux ƽ̨Ï£¬ÔõÑùÔËÐÐ thinkphp ÏîÄ¿ÄØ?
ThinkPHP ÊÇÒ»¸öºÜÊÇÓÅÒìµÄ PHP ¿ª·¢¿ò¼Ü¡£Ëü¼«´óµÄÌá¸ßÁË PHP ¿ª·¢Ð§ÂʺʹúÂëÖÊÁ¿£¬Êܵ½ÁË¿í´ó¿ª·¢ÕßµÄÇàíù¡£¶øÔÚ Linux ƽ̨Ï£¬ÔõÑùÔËÐÐ ThinkPHP ÏîÄ¿ÄØ£¿ÏÂÃ棬Ϊ¸÷ÈËÏêϸÏÈÈÝ¡£
×°Öà PHP ÇéÐÎ
ÔÚ Linux ÏÂ×°Öà PHP ÇéÐκÜÊǼòÆÓ£¬Ö»ÐèÖ´ÐÐÒÔÏÂÏÂÁî¼´¿É£º
Ubuntu£º
sudo apt-get install php
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
CentOS£º
yum install php
×°ÖÃ Apache »ò Nginx
ÔÚ Linux ϳ£ÓÃµÄ Web ЧÀÍÆ÷ÓÐ Apache ºÍ Nginx Á½ÖÖ£¬ÏÂÃæ»®·ÖÏÈÈÝÔõÑù×°Öá£
2.1 Apache ×°ÖÃ
Ubuntu£º
sudo apt-get install apache2
CentOS£º
yum install httpd
2.2 Nginx ×°ÖÃ
¹ØÓÚʹÓà Nginx µÄÓû§£¬¿ÉÒÔÑ¡Ôñ×°Öà Nginx ²¢Ê¹Óà php-fpm Ä£¿éÖ´ÐÐ PHP ´úÂ룬´ËÖÖ·½·¨Ð§ÂÊ½Ï Apache ¸ü¸ß¡£
Ubuntu£º
sudo apt-get install nginx php-fpm
CentOS£º
yum install nginx php-fpm
×°ÖÃ Composer
ThinkPHP 5 ½ÓÄÉ Composer ×÷Ϊ°ü¹ÜÀí¹¤¾ß£¬ÈôÊÇÒѾװÖùý Composer£¬Ôò¿ÉÒÔÌø¹ý´Ë°ì·¨¡£
Ubuntu£º
sudo apt-get install composer
CentOS£º
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
×°ÖÃ ThinkPHP
ÔÚ Linux Ï£¬×°Öà ThinkPHP ÓжàÖÖ·½·¨£¬ÏÂÃæÏÈÈÝÁ½ÖÖ£ºComposer ×°ÖúÍÊÖ¶¯×°Öá£
4.1 Composer ×°ÖÃ
ÔÚÏÂÁîÐÐÖÐÖ´ÐÐÒÔÏÂÏÂÁ
composer create-project topthink/think tp5 –prefer-dist
ÆäÖУ¬tp5 ΪÏîÄ¿Ãû³Æ£¬–prefer-dist ÌåÏÖʹÓÃѹËõ°ü·½·¨×°Öá£
×°ÖÃÍê³Éºó£¬¼´¿Éͨ¹ýÏÂÁîÐÐÔÚÏîÄ¿¸ùĿ¼ÏÂÆô¶¯ PHP ÄÚÖà Web ЧÀÍÆ÷£¬Ö´ÐÐÒÔÏÂÏÂÁ
php think run
4.2 ÊÖ¶¯×°ÖÃ
ÊÖ¶¯×°ÖÃÐèÒªÏȽ« ThinkPHP ÏÂÔز¢½âѹËõµ½Ö¸¶¨Ä¿Â¼£¬È»ºóÉèÖÃÖØд¹æÔò£¨¿ÉʹÓà .htaccess »ò nginx.conf£©£¬ÉèÖÃÍê³Éºó¼´¿ÉÔËÐС£
ÉèÖÃÊý¾Ý¿â
ÔÚ Linux Ï£¬ThinkPHP ĬÈÏʹÓà MySQL Êý¾Ý¿â¡£ÐèÒªÔÚÉèÖÃÎļþÖÐÉèÖÃÊý¾Ý¿âÅþÁ¬ÐÅÏ¢¡£
ÔÚÏîÄ¿¸ùĿ¼Ï£¬·¿ª application/database.php Îļþ£¬Ìîд׼ȷµÄÊý¾Ý¿âÅþÁ¬ÐÅÏ¢¼´¿É¡£
ÔËÐÐÏîÄ¿
ÉèÖÃÍê³Éºó£¬¼´¿Éͨ¹ý Web ä¯ÀÀÆ÷»á¼ûÏîÄ¿¡£
¹æÔò£ºhttp(s)://ÄãµÄÓòÃû»òÕßIP/ÏîÄ¿Ãû³Æ/Ä£¿éÃû/¿ØÖÆÆ÷Ãû/ÒªÁìÃû
ÀýÈ磺
http://localhost/tp5/index/index/hello
×ܽá
ÔÚ Linux ƽ̨Ï£¬×°ÖúÍÔËÐÐ ThinkPHP ÏîÄ¿²¢²»ÄÑÌ⣬Ðè×¢ÖØÒÔϼ¸µã£º
×°Öà PHP ÇéÐΣ»
×°ÖÃ Apache »ò Nginx£»
×°ÖÃ Composer£»
×°ÖÃ ThinkPHP£»
ÉèÖÃÊý¾Ý¿â£»
ÔËÐÐÏîÄ¿¡£
Ï£Íûͨ¹ý±¾ÎĵÄÏÈÈÝ£¬Äܹ»×ÊÖú¸÷È˸üºÃµØÔÚ Linux ϵͳÏÂÔËÐÐ ThinkPHP ÏîÄ¿¡£
ÒÔÉϾÍÊÇlinuxÏÂthinkphpÔõôÔËÐеÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡