laravel°²ÅÅÏîÄ¿
laravelÊÇÒ»¿îÏÖ´ú»¯µÄphp¿ò¼Ü£¬¾ßÓÐÍêÉƵÄmvc¼Ü¹¹¡¢ÃæÏò¹¤¾ßµÄ¿ª·¢Ä£Ê½¡¢Ç¿Ê¢µÄ·ÓÉ¿ØÖÆ¡¢ÎÞаµÄorm¡¢¸»ºñµÄ¹¤¾ßÀà¿âºÍÄ£°åÒýÇæµÈÌص㣬ÔÚwebÓ¦ÓóÌÐò¿ª·¢ÖйãÊܽӴý¡£ÔÚ±¾ÎÄÖУ¬½«ÏÈÈÝÔõÑùÔÚlinuxЧÀÍÆ÷ÉÏ°²ÅÅlaravelÏîÄ¿¡£
×¼±¸ÊÂÇé
ÔÚ¾ÙÐÐLaravelÏîÄ¿°²ÅÅ֮ǰ£¬ÐèҪȷ±£ÒÔÏÂÌõ¼þ£º
1.ЧÀÍÆ÷ϵͳ£ºCentOS»òUbuntuµÈÖ÷Á÷Linuxϵͳ
2.ЧÀÍÆ÷ÇéÐΣºNginx»òApache HTTP Server
3.Êý¾Ý¿â£ºMySQL»òPostgreSQLµÈ¹ØϵÐÍÊý¾Ý¿â
4.PHP£ºPHP7.0»ò¸ü¸ß°æ±¾£¬ÐèҪװÖÃÏà¹ØÀ©Õ¹
5.°æ±¾¿ØÖÆ£ºGit»òSVN£¬Àû±ã´úÂëÖÎÀíºÍ°²ÅÅ
6.ÓòÃû£ºÐèÒªÓа󶨵ÄÓòÃû»òIPµØµã£¬Àû±ã»á¼ûºÍ²âÊÔÍøÕ¾
ÒÔÉÏÌõ¼þ¶¼Öª×ãÖ®ºó£¬¾Í¿ÉÒÔ½øÈëLaravelÏîÄ¿µÄ°²ÅÅÀú³Ì¡£
°ì·¨Ò»£º×°ÖÃComposer
ComposerÊÇPHPµÄ°ü¹ÜÀíÆ÷£¬ÓÃÓÚÖÎÀíÒÀÀµ¹ØϵºÍ×Ô¶¯¼ÓÔع¦Ð§¡£ÔÚ°²ÅÅLaravelÏîĿ֮ǰ£¬ÐèÒªÏÈ×°ÖÃComposer¡£
1.ÏÂÃæÊÇÓÃcurlÏÂÁî×°ÖÃComposerµÄ·½·¨£º
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
µÇ¼ºó¸´ÖÆ
2.×°ÖÃÍê³Éºó£¬¿ÉÒÔͨ¹ýcomposerÏÂÁî¼ì²éÊÇ·ñ×°ÖÃÀֳɣº
composer -v
µÇ¼ºó¸´ÖÆ
°ì·¨¶þ£º¿Ë¡´úÂë
1.ʹÓÃSSHÅþÁ¬µ½Ð§ÀÍÆ÷£¬²¢½øÈë°²ÅÅÏîÄ¿µÄĿ¼£º
cd /var/www/
µÇ¼ºó¸´ÖÆ
2.ÔÚ¸ÃĿ¼Ï£¬Ö´ÐÐÒÔÏÂÏÂÁî¿Ë¡ÏîÄ¿´úÂ룺
git clone https://github.com/your_git_repository.git
µÇ¼ºó¸´ÖÆ
ÕâÀïµÄ¡°your_git_repository¡±ÌåÏÖÏîÄ¿µÄGit¿ÍÕ»µØµã¡£
3.½øÈëÏîĿĿ¼£¬Ê¹ÓÃComposer×°ÖÃÒÀÀµ£º
cd your_project_directory composer install
µÇ¼ºó¸´ÖÆ
ÕâÀïµÄ¡°your_project_directory¡±ÌåÏÖÏîÄ¿ËùÔÚµÄĿ¼Ãû³Æ¡£
°ì·¨Èý£ºÉèÖÃÇéÐαäÁ¿
1.ÔÚÏîĿĿ¼ÖУ¬¸´ÖÆ¡°.env.example¡±Îļþ²¢ÖØÃüÃûΪ¡°.env¡±£º
cp .env.example .env
µÇ¼ºó¸´ÖÆ
2.Ð޸ġ°.env¡±ÎļþÖеÄÏà¹ØÉèÖ㬰üÀ¨Êý¾Ý¿âÅþÁ¬ÐÅÏ¢¡¢ÓʼþЧÀ͵ȡ£ÈôÊÇÓÐÐèÒª£¬Ò²¿ÉÒÔÉèÖÃÓ¦ÓóÌÐòµÄµ÷ÊÔģʽ¡¢ÈÕÖ¾Êä³öµÈ¡£Íê³ÉºóÉúÑIJ¢Í˳ö¡£
3.ÌìÉúÒ»¸öеÄÃÜÔ¿£º
php artisan key:generate
µÇ¼ºó¸´ÖÆ
Õâ¸öÃÜÔ¿ÓÃÓÚ¼ÓÃÜÌìÉúµÄÁîÅƺÍcookieµÈÊý¾Ý¡£
°ì·¨ËÄ£ºÉèÖÃWebЧÀÍÆ÷
1.ÔÚNginx»òApache HTTP ServerµÄÉèÖÃÎļþÖУ¬Ìí¼ÓÒ»¸öÐéÄâÖ÷»úÉèÖ㬰üÀ¨ÓòÃû¡¢Ä¿Â¼µÈÐÅÏ¢¡£ÒÔNginxΪÀý£¬½¨ÉèÒ»¸öλÓÚ¡°/etc/nginx/sites-available/¡±Ä¿Â¼ÏµÄÉèÖÃÎļþ£¬ºÃ±È¡°your_domain.conf¡±£º
server { listen 80; server_name your_domain.com; root /var/www/your_project_directory/public; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ .php$ { fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_split_path_info ^(.+.php)(/.+)$; include fastcgi_params; } }
µÇ¼ºó¸´ÖÆ
2.½«ÉèÖÃÎļþÁ´½Óµ½¡°/etc/nginx/sites-enabled/¡±Ä¿Â¼Ï£¬ÆôÓÃÐéÄâÖ÷»ú£º
sudo ln -s /etc/nginx/sites-available/your_domain.conf /etc/nginx/sites-enabled/
µÇ¼ºó¸´ÖÆ
3.ÖØмÓÔØNginxÉèÖãº
sudo service nginx reload
µÇ¼ºó¸´ÖÆ
ÐèҪעÖصÄÊÇ£¬ÒÔÉÏÉèÖÃÎļþÖеġ°your_domain.com¡±ºÍ¡°your_project_directory¡±ÐèÒªÌæ»»³ÉÏÖʵµÄÓòÃûºÍÏîĿĿ¼Ãû³Æ¡£
°ì·¨Î壺ÔËÐÐǨáãºÍÆô¶¯ÐÐÁÐ
1.ÔÚÏîĿĿ¼ÖУ¬ÔËÐÐǨáã²Ù×÷£¬½¨ÉèÏà¹ØÊý¾Ý¿â±í£º
php artisan migrate
µÇ¼ºó¸´ÖÆ
2.Æô¶¯LaravelÐÐÁУ¬´¦ÀíÒ첽ʹÃü£º
php artisan queue:listen
µÇ¼ºó¸´ÖÆ
ºǫִ́ÐиÃÏÂÁî¿ÉÒÔʹÓÃÒÔÏ·½·¨£º
nohup php artisan queue:listen &
µÇ¼ºó¸´ÖÆ
»ò½«Æô¶¯ÏÂÁîдÈë/etc/supervisor/conf.dĿ¼ÏµÄÉèÖÃÎļþÖУ¬Ê¹ÓÃsupervisor¾ÙÐÐÖÎÀí¡£
ÖÁ´Ë£¬LaravelÏîÄ¿µÄ°²ÅžÍÍê³ÉÁË¡£ÔÚä¯ÀÀÆ÷ÖÐÊäÈëÓòÃû»òЧÀÍÆ÷ipµØµã£¬¼´¿É»á¼ûÍøÕ¾¡£ÈôÊÇÒª¸üдúÂ룬ֻÐèҪʹÓÃGit pullÏÂÁî¸üпÍÕ»ÖеĴúÂë¼´¿É¡£
×ܽá
LaravelÊÇÒ»¿î¹¦Ð§Ç¿Ê¢µÄPHP¿ò¼Ü£¬Ê¹ÓÃLaravel¿ª·¢µÄÓ¦ÓóÌÐò£¬ÔÚЧÂÊ¡¢ÐÔÄܺͿÉά»¤ÐÔ·½Ã涼ÓкܴóµÄÌáÉý¡£±¾ÎľÍÊÇÏÈÈÝÔõÑùÔÚLinuxЧÀÍÆ÷ÉÏ°²ÅÅLaravelÏîÄ¿£¬°üÀ¨×°ÖÃComposer¡¢¿Ë¡´úÂë¡¢ÉèÖÃÇéÐαäÁ¿¡¢ÉèÖÃWebЧÀÍÆ÷ºÍÔËÐÐǨáãµÈ°ì·¨¡£Ï£ÍûÕâƪÎÄÕ¿ÉÒÔ×ÊÖúÓÐÐèÒªµÄ¶ÁÕß¾ÙÐÐLaravelÏîÄ¿°²ÅÅ¡£
ÒÔÉϾÍÊÇlaravel°²ÅÅÏîÄ¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡