ÿØÿà JFIF    ÿÛ „  ( %"1!%)+...383,7(-.+  -+++--++++---+-+-----+---------------+---+-++7-----ÿÀ  ß â" ÿÄ     ÿÄ H    !1AQaq"‘¡2B±ÁÑð#R“Ò Tbr‚²á3csƒ’ÂñDS¢³$CÿÄ   ÿÄ %  !1AQa"23‘ÿÚ   ? ôÿ ¨pŸªáÿ —åYõõ\?àÒü©ŠÄï¨pŸªáÿ —åYõõ\?àÓü©ŠÄá 0Ÿªáÿ Ÿå[úƒ ú®ði~TÁbqÐ8OÕpÿ ƒOò¤Oè`–RÂáœá™êi€ßÉ< FtŸI“öÌ8úDf´°å}“¾œ6  öFá°y¥jñÇh†ˆ¢ã/ÃÐ:ªcÈ "Y¡ðÑl>ÿ ”ÏËte:qž\oäŠe÷󲍷˜HT4&ÿ ÓÐü6ö®¿øþßèô Ÿ•7Ñi’•j|“ñì>b…þS?*Óôÿ ÓÐü*h¥£ír¶ü UãS炟[AÐaè[ûª•õ&õj?†Éö+EzP—WeÒírJFt ‘BŒ†Ï‡%#tE Øz ¥OÛ«!1›üä±Í™%ºÍãö]°î(–:@<‹ŒÊö×òÆt¦ãº+‡¦%ÌÁ²h´OƒJŒtMÜ>ÀÜÊw3Y´•牋4ǍýʏTì>œú=Íwhyë,¾Ôò×õ¿ßÊa»«þˆѪQ|%6ž™A õ%:øj<>É—ÿ Å_ˆCbõ¥š±ý¯Ýƒï…¶|RëócÍf溪“t.СøTÿ *Ä¿-{†çàczůŽ_–^XþŒ±miB[X±d 1,é”zEù»& î9gœf™9Ð'.;—™i}!ôšåîqêÛ٤ёý£½ÆA–àôe"A$˝Úsäÿ ÷Û #°xŸëí(l »ý3—¥5m! rt`†0~'j2(]S¦¦kv,ÚÇ l¦øJA£Šƒ J3E8ÙiŽ:cÉžúeZ°€¯\®kÖ(79«Ž:¯X”¾³Š&¡* ….‰Ž(ÜíŸ2¥ª‡×Hi²TF¤ò[¨íÈRëÉ䢍mgÑ.Ÿ<öäS0í„ǹÁU´f#Vß;Õ–…P@3ío<ä-±»Ž.L|kªÀê›fÂ6@»eu‚|ÓaÞÆŸ…¨ááå>åŠ?cKü6ùTÍÆ”†sĤÚ;H2RÚ†õ\Ö·Ÿn'¾ ñ#ºI¤Å´%çÁ­‚â7›‹qT3Iï¨ÖÚ5I7Ë!ÅOóŸ¶øÝñØôת¦$Tcö‘[«Ö³šÒ';Aþ ¸èíg A2Z"i¸vdÄ÷.iõ®§)¿]¤À†–‡É&ä{V¶iŽ”.Ó×Õÿ û?h¬Mt–íª[ÿ Ñÿ ÌV(í}=ibÔ¡›¥¢±b Lô¥‡piη_Z<‡z§èŒ)iÖwiÇ 2hÙ3·=’d÷8éŽ1¦¸c¤µ€7›7Ø ð\á)} ¹fËí›pAÃL%âc2 í§æQz¿;T8sæ°qø)QFMð‰XŒÂ±N¢aF¨…8¯!U  Z©RÊ ÖPVÄÀÍin™Ì-GˆªÅËŠ›•zË}º±ŽÍFò¹}Uw×#ä5B¤{î}Ð<ÙD é©¤&‡ïDbàÁôMÁ." ¤‡ú*õ'VŽ|¼´Úgllº¼klz[Æüï÷Aób‡Eÿ dÑ»Xx9ÃÜ£ÁT/`¼¸vI±Ýµ·Ë‚“G³þ*Ÿû´r|*}<¨îºœ @¦mÄ’M¹”.œ«Y–|6ÏU¤jç¥ÕÞqO ˜kDÆÁ¨5ÿ š;ÐЦ¦€GÙk \ –Þ=â¼=SͧµªS°ÚÍpÜãQűÀõ¬?ÃÁ1Ñ•õZà?hóœ€ L¦l{Y*K˜Ù›zc˜–ˆâ ø+¾ ­-Ök¥%ùEÜA'}ˆ><ÊIè“bpÍ/qÞâvoX€w,\úªò6Z[XdÒæ­@Ö—€$òJí#é>'°Ú ôª˜<)4ryÙ£|óAÅn5žêŸyÒäMÝ2{"}‰–¤l÷ûWX\l¾Á¸góÉOÔ /óñB¤f¸çñ[.P˜ZsÊË*ßT܈§QN¢’¡¨§V¼(Üù*eÕ“”5T¨‹Âê¥FŒã½Dü[8'Ò¥a…Ú¶k7a *•›¼'Ò·\8¨ª\@\õ¢¦íq+DÙrmÎ…_ªæ»ŠÓœ¡¯’Ré9MÅ×D™lælffc+ŒÑ,ý™ÿ ¯þǤ=Å’Á7µ÷ÚÛ/“Ü€ñýã¼àí¾ÕÑ+ƒ,uµMâÀÄbm:ÒÎPæ{˜Gz[ƒ¯«® KHà`ߨŠéí¯P8Aq.C‰ à€kòpj´kN¶qô€…Õ,ÜNŠª-­{Zö’æû44‰sŽè‰îVíRœÕm" 6?³D9¡ÇTíÅꋇ`4«¸ÝÁô ï’ýorqКÇZ«x4Žâéþuïf¹µö[P ,Q£éaX±`PÉÍZ ¸äYúg üAx ’6Lê‚xÝÓ*äQ  Ï’¨hÍ =²,6ï#rÃ<¯–£»ƒ‹,–ê•€ aÛsñ'%Æ"®ÛüìBᝠHÚ3ß°©$“XnœÖ’î2ËTeûìxîß ¦å¿çÉ ðK§þ{‘t‚Ϋ¬jéîZ[ ”š7L¥4VÚCE×]m¤Øy”ä4-dz£œ§¸x.*ãÊÊ b÷•h:©‡¦s`BTÁRû¾g⻩‹jø sF¢àJøFl‘È•Xᓁà~*j¯ +(ÚÕ6-£¯÷GŠØy‚<Ç’.F‹Hœw(+)ÜÜâÈzÄäT§FߘãÏ;DmVœ3Àu@mÚüXÝü•3B¨òÌÁÛ<·ÃÜ z,Ì@õÅ·d2]ü8s÷IôÞ¯^Ç9¢u„~ëAŸï4«M? K]­ÅàPl@s_ p:°¬ZR”´›JC[CS.h‹ƒïËœ«Æ]–÷ó‚wR×k7X‰k›‘´ù¦=¡«‰¨¨Â')—71ó’c‡Ðúµ `é.{§p¹ój\Ž{1h{o±Ý=áUÊïGÖŒõ–-BÄm+AZX¶¡ ïHðæ¥JmÙ;…䡟ˆ¦ ° äšiÉg«$üMk5¤L“’çÊvïâï ,=f“"íἊ5ô¬x6{ɏžID0e¸vçmi'︧ºð9$ò¹÷*£’9ÿ ²TÔ…×>JV¥}Œ}$p[bÔ®*[jzS*8 ”·T›Í–ñUîƒwo$áè=LT™ç—~ô·¤ÈÚ$榍q‰„+´kFm)ž‹©i–ËqÞŠ‰à¶ü( ‚•§ •°ò·‡#5ª•µÊ﯅¡X¨šÁ*F#TXJÊ ušJVÍ&=iÄs1‚3•'fý§5Ñ<=[íÞ­ PÚ;ѱÌ_~Ä££8rÞ ²w;’hDT°>ÈG¬8Á²ÚzŽ®ò®qZcqJêäÞ-ö[ܘbň±çb“ж31²n×iƒðÕ;1¶þÉ ªX‰,ßqÏ$>•î íZ¥Z 1{ç൵+ƒÕµ¥°T$§K]á»Ûï*·¤tMI’ÂZbŽÕiÒ˜}bÓ0£ª5›¨ [5Ž^ÝœWøÂÝh° ¢OWun£¤5 a2Z.G2³YL]jåtì”ä ÁÓ‘%"©<Ôúʰsº UZvä‡ÄiÆÒM .÷V·™ø#kèýiíÌ–ª)µT[)BˆõÑ xB¾B€ÖT¨.¥~ð@VĶr#¸ü*åZNDŽH;âi ],©£öØpù(šºãö¼T.uCê•4@ÿ GÕÛ)Cx›®0ø#:ÏðFÒbR\(€€Ä®fã4Þ‰Fä¯HXƒÅ,†öEÑÔÜ]Öv²?tLÃvBY£ú6Êu5ÅAQ³1‘’¬x–HŒÐ‡ ^ ¸KwJôÖŽ5×CÚ¨vÜ«/B0$×k°=ðbÇ(Ï)w±A†Á† 11Í=èQšµ626ŒÜ/`G«µ<}—-Ö7KEHÈÉðóȤmݱû±·ø«Snmá=“䫚mݱŸ¡¶~ó·“äUóJæúòB|E LêŽy´jDÔ$G¢þÐñ7óR8ýÒ…Ç› WVe#·Ÿ p·Fx~•ݤF÷0Èÿ K¯æS<6’¡WШ; ´ÿ ¥Êø\Òuî†åÝ–VNœkÒ7oòX¨Á­Ø÷FÎÑä±g÷ÿ M~Çî=p,X´ ÝÌÚÅ‹’ÃjÖ.ØöÏñ qïQ¤ÓZE†° =6·]܈ s¸>v•Ž^Ý\wq9r‰Î\¸¡kURÒ$­*‹Nq?Þª*!sŠÆ:TU_u±T+øX¡ ®¹¡,ÄâÃBTsÜ$Ø›4m椴zÜK]’’›Pƒ @€#â˜`é¹=I‡fiV•Ôî“nRm+µFPOhÍ0B£ €+¬5c v•:P'ÒyÎ ‰V~‚Ó†ÖuókDoh$å\*ö%Ю=£«…aȼ½÷Û.-½VŒŠ¼'lyî±1¬3ó#ÞE¿ÔS¤gV£m›=§\û"—WU¤ÚǼÿ ÂnÁGŒÃ ‚õN D³õNÚíŒÕ;HôyÄÈ©P¹Ä{:?R‘Ô¨âF÷ø£bÅó® JS|‚R÷ivýáâ€Æé¡è³´IئÑT!§˜•ت‚¬â@q€wnïCWÄ@JU€ê¯m6]Ï:£âx'+ÒðXvÓ¦Úm=–´7œ $ì“B£~p%ÕŸUþ« N@¼üï~w˜ñø5®—'Ôe»¤5ã//€ž~‰Tþ›Å7•#¤× Íö pÄ$ùeåì*«ÓŠEØWEÈsßg ¦ûvžSsLpºÊW–âµEWöˬH; ™!CYõZ ÃÄf æ#1W. \uWâ\,\Çf j’<qTbên›Î[vxx£ë 'ö¨1›˜ÀM¼Pÿ H)ƒêêŒA7s,|F“ 꺸k³9Ìö*ç®;Ö!Ö$Eiž•¹ÒÚ†ýóéÝû¾ÕS®ó$’NÝäŸz¤5r¦ãÄÃD÷Üø!°ø‡Ô&@m™Ì^Ãä­d q5Lnÿ N;.6½·N|#ä"1Nƒx“ã<3('&ñßt  ~ªu”1Tb㫨9ê–›–bìd$ߣ=#ÕãÒmU¯eí$EFù5ýYô櫨æì™Ç—±ssM]·á¿0ÕåJRÓªîiƒ+O58ÖñªŠÒx" \µâá¨i’¤i —Ö ” M+M¤ë9‚‰A¦°Qõ¾ßøK~¼Ã‘g…Ö´~÷Ï[3GUœÒ½#…kàÔ®Ò”‰³·dWV‰IP‰Ú8u¹”E ÖqLj¾êÕCBš{A^Âß;–¨`¯¬ìö ˼ ×tìø.tƐm*n¨y4o&Àx¥n¦×î‡aupáÛj8¿m›è¶ã!o½;ß0y^ý×^EÑ¿ÒjzŒ­)vÚÑnÄL …^ªô× ‡—‚3k Îý­hï]içå–îÏ*÷ñþ»Ô CÒjøjÍznˆ´ ¹#b'Fô‹ ‰v¥'’à'T´ƒHýÍ%M‰ ƒ&ÆÇŒï1 ‘ –Þ ‰i¬s žR-Ÿ kЬá¬7:þ 0ŒÅÒÕ/aÙ¬ÃÝ#Úøœ ©aiVc‰. ¹¦ãµ” ›Yg¦›ÆÎýº°f³7ƒhá·¸­}&D9¡ÂsÉÙÞèŠõØàC™¨ñbFC|´Ü(ŸƒÚÒ-%»'a Ì¿)ËÇn¿úÿ ÞŽX…4ÊÅH^ôΑí@ù¹Eh¶“L8Çjù ¼ÎåVªóR©Ï5uà V4lZß®=€xÖŸ–ÑÈ ÷”¨°¾__yM1tÉ?uÆþIkÄgæ@þ[¢†°XÃJ£j·:nkÅ¢u ‘}âGzö­/IµèЬ¼48q¦F°ŽR¼=ûì{´¯RýicS ÕÛ íNtÍÙï£,w4rêì®»~x(©Uñ§#Ñ&œÕ¤>ÎåÍÓ9’Ö{9eV­[Öjâ²ãu]˜å2›qÑšÕJç0€sÄ|Êëè0튔bÁ>“{×_F`Ø©ºê:µä,v¤ðfc1±"«ÔÍän1#=· Âøv~H½ÐßA¾¿Ü€Óš]Õ; I¾÷ç‚Qi†î¹9ywÔKG˜áñ zQY—§ÃÕZ07§X‚ Áh;ÁM)iÌCH-¯T‘ë|A0{Ò½LÚ–TâÖkÜ’dÀ“rmm»”جPF³ÖcbE§T€ÒxKºû’Ó®7±²(\4ŽÃ¸Uu@j™yĵ;³µ!Á¢b.W¤=mõ´êµK k ¸K^ÜÛ#p*Ü14qkZç5ïë †°5Ï%ÍÛ<Õ¤×Ô¥ê†C Õ´¼ú$ƒÖ“”]Ù¬qÞÚ[4©ý!ûÏ—Áb쳐XµA¬â~`›Çr¸8ìùÝ䫦<>ä÷«?xs´ÇÑ /á;¹øüÊÈÙà{"@Žïzâ¬[âß‚ U_<ÇŸ½4èN˜ú61®qŠu ¦þF£»äJ_ˆÙÎ~ ÞAã–݄ϗrŠD;xTž‘ô`É«…suãO`?³à™ô Lý#Íc5öoæØ‚y´´÷«ZR§<&JÇ+éâô´€i!Àˆ0æAoàðLèÖ-2ŸõW.’t^–(KÁmHµV@xÜÇy®Ñø­â^:Ú3w· 7½¹°ñ¸â¹®:',«Mœ—n­Á+Ãbš LÈ‘ÄnRÓÅœ%¦²‰¨ùQ:¤f‚ "PÕtô¸…cæl…&˜Ú˜Ôkv‹ž+vŠ,=¢v­6—Xy*¥t£«<™:“aîϲ=¦6rO]XI¿Œ÷¤zÚ­›¶ 6÷”w\d ü~v®ˆÌk«^m<ÿ ¢‰Õ\)ùºŽ;… lîÙÅEŠ®cѾ@vnMÏ,¼“ñ•ŽBxðÃzãÇç%3ˆ"}Ù•Åî> BÉú;Ò]V+P˜F_´ßé> Øše|ï‡ÄOmFæÇ ãqÞ$/xÐx­z`ï9"œÜij‚!7.\Td…9M‡•iŽ‹¾‘50ÞŽn¥ß4ÉôO ¹*í^QêËÜÇÌ8=ާs‰'ÂëÙ«á%Pú[O †ÅP¯Vsް.‰,kc¶ ¬A9n˜XÎ-ÞšN["¹QÕ‰ƒMýÁߺXJæÍaLj¾×Ãmã¾ãÚ uñÒþåQô¦¥ /ÄUx:‚ÍÜ’ Đ©ØÝ3V¨‰ÕnÐ6ó*óúK­«…c ¯U òhsý­jóÔj#,ímŒRµ«lbïUTŒÑ8†Ä0œÏr`ð¡¬É Ї ë"À² ™ 6¥ f¶ ¢ÚoܱԷ-<Àî)†a¶ž'Ú»¨TXqØæ¶÷YÄHy˜9ÈIW­YÀuMFë ºÏ’AqÌ4·/Ú †ô'i$øä­=Ä Ý|öK×40è|È6p‘0§)o¥ctî§H+CA-“ xØ|ÐXАç l8íºð3Ø:³¤¬KX¯UÿÙ #!/usr/bin/ruby # encoding: binary # Phusion Passenger - https://www.phusionpassenger.com/ # Copyright (c) 2010-2025 Asynchronous B.V. # # "Passenger", "Phusion Passenger" and "Union Station" are registered # trademarks of Asynchronous B.V. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. ## Magic comment: begin bootstrap ## source_root = File.expand_path("..", File.dirname(__FILE__)) $LOAD_PATH.unshift("#{source_root}/src/ruby_supportlib") begin require 'rubygems' rescue LoadError end require 'phusion_passenger' ## Magic comment: end bootstrap ## PhusionPassenger.locate_directories # The Apache executable may be located in an 'sbin' folder. We add # the 'sbin' folders to $PATH just in case. On some systems # 'sbin' isn't in $PATH unless the user is logged in as root from # the start (i.e. not via 'su' or 'sudo'). EXTRA_INSTALLER_PATHS = ":/usr/sbin:/sbin:/usr/local/sbin" ENV["PATH"] += EXTRA_INSTALLER_PATHS require 'optparse' require 'stringio' PhusionPassenger.require_passenger_lib 'constants' PhusionPassenger.require_passenger_lib 'platform_info/ruby' PhusionPassenger.require_passenger_lib 'platform_info/operating_system' PhusionPassenger.require_passenger_lib 'platform_info/linux' PhusionPassenger.require_passenger_lib 'platform_info/apache' PhusionPassenger.require_passenger_lib 'platform_info/apache_detector' PhusionPassenger.require_passenger_lib 'abstract_installer' PhusionPassenger.require_passenger_lib 'config/validate_install_command' PhusionPassenger.require_passenger_lib 'utils/terminal_choice_menu' class Installer < PhusionPassenger::AbstractInstaller include PhusionPassenger TerminalChoiceMenu = PhusionPassenger::Utils::TerminalChoiceMenu AUTOINSTALL_BEGIN_LOAD_BLOCK = "### Begin automatically installed #{PROGRAM_NAME} load snippet ###" AUTOINSTALL_END_LOAD_BLOCK = "### End automatically installed #{PROGRAM_NAME} load snippet ###" AUTOINSTALL_BEGIN_CONF_BLOCK = "### Begin automatically installed #{PROGRAM_NAME} config snippet ###" AUTOINSTALL_END_CONF_BLOCK = "### End automatically installed #{PROGRAM_NAME} config snippet ###" def dependencies specs = [ 'depcheck_specs/compiler_toolchain', 'depcheck_specs/ruby', 'depcheck_specs/gems', 'depcheck_specs/libs', 'depcheck_specs/apache2' ] ids = [ 'cc', 'c++', 'libcurl-dev', 'zlib-dev', 'apache2', 'rake', 'ruby-openssl', 'rubygems' ] if @languages.include?("ruby") if PlatformInfo.passenger_needs_ruby_dev_header? ids << 'ruby-dev' end ids << 'rack' end # On macOS Curl uses TransportSecurity instead of OpenSSL, except on High Sierra or later. if !(PlatformInfo.os_name_simple == 'macosx' && PlatformInfo.os_version <= '10.13') ids << 'openssl-dev' end if PlatformInfo.apxs2_needed_for_building_apache_modules? ids << 'apache2-dev' end # Some broken servers don't have apr-config or apu-config installed. # Nevertheless, it is possible to compile Apache modules if Apache # was configured with --included-apr. So here we check whether # apr-config and apu-config are available. If they're not available, # then we only register them as required dependency if no Apache # module can be compiled without their presence. if needs_apr_and_apu? ids << 'apr-dev' ids << 'apu-dev' end return [specs, ids] end def needs_apr_and_apu? (PlatformInfo.apr_config && PlatformInfo.apu_config) || PlatformInfo.apr_config_needed_for_building_apache_modules? end def install_doc_url "https://www.phusionpassenger.com/library/install/apache/" end def troubleshooting_doc_url "https://www.phusionpassenger.com/library/admin/apache/troubleshooting/" end def run_steps PlatformInfo.verbose = true if @verbose_depcheck if PhusionPassenger.build_system_dir.nil? # Invariant: PhusionPassenger.custom_packaged? if apache_module_available? notify_apache_module_installed show_deployment_example else install_apache_module_from_native_package || exit(1) end exit end Dir.chdir(PhusionPassenger.build_system_dir) show_welcome_screen check_selinux_and_suggest_rpm query_interested_languages check_gem_install_permission_problems || exit(1) check_directory_accessible_by_web_server check_dependencies || exit(1) check_whether_there_are_multiple_apache_installs || exit check_whether_apache_uses_compatible_mpm check_whether_os_is_broken check_whether_system_has_enough_ram check_write_permission_to_passenger_root || exit(1) check_write_permission_to_web_server_config_files || exit(1) if compile_apache2_module install_apache2_config_snippets || exit(1) validate_install show_deployment_example else show_possible_solutions_for_compilation_and_installation_problems exit(1) end end private def show_welcome_screen render_template 'apache2/welcome', :version => VERSION_STRING wait end def check_selinux_and_suggest_rpm return if !PhusionPassenger.originally_packaged? || PlatformInfo.os_name_simple != "linux" || !(PlatformInfo.linux_distro_tags.include?(:rhel) || PlatformInfo.linux_distro_tags.include?(:centos)) !PlatformInfo.find_command('sestatus') begin sestatus = `sestatus` getenforce = `getenforce` rescue Errno::ENOENT return end status = sestatus.scan(/^SELinux status:.*/).first if status =~ /enabled/ && getenforce =~ /Enforcing/ new_screen render_template 'apache2/rpm_installation_recommended' wait end end def query_interested_languages menu = TerminalChoiceMenu.new(["Ruby", "Python", "Node.js", "Meteor"]) menu["Ruby"].checked = interesting_language?('ruby') menu["Python"].checked = interesting_language?('python') menu["Node.js"].checked = interesting_language?('nodejs', 'node') menu["Meteor"].checked = interesting_language?('meteor') new_screen puts "Which languages are you interested in?" puts if interactive? puts "Use to select." puts "If the menu doesn't display correctly, press '!'" else puts "Override selection with --languages." end puts if interactive? begin menu.query rescue Interrupt raise Abort end else menu.display_choices puts end @languages = menu.selected_choices.map{ |x| x.downcase.gsub(/\./, '') } end def interesting_language?(name, command = nil) if @languages return @languages.include?(name) else return !!PlatformInfo.find_command(command || name) end end def check_whether_there_are_multiple_apache_installs new_screen puts 'Checking whether there are multiple Apache installations...' output = StringIO.new detector = PlatformInfo::ApacheDetector.new(output) begin detector.detect_all detector.report @apache2 = detector.result_for(PlatformInfo.apxs2) if @apache2.nil? # Print an extra newline because the autodetection routines # may have run some commands which printed stuff to stderr. puts if Process.uid == 0 render_template 'apache2/apache_install_broken', :apxs2 => PlatformInfo.apxs2, :extra_paths => EXTRA_INSTALLER_PATHS, :sudo_s_e => PhusionPassenger::PlatformInfo.ruby_sudo_shell_command("-E"), :ruby => PhusionPassenger::PlatformInfo.ruby_command, :passenger_config => "#{PhusionPassenger.bin_dir}/passenger-config" else render_template 'apache2/run_installer_as_root_for_apache_analysis', :sudo => PhusionPassenger::PlatformInfo.ruby_sudo_command, :sudo_s_e => PhusionPassenger::PlatformInfo.ruby_sudo_shell_command("-E"), :ruby => PhusionPassenger::PlatformInfo.ruby_command, :installer => "#{PhusionPassenger.bin_dir}/passenger-install-apache2-module #{ORIG_ARGV.join(' ')}" end return false elsif detector.results.size > 1 other_installs = detector.results - [@apache2] render_template 'apache2/multiple_apache_installations_detected', :current => @apache2, :other_installs => other_installs puts if interactive? # @apache.apxs2 can be nil, which on macOS >= 10.13 High Sierra # means that we're using the OS-provided Apache installation. result = prompt_confirmation "Are you sure you want to install " + "against Apache #{@apache2.version} (#{@apache2.apxs2 || 'OS-provided install'})?" if !result puts line render_template 'apache2/installing_against_a_different_apache', :other_installs => other_installs end return result else puts 'Continuing installation because --auto is given.' return true end else puts 'Only a single installation detected. This is good.' return true end ensure detector.finish end end def check_whether_apache_uses_compatible_mpm # 'apache2ctl -V' output is in the form of: # # Server MPM: Prefork # <--- this line is not always available! # ... # Server compiled with.... # -D APACHE_MPM_DIR="server/mpm/prefork" output = PlatformInfo.apache2ctl_V if output output =~ /^Server MPM: +(.*)$/ if $1 mpm = $1.downcase else output =~ /APACHE_MPM_DIR="server\/mpm\/(.*)"/ if $1 mpm = $1.downcase else mpm = nil end end if mpm != "prefork" && mpm != "worker" && mpm != "event" new_screen render_template 'apache2/apache_must_be_compiled_with_compatible_mpm', :current_mpm => mpm wait end elsif !@apache2.config_file_broken? # 'output' may be nil because the config file is broken (see # PlatformInfo.apache2ctl_V for more information), but we already # warn the user about in #validate_install. # So here we only warn about not being able to detect an MPM type # if 'output' is nil but not as a result of the config file being broken. new_screen render_template 'apache2/mpm_unknown', :control_command => @apache2.ctl wait end end def check_write_permission_to_passenger_root File.new("__test__.txt", "w").close return true rescue SystemCallError puts line if Process.uid == 0 render_template 'installer_common/cannot_access_files_as_root', :type => "directory", :files => [PhusionPassenger.build_system_dir] else render_template 'installer_common/run_installer_as_root', :dir => PhusionPassenger.build_system_dir, :sudo => PhusionPassenger::PlatformInfo.ruby_sudo_command, :sudo_s_e => PhusionPassenger::PlatformInfo.ruby_sudo_shell_command("-E"), :ruby => PhusionPassenger::PlatformInfo.ruby_command, :installer => "#{PhusionPassenger.bin_dir}/passenger-install-apache2-module #{ORIG_ARGV.join(' ')}" end return false ensure File.unlink("__test__.txt") rescue nil end def check_write_permission_to_web_server_config_files return true if !@update_config config_file = PlatformInfo.httpd_default_config_file return if !config_file || !File.exist?(config_file) all_config_files = PlatformInfo.httpd_included_config_files(config_file) if all_config_files[:unreadable_files].any? puts line if Process.uid == 0 render_template 'installer_common/cannot_access_files_as_root', :access => "read from", :files => all_config_files[:unreadable_files] else render_template 'installer_common/run_installer_as_root', :access => "read from", :desc => "an Apache configuration file", :sudo => PhusionPassenger::PlatformInfo.ruby_sudo_command, :sudo_s_e => PhusionPassenger::PlatformInfo.ruby_sudo_shell_command("-E"), :ruby => PhusionPassenger::PlatformInfo.ruby_command, :installer => "#{PhusionPassenger.bin_dir}/passenger-install-apache2-module #{ORIG_ARGV.join(' ')}" end puts render_template 'apache2/present_choice_for_no_update_config' return false end unwriteable_files = [] all_config_files[:files].each do |filename| if !File.writable_real?(filename) unwriteable_files << filename end end if unwriteable_files.empty? return true else puts line if Process.uid == 0 render_template 'installer_common/cannot_access_files_as_root', :files => unwriteable_files else render_template 'installer_common/run_installer_as_root', :desc => "an Apache configuration file", :sudo => PhusionPassenger::PlatformInfo.ruby_sudo_command, :sudo_s_e => PhusionPassenger::PlatformInfo.ruby_sudo_shell_command("-E"), :ruby => PhusionPassenger::PlatformInfo.ruby_command, :installer => "#{PhusionPassenger.bin_dir}/passenger-install-apache2-module #{ORIG_ARGV.join(' ')}" end puts render_template 'apache2/present_choice_for_no_update_config' return false end end def compile_apache2_module puts line puts 'Compiling and installing Apache 2 module...' if @compile puts "cd #{PhusionPassenger.build_system_dir}" if ENV['TRACE'] rake = "#{PlatformInfo.rake_command} --trace RELEASE=yes" else rake = "#{PlatformInfo.rake_command} RELEASE=yes" end command = "env NOEXEC_DISABLE=1 #{rake} apache2:clean apache2" if PhusionPassenger.packaging_method == "homebrew" # Running apache2:clean deletes some object files needed # by passenger-install-nginx-module, so we ensure those # object files are compiled. command << " nginx" end return sh(command) else puts "Skipping compilation" return true end end def load_snippet return "LoadModule passenger_module #{PhusionPassenger.apache2_module_path}" end def config_snippet result = "\n" + " PassengerRoot #{PhusionPassenger.install_spec}\n" + " PassengerDefaultRuby #{PlatformInfo.ruby_command}\n" if PhusionPassenger.packaging_method == "rpm" result << " PassengerInstanceRegistryDir /var/run/passenger-instreg\n" end result << "" result end def apache2_config_snippets return "#{load_snippet}\n#{config_snippet}\n" end def backup_config_files(config_file, all_config_files) now = Time.now.strftime("%Y-%m-%d-%H:%M:%S") archive = "#{config_file}.#{GLOBAL_NAMESPACE_DIRNAME}-backup-#{now}.tar.gz" backup_files = all_config_files.dup # Some people create a regular file in /etc/apache2/mods-enabled, for convenience # reasons. This file is not actually managed by a2enmod. We will remove such files # because we're going to use mods-eanbled ourselves, so we need to back them up. if (dir = PlatformInfo.httpd_mods_enabled_directory) && PlatformInfo.a2enmod if File.file?("#{dir}/#{APACHE2_MODULE_CONF_NAME}.load") backup_files << "#{dir}/#{APACHE2_MODULE_CONF_NAME}.load" end if File.file?("#{dir}/#{APACHE2_MODULE_CONF_NAME}.conf") backup_files << "#{dir}/#{APACHE2_MODULE_CONF_NAME}.conf" end end puts "Backing up existing configuration files to #{archive}..." backup_files.uniq! backup_files.map! { |x| x.sub(/^\//, '') } Dir.chdir("/") do sh! "tar", "-czf", archive, *backup_files end end def uninstall_or_comment_out_existing_config_snippets(all_config_files) files_containing_autoinstall_load_blocks = [] files_containing_autoinstall_conf_blocks = [] # Some people create a regular file in /etc/apache2/mods-enabled, for convenience # reasons. This file is not actually managed by a2enmod. We remove such files # because we're going to use mods-enabled ourselves. They've already been backed up. if (dir = PlatformInfo.httpd_mods_enabled_directory) && PlatformInfo.a2enmod filename = "#{dir}/#{APACHE2_MODULE_CONF_NAME}.load" if File.file?(filename) && !File.symlink?(filename) puts "Removing #{filename}" File.unlink(filename) end filename = "#{dir}/#{APACHE2_MODULE_CONF_NAME}.conf" if File.file?(filename) && !File.symlink?(filename) puts "Removing #{filename}" File.unlink(filename) end end # Uncomment Phusion Passenger config snippets. all_config_files.each do |filename| next if !File.exist?(filename) contents = File.open(filename, "rb") do |f| f.read end if contents =~ /#{Regexp.escape AUTOINSTALL_BEGIN_LOAD_BLOCK}.*?#{Regexp.escape AUTOINSTALL_END_LOAD_BLOCK}/m files_containing_autoinstall_load_blocks << filename end if contents =~ /#{Regexp.escape AUTOINSTALL_BEGIN_CONF_BLOCK}.*?#{Regexp.escape AUTOINSTALL_END_CONF_BLOCK}/m files_containing_autoinstall_conf_blocks << filename end subst1 = contents.gsub!(/^([ \t]*LoadModule[ \t]+passenger_module[ \t]+.*)$/i, '# \1') subst2 = contents.gsub!(/^([ \t]*PassengerRoot[ \t]+.*)$/i, '# \1') subst3 = contents.gsub!(/^([ \t]*PassengerDefaultRuby[ \t]+.*)$/i, '# \1') if subst1 || subst2 || subst3 puts "Uninstalling previous #{PROGRAM_NAME} from #{filename}..." File.open(filename, "wb") do |f| f.write(contents) end end end # If there are multiple auto-install comment blocks, remove the duplicates. # First, we remove all comment blocks from all files besides the first one. if files_containing_autoinstall_load_blocks.size > 1 files_containing_autoinstall_load_blocks[1..-1].each do |filename| puts "Removing duplicate load snippets from #{filename}..." remove_comment_blocks(filename, AUTOINSTALL_BEGIN_LOAD_BLOCK, AUTOINSTALL_END_LOAD_BLOCK) end end if files_containing_autoinstall_conf_blocks.size > 1 files_containing_autoinstall_conf_blocks[1..-1].each do |filename| puts "Removing duplicate conf snippets from #{filename}..." remove_comment_blocks(filename, AUTOINSTALL_BEGIN_CONF_BLOCK, AUTOINSTALL_END_CONF_BLOCK) end end # Then we are left with exactly 0 or exactly 1 file with comment blocks # of each type. There may be duplicates inside that single file, so # remove duplicates there too. if files_containing_autoinstall_load_blocks.size > 0 filename = files_containing_autoinstall_load_blocks[0] puts "Removing duplicate load snippets inside #{filename}..." remove_duplicate_comment_blocks(filename, AUTOINSTALL_BEGIN_LOAD_BLOCK, AUTOINSTALL_END_LOAD_BLOCK) end if files_containing_autoinstall_conf_blocks.size > 0 filename = files_containing_autoinstall_conf_blocks[0] puts "Removing duplicate configuration snippets inside #{filename}..." remove_duplicate_comment_blocks(filename, AUTOINSTALL_BEGIN_CONF_BLOCK, AUTOINSTALL_END_CONF_BLOCK) end # One or more files may have been removed, so filter out the ones # that are left. all_config_files.reject! do |filename| !File.exist?(filename) end end def remove_comment_blocks(filename, begin_marker, end_marker) contents = File.open(filename, "rb") do |f| f.read end regexp = /#{Regexp.escape begin_marker}.*?#{Regexp.escape end_marker}\n?/m contents.gsub!(regexp, '') File.open(filename, "wb") do |f| f.write(contents) end end def remove_duplicate_comment_blocks(filename, begin_marker, end_marker) contents = File.open(filename, "rb") do |f| f.read end regexp = /#{Regexp.escape begin_marker}.*?#{Regexp.escape end_marker}\n?/m if m = regexp.match(contents) offset = m.end(0) rest = contents.slice!(m.end(0) .. -1) rest.gsub!(regexp, '') contents << rest File.open(filename, "wb") do |f| f.write(contents) end end end def add_new_config_snippets(all_config_files) # Look for the file containing the auto-install load and conf comment blocks. # The uninstall_or_comment_out_existing_config_snippets method has already # guaranteed that there is at most 1 file per comment block type, and that # inside each file there are no duplicate comment blocks. load_block_file = find_config_file_containing_comment_block(all_config_files, AUTOINSTALL_BEGIN_LOAD_BLOCK, AUTOINSTALL_END_LOAD_BLOCK) conf_block_file = find_config_file_containing_comment_block(all_config_files, AUTOINSTALL_BEGIN_CONF_BLOCK, AUTOINSTALL_END_CONF_BLOCK) if load_block_file && conf_block_file puts "Updating #{PROGRAM_NAME} module load snippet inside #{load_block_file}..." update_comment_block(load_block_file, AUTOINSTALL_BEGIN_LOAD_BLOCK, AUTOINSTALL_END_LOAD_BLOCK, load_snippet) puts "Updating #{PROGRAM_NAME} configuration snippet inside #{conf_block_file}..." update_comment_block(conf_block_file, AUTOINSTALL_BEGIN_CONF_BLOCK, AUTOINSTALL_END_CONF_BLOCK, config_snippet) elsif !load_block_file && !conf_block_file create_load_snippet_file(:maybe_in_mods_available) create_conf_snippet_file(:maybe_in_mods_available) if PlatformInfo.httpd_mods_available_directory && PlatformInfo.a2enmod sh! "#{PlatformInfo.a2enmod} #{APACHE2_MODULE_CONF_NAME}" end # It looks like either the load or conf file isn't available. # If the file that is available is inside mods-available, then it # means that the mods-available files are broken. elsif is_file_inside_mods_available?(load_block_file, "#{APACHE2_MODULE_CONF_NAME}.load") || is_file_inside_mods_available?(conf_block_file, "#{APACHE2_MODULE_CONF_NAME}.conf") # We fix it if a2enmod is available. Otherwise, we remove the block. if PlatformInfo.a2enmod if !load_block_file create_load_snippet_file(:must_be_in_mods_available) else create_conf_snippet_file(:must_be_in_mods_available) end else if load_block_file puts "Removing load snippets from #{filename}..." remove_comment_blocks(load_block_file, AUTOINSTALL_BEGIN_LOAD_BLOCK, AUTOINSTALL_END_LOAD_BLOCK) else puts "Removing configuration snippets from #{filename}..." remove_comment_blocks(conf_block_file, AUTOINSTALL_BEGIN_CONF_BLOCK, AUTOINSTALL_END_CONF_BLOCK) end create_load_snippet_file(:must_be_in_mods_available) create_conf_snippet_file(:must_be_in_mods_available) end sh! "#{PlatformInfo.a2enmod} passenger" else if !load_block_file create_load_snippet_file(:not_in_mods_available) puts "Updating #{PROGRAM_NAME} configuration snippet inside #{conf_block_file}..." update_comment_block(conf_block_file, AUTOINSTALL_BEGIN_CONF_BLOCK, AUTOINSTALL_END_CONF_BLOCK, config_snippet) else create_conf_snippet_file(:not_in_mods_available) puts "Updating #{PROGRAM_NAME} module load snippet inside #{load_block_file}..." update_comment_block(load_block_file, AUTOINSTALL_BEGIN_LOAD_BLOCK, AUTOINSTALL_END_LOAD_BLOCK, load_snippet) end end end def find_config_file_containing_comment_block(all_config_files, begin_marker, end_marker) regexp = /#{Regexp.escape begin_marker}.*?#{Regexp.escape end_marker}/m all_config_files.each do |filename| contents = File.open(filename, "rb") do |f| f.read end if contents =~ regexp return filename end end return nil end def update_comment_block(filename, begin_marker, end_marker, block_contents) regexp = /#{Regexp.escape begin_marker}.*?#{Regexp.escape end_marker}\n?/m contents = File.open(filename, "rb") do |f| f.read end if contents.sub!(regexp, "#{begin_marker}\n#{block_contents}\n#{end_marker}\n") File.open(filename, "wb") do |f| f.write(contents) end return true else return false end end def remove_comment_blocks(filename, begin_marker, end_marker) regexp = /#{Regexp.escape begin_marker}.*?#{Regexp.escape end_marker}\n?/m contents = File.open(filename, "rb") do |f| f.read end contents.gsub!(regexp, "") File.open(filename, "wb") do |f| f.write(contents) end end def is_file_inside_mods_available?(filename, basename) if dir = PlatformInfo.httpd_mods_available_directory return filename == "#{dir}/#{basename}" else return false end end def create_load_snippet_file(where) case where when :maybe_in_mods_available if PlatformInfo.httpd_mods_available_directory && PlatformInfo.a2enmod filename = "#{PlatformInfo.httpd_mods_available_directory}/#{APACHE2_MODULE_CONF_NAME}.load" else filename = PlatformInfo.httpd_default_config_file end when :must_be_in_mods_available if PlatformInfo.httpd_mods_available_directory && PlatformInfo.a2enmod filename = "#{PlatformInfo.httpd_mods_available_directory}/#{APACHE2_MODULE_CONF_NAME}.load" else raise "Apache does not support the mods-available directory" end when :not_in_mods_available filename = PlatformInfo.httpd_default_config_file else raise ArgumentError end if File.exist?(filename) # If this is a file inside mods-available, and the file didn't have a symlink # in mods-enabled, then the uninstall phase did not remove duplicates from this # file. So here we remove duplicates again. puts "Removing duplicate load snippets inside #{filename}..." remove_duplicate_comment_blocks(filename, AUTOINSTALL_BEGIN_LOAD_BLOCK, AUTOINSTALL_END_LOAD_BLOCK) puts "Installing #{PROGRAM_NAME} module load snippet to #{filename}..." should_add = !update_comment_block(filename, AUTOINSTALL_BEGIN_LOAD_BLOCK, AUTOINSTALL_END_LOAD_BLOCK, load_snippet) else puts "Installing #{PROGRAM_NAME} module load snippet to #{filename}..." should_add = true end if should_add File.open(filename, "ab") do |f| f.write("\n#{AUTOINSTALL_BEGIN_LOAD_BLOCK}\n" + "#{load_snippet}\n" + "#{AUTOINSTALL_END_LOAD_BLOCK}\n") end end end def create_conf_snippet_file(where) case where when :maybe_in_mods_available if PlatformInfo.httpd_mods_available_directory && PlatformInfo.a2enmod filename = "#{PlatformInfo.httpd_mods_available_directory}/#{APACHE2_MODULE_CONF_NAME}.conf" else filename = PlatformInfo.httpd_default_config_file end when :must_be_in_mods_available if PlatformInfo.httpd_mods_available_directory && PlatformInfo.a2enmod filename = "#{PlatformInfo.httpd_mods_available_directory}/#{APACHE2_MODULE_CONF_NAME}.conf" else raise "Apache does not support the mods-available directory" end when :not_in_mods_available filename = PlatformInfo.httpd_default_config_file else raise ArgumentError end if File.exist?(filename) # If this is a file inside mods-available, and the file didn't have a symlink # in mods-enabled, then the uninstall phase did not remove duplicates from this # file. So here we remove duplicates again. puts "Removing duplicate configuration snippets inside #{filename}..." remove_duplicate_comment_blocks(filename, AUTOINSTALL_BEGIN_CONF_BLOCK, AUTOINSTALL_END_CONF_BLOCK) puts "Installing #{PROGRAM_NAME} module configuration snippet to #{filename}..." should_add = !update_comment_block(filename, AUTOINSTALL_BEGIN_CONF_BLOCK, AUTOINSTALL_END_CONF_BLOCK, config_snippet) else puts "Installing #{PROGRAM_NAME} module configuration snippet to #{filename}..." should_add = true end if should_add File.open(filename, "ab") do |f| f.write("\n#{AUTOINSTALL_BEGIN_CONF_BLOCK}\n" + "#{config_snippet}\n" + "#{AUTOINSTALL_END_CONF_BLOCK}\n") end end end def install_apache2_config_snippets if !@update_config show_apache2_config_snippets return true end config_file = PlatformInfo.httpd_default_config_file if config_file && File.exist?(config_file) puts line puts "Updating Apache configuration files..." config_file = PlatformInfo.httpd_default_config_file all_config_files = PlatformInfo.httpd_included_config_files(config_file)[:files] backup_config_files(config_file, all_config_files) if @backup_config uninstall_or_comment_out_existing_config_snippets(all_config_files) add_new_config_snippets(all_config_files) return true else show_apache2_config_snippets return true end end def show_apache2_config_snippets puts line render_template 'apache2/config_snippets', :snippet => apache2_config_snippets wait end def validate_install # By compiling Passenger, we may have changed Apache's state. For example, # if 'apache2ctl -V' failed because it referenced an Apache module that # didn't exist, then it may exist now, causing 'apache2ctl -V' to succeed. # We want ValidateInstallCommand to reflect the current Apache state, # not the one before compilation started, so we clear PlatformInfo # memoizations here. PlatformInfo.clear_memoizations new_screen puts "Validating installation..." puts args = ["--validate-apache2", "--invoked-from-installer"] args << "--auto" if @auto # The validator will get the path to apxs2 from the APXS2 environment # variable that this installer sets. validator = PhusionPassenger::Config::ValidateInstallCommand.new(args) exit_code = validator.run_and_get_exit_code STDOUT.write(@colors.default_terminal_color) case exit_code when PhusionPassenger::Config::ValidateInstallCommand::FAIL_EXIT_CODE puts "Please solve the above issues, then press ENTER to continue." wait when PhusionPassenger::Config::ValidateInstallCommand::WARN_EXIT_CODE puts "Press ENTER to continue." wait else exit(exit_code) end end def show_deployment_example new_screen render_template 'apache2/deployment_example', :deployment_guide_url => "https://www.phusionpassenger.com/library/deploy/apache/deploy/", :phusion_website => PHUSION_WEBSITE, :passenger_website => PASSENGER_WEBSITE end def show_possible_solutions_for_compilation_and_installation_problems new_screen render_template 'apache2/possible_solutions_for_compilation_and_installation_problems', :support_url => SUPPORT_URL end def apache_module_available? return File.exist?(PhusionPassenger.apache2_module_path) end def install_apache_module_from_native_package case PhusionPassenger.packaging_method when 'deb' sh! "sudo apt-get update" sh! "sudo apt-get install #{DEB_APACHE_MODULE_PACKAGE}" return true when 'rpm' sh! "sudo yum install #{RPM_APACHE_MODULE_PACKAGE}-#{VERSION_STRING}" return true else puts "The #{PROGRAM_NAME} Apache module package is not installed." puts "Please ask your packager or operating system vendor how to install it." return false end end def notify_apache_module_installed render_template 'apache2/notify_apache_module_installed' wait end end ORIG_ARGV = ARGV.dup options = { :compile => true, :update_config => false, :backup_config => true } parser = OptionParser.new do |opts| opts.banner = "Usage: passenger-install-apache2-module [options]" opts.separator "" indent = ' ' * 37 opts.separator "Options:" opts.on("-a", "--auto", String, "Automatically build the Apache module,\n" << "#{indent}without interactively asking for user\n" << "#{indent}input.") do options[:auto] = true end opts.on("--apxs2-path PATH", String, "Path to 'apxs2' command.") do |value| ENV['APXS2'] = value end opts.on("--apr-config-path PATH", String, "Path to 'apr-config' command.") do |value| ENV['APR_CONFIG'] = value end opts.on("--languages NAMES", "Comma-separated list of interested\n" << "#{indent}languages (e.g.\n" << "#{indent}'ruby,python,nodejs,meteor')") do |value| options[:languages] = value.split(",") end opts.on("--no-compile", "Skip compilation.") do options[:compile] = false end #opts.on("--no-update-config", "Do not automatically update Apache config\n" << # "#{indent}files.") do # options[:update_config] = false #end #opts.on("--no-backup-config", "When updating Apache config files, do not\n" << # "#{indent}create backups of the existing files.") do # options[:backup_config] = false #end opts.on("--force-colors", "Display colors even if stdout is not a TTY") do options[:colorize] = true end opts.on("--verbose-depcheck", "Show more dependency checking-related logs") do options[:verbose_depcheck] = true end opts.on("--snippet", "Show just the Apache config snippet.") do options[:snippet] = true end end begin parser.parse! rescue OptionParser::ParseError => e puts e puts puts "Please see '--help' for valid options." exit 1 end installer = Installer.new(options) if options[:snippet] puts installer.send(:apache2_config_snippets) else installer.run end