thinkphpÔõÑù×°ÖÃ
Ò»¡¢ÏÂÔØ ThinkPHP Ô´Âë
ÎÒÃÇÐèÒªÏÈÏÂÔØ×îаæµÄ ThinkPHP Ô´´úÂ룬¿ÉÒÔ´Ó¹Ù·½ÍøÕ¾»ñÈ¡¡£Äú¿ÉÒÔÔÚÏÂÔØÒ³ÃæÉÏÑ¡ÔñѹËõ°ü»òGit´úÂë¿âÀ´¾ÙÐÐÏÂÔØ¡£ÈôÊÇÄúÒѾÊìϤ Git µÄʹÓÃÒªÁ죬¿ÉÒÔÖ±½ÓʹÓà Git ÏÂÁîÀ´¿Ë¡´úÂë¿â£»ÈôÊÇÄú²»ÊìϤ Git£¬Ôò¿ÉÒÔÏÂÔØѹËõ°ü¾ÙÐÐ×°Öá£
¶þ¡¢½âѹԴÂë
ÏÂÔØÍê³Éºó£¬½«Ñ¹Ëõ°ü½âѹµ½ÄúµÄ Web ЧÀÍÆ÷µÄÖ¸¶¨Ä¿Â¼Ï¡£Õâ¸öĿ¼ͨ³£ÊÇÄúµÄ Web ЧÀÍÆ÷Ëù¼àÌýµÄĿ¼¡£¾Ù¸öÀý×Ó£¬ÈôÄúÕýÔÚÔËÐÐ Apache ЧÀÍÆ÷£¬¸ÃĿ¼һÑùƽ³£Îª /var/www/html¡£
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
Èý¡¢ÉèÖà Web ЧÀÍÆ÷
ÔÚÍê³ÉÔ´Âë½âѹºó£¬ÎÒÃÇÐèÒªÉèÖà Web ЧÀÍÆ÷µÄÉèÖÃÎļþ£¬ÒÔ±ãÈÃЧÀÍÆ÷¿ÉÒÔ׼ȷµÄÔËÐÐ ThinkPHP ¿ò¼Ü¡£Æ¾Ö¤ÏÂÃæµÄ°ì·¨¾ÙÐÐÉèÖãº
¹ØÓÚ Apache ЧÀÍÆ÷£¬·¿ª Apache µÄÉèÖÃÎļþ£¨Í¨³£Îª /etc/httpd/conf/httpd.conf£©£¬Ìí¼ÓÏÂÃæµÄ´úÂ룺
<VirtualHost *:80> ServerName your.server.name DocumentRoot /path/to/thinkphp/public <Directory /path/to/thinkphp/public> AllowOverride All Require all granted </Directory> </VirtualHost>
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬your.server.name ÊÇÄúµÄЧÀÍÆ÷ËùʹÓõÄÓòÃû»ò IP µØµã£¬/path/to/thinkphp ÊÇÄúµÄ ThinkPHP Ô´ÂëËùÔÚµÄĿ¼¡£Õâ¸öÉèÖÃÎļþ»áÈÃÄúµÄЧÀÍÆ÷¼àÌý 80 ¶Ë¿Ú£¬²¢½«ËùÓÐÀ´×Ô your.server.name µÄÇëÇóÖض¨Ïòµ½ ThinkPHP ³ÌÐòµÄÈë¿ÚÎļþ£¨Í¨³£ÊÇ index.php£©¡£
¹ØÓÚ Nginx ЧÀÍÆ÷£¬·¿ª Nginx µÄÉèÖÃÎļþ£¨Í¨³£Îª /etc/nginx/nginx.conf£©£¬Ìí¼ÓÏÂÃæµÄ´úÂ룺
server { listen 80; server_name your.server.name; location / { root /path/to/thinkphp/public; index index.php; try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { root /path/to/thinkphp/public; fastcgi_pass unix:/run/php-fpm/www.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬your.server.name ÊÇÄúµÄЧÀÍÆ÷ËùʹÓõÄÓòÃû»ò IP µØµã£¬/path/to/thinkphp ÊÇÄúµÄ ThinkPHP Ô´ÂëËùÔÚµÄĿ¼¡£Õâ¸öÉèÖÃÎļþ»áÈà Nginx ¼àÌý 80 ¶Ë¿Ú£¬²¢½«ËùÓÐÀ´×Ô your.server.name µÄÇëÇóÖض¨Ïòµ½ ThinkPHP ³ÌÐòµÄÈë¿ÚÎļþ£¨Í¨³£ÊÇ index.php£©¡£
ËÄ¡¢×°ÖÃÊý¾Ý¿â¼°ÉèÖÃÓ¦ÓÃÉèÖÃ
ÔÚÉèÖÃÍê Web ЧÀÍÆ÷Ö®ºó£¬ÎÒÃÇÐèҪΪӦÓóÌÐòÉèÖÃÊý¾Ý¿âÉèÖúÍÓ¦ÓÃÉèÖá£Æ¾Ö¤ÏÂÃæµÄ°ì·¨¾ÙÐвÙ×÷£º
·¿ª config/database.php Îļþ£¬ÉèÖÃÊý¾Ý¿âÐÅÏ¢¡£ÀýÈ磺
<?php return [ 'hostname' => 'localhost', 'database' => 'thinkphp', 'username' => 'root', 'password' => '', // ... ];
µÇ¼ºó¸´ÖÆ
·¿ª config/app.php Îļþ£¬ÉèÖÃÓ¦ÓÃÉèÖÃÐÅÏ¢¡£ÀýÈ磺
<?php return [ // Ó¦ÓÃÃû³Æ 'app_name' => 'ThinkPHP', // ĬÈÏʱÇø 'default_timezone' => 'Asia/Shanghai', // µ÷ÊÔģʽ 'debug' => true, // ... ];
µÇ¼ºó¸´ÖÆ
Îå¡¢ÔËÐÐ ThinkPHP Ó¦ÓóÌÐò
ÎÒÃÇÒѾÀֳɵØ×°ÖÃÁË ThinkPHP ¿ò¼ÜµÄÔ´´úÂ룬²¢ÀÖ³ÉÉèÖÃÁË Web ЧÀÍÆ÷ºÍÓ¦ÓóÌÐò¡£ÏÖÔÚ£¬ÎÒÃÇ¿ÉÒÔÆô¶¯ Web ЧÀÍÆ÷£¬»á¼ûÄúÉèÖõÄÓòÃû»ò IP µØµã£¬Ó¦¸Ã¾ÍÄÜ¿´µ½Ò»¸ö½Ó´ýÒ³ÃæÌåÏÖÒѾÀֳɵØ×°ÖÃÁË ThinkPHP Ó¦ÓóÌÐò¡£
ÒÔÉϾÍÊÇthinkphpÔõÑù×°ÖõÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡