{"id":797,"date":"2013-08-01T00:00:00","date_gmt":"2013-08-01T00:00:00","guid":{"rendered":"https:\/\/fir3netwp.gmsrrpobkbd.com\/2013\/08\/01\/how-do-i-compile-modwgsi-for-python-27\/"},"modified":"2021-07-31T17:14:42","modified_gmt":"2021-07-31T17:14:42","slug":"how-do-i-compile-modwgsi-for-python-27","status":"publish","type":"post","link":"https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html","title":{"rendered":"How do I compile mod_wgsi for Python 2.7"},"content":{"rendered":"

Recently I found myself in a situation where I needed to recompile mod_wgsi against a newer version of Python.<\/p>\n

This involves recompiling Python with the correct flags, then recompiling mod_wsgi using the newly compiled Python. Below shows the steps,<\/p>\n

Check Version<\/strong><\/h2>\n

First of all check what version of Python mod_wsgi was compiled with.<\/p>\n

[root@server]# ldd \/usr\/lib64\/httpd\/modules\/mod_wsgi.so
\nlibpython2.4.so.1.0<\/strong><\/span> => \/usr\/lib64\/libpython2.4.so.1.0 (0x00002b3149c4e000)
\nlibpthread.so.0 => \/lib64\/libpthread.so.0 (0x00002b3149f82000)
\nlibdl.so.2 => \/lib64\/libdl.so.2 (0x00002b314a19d000)
\nlibutil.so.1 => \/lib64\/libutil.so.1 (0x00002b314a3a2000)
\nlibm.so.6 => \/lib64\/libm.so.6 (0x00002b314a5a5000)
\nlibc.so.6 => \/lib64\/libc.so.6 (0x00002b314a828000)
\n\/lib64\/ld-linux-x86-64.so.2 (0x000000364b200000)<\/p>\n

 <\/p>\n

Compile Python<\/strong><\/h2>\n

Next, compile Python. The option to build a shared library is also used to prevent future issues (details can be found here<\/a>).<\/p>\n

yum groupinstall “Development tools”
\nyum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel<\/p>\n

cd ~
\nwget
http:\/\/www.python.org\/ftp\/python\/2.7.5\/Python-2.7.5.tgz<\/a>
\ntar xvf Python-2.7.5.tgz
\ncd Python-2.7.5<\/p>\n

.\/configure –enable-shared –with-threads
\nmake
\nmake install<\/p>\n

Once you have complete these steps you may get the error,<\/p>\n

\/usr\/local\/bin\/python2.7: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory<\/p>\n

There are 2 ways to fix this. You can :<\/p>\n

1. run ‘echo export LD_LIBRARY_PATH=\/usr\/local\/lib >> \/etc\/profile’ or<\/p>\n

2. configure the following softlinks<\/p>\n

ln -s \/usr\/local\/lib\/libpython2.7.so.1.0 \/usr\/lib\/
\nln -s \/usr\/local\/lib\/libpython2.7.so \/usr\/<\/p>\n

 <\/p>\n

Compile WSGI<\/strong><\/h2>\n

Finally we compile wsgi,<\/p>\n

cd ~
\nwget
\ntar xvf mod_wsgi-3.4.tar.gz
\ncd mod_wsgi-3.4<\/p>\n

.\/configure\u00a0 –with-python=\/usr\/local\/bin\/python2.7
\nmake
\nmake install<\/p>\n

 <\/p>\n

References<\/strong><\/h2>\n

http:\/\/stackoverflow.com\/questions\/7880454\/python-executable-not-finding-libpython-shared-library<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

Recently I found myself in a situation where I needed to recompile mod_wgsi against a newer version of Python. This involves recompiling Python with the correct flags, then recompiling mod_wsgi using the newly compiled Python. Below shows the steps, Check Version First of all check what version of Python mod_wsgi was compiled with. [root@server]# ldd … Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"yoast_head":"\nHow do I compile mod_wgsi for Python 2.7 - Fir3net<\/title>\n<meta name=\"description\" content=\"Recently I found myself in a situation where I needed to recompile mod_wgsi against a newer version of Python. This involves recompiling Python with the\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How do I compile mod_wgsi for Python 2.7 - Fir3net\" \/>\n<meta property=\"og:description\" content=\"Recently I found myself in a situation where I needed to recompile mod_wgsi against a newer version of Python. This involves recompiling Python with the\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html\" \/>\n<meta property=\"og:site_name\" content=\"Fir3net\" \/>\n<meta property=\"article:published_time\" content=\"2013-08-01T00:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-07-31T17:14:42+00:00\" \/>\n<meta name=\"author\" content=\"Rick Donato\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rick Donato\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html\"},\"author\":{\"name\":\"Rick Donato\",\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/person\/ab35009601b7687ee1c5310be6038037\"},\"headline\":\"How do I compile mod_wgsi for Python 2.7\",\"datePublished\":\"2013-08-01T00:00:00+00:00\",\"dateModified\":\"2021-07-31T17:14:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html\"},\"wordCount\":309,\"publisher\":{\"@id\":\"https:\/\/www.fir3net.com\/#organization\"},\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html\",\"url\":\"https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html\",\"name\":\"How do I compile mod_wgsi for Python 2.7 - Fir3net\",\"isPartOf\":{\"@id\":\"https:\/\/www.fir3net.com\/#website\"},\"datePublished\":\"2013-08-01T00:00:00+00:00\",\"dateModified\":\"2021-07-31T17:14:42+00:00\",\"description\":\"Recently I found myself in a situation where I needed to recompile mod_wgsi against a newer version of Python. This involves recompiling Python with the\",\"breadcrumb\":{\"@id\":\"https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.fir3net.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Programming\",\"item\":\"https:\/\/www.fir3net.com\/programming\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python\",\"item\":\"https:\/\/www.fir3net.com\/programming\/python\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"How do I compile mod_wgsi for Python 2.7\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.fir3net.com\/#website\",\"url\":\"https:\/\/www.fir3net.com\/\",\"name\":\"Fir3net\",\"description\":\"Keeping you in the know\",\"publisher\":{\"@id\":\"https:\/\/www.fir3net.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.fir3net.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.fir3net.com\/#organization\",\"name\":\"Fir3net\",\"url\":\"https:\/\/www.fir3net.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.fir3net.com\/wp-content\/uploads\/Fir3net-Background-Logo-compressed.png\",\"contentUrl\":\"https:\/\/www.fir3net.com\/wp-content\/uploads\/Fir3net-Background-Logo-compressed.png\",\"width\":390,\"height\":88,\"caption\":\"Fir3net\"},\"image\":{\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/person\/ab35009601b7687ee1c5310be6038037\",\"name\":\"Rick Donato\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d75d69a54c0ca3b32c24c3a9703b623c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d75d69a54c0ca3b32c24c3a9703b623c?s=96&d=mm&r=g\",\"caption\":\"Rick Donato\"},\"description\":\"Rick Donato is a Network Automation Architect\/Evangelist and the founder of Packet Coders.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How do I compile mod_wgsi for Python 2.7 - Fir3net","description":"Recently I found myself in a situation where I needed to recompile mod_wgsi against a newer version of Python. This involves recompiling Python with the","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html","og_locale":"en_US","og_type":"article","og_title":"How do I compile mod_wgsi for Python 2.7 - Fir3net","og_description":"Recently I found myself in a situation where I needed to recompile mod_wgsi against a newer version of Python. This involves recompiling Python with the","og_url":"https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html","og_site_name":"Fir3net","article_published_time":"2013-08-01T00:00:00+00:00","article_modified_time":"2021-07-31T17:14:42+00:00","author":"Rick Donato","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rick Donato","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html#article","isPartOf":{"@id":"https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html"},"author":{"name":"Rick Donato","@id":"https:\/\/www.fir3net.com\/#\/schema\/person\/ab35009601b7687ee1c5310be6038037"},"headline":"How do I compile mod_wgsi for Python 2.7","datePublished":"2013-08-01T00:00:00+00:00","dateModified":"2021-07-31T17:14:42+00:00","mainEntityOfPage":{"@id":"https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html"},"wordCount":309,"publisher":{"@id":"https:\/\/www.fir3net.com\/#organization"},"articleSection":["Python"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html","url":"https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html","name":"How do I compile mod_wgsi for Python 2.7 - Fir3net","isPartOf":{"@id":"https:\/\/www.fir3net.com\/#website"},"datePublished":"2013-08-01T00:00:00+00:00","dateModified":"2021-07-31T17:14:42+00:00","description":"Recently I found myself in a situation where I needed to recompile mod_wgsi against a newer version of Python. This involves recompiling Python with the","breadcrumb":{"@id":"https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.fir3net.com\/Programming\/Python\/how-do-i-compile-modwgsi-for-python-27.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.fir3net.com\/"},{"@type":"ListItem","position":2,"name":"Programming","item":"https:\/\/www.fir3net.com\/programming"},{"@type":"ListItem","position":3,"name":"Python","item":"https:\/\/www.fir3net.com\/programming\/python"},{"@type":"ListItem","position":4,"name":"How do I compile mod_wgsi for Python 2.7"}]},{"@type":"WebSite","@id":"https:\/\/www.fir3net.com\/#website","url":"https:\/\/www.fir3net.com\/","name":"Fir3net","description":"Keeping you in the know","publisher":{"@id":"https:\/\/www.fir3net.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.fir3net.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.fir3net.com\/#organization","name":"Fir3net","url":"https:\/\/www.fir3net.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.fir3net.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.fir3net.com\/wp-content\/uploads\/Fir3net-Background-Logo-compressed.png","contentUrl":"https:\/\/www.fir3net.com\/wp-content\/uploads\/Fir3net-Background-Logo-compressed.png","width":390,"height":88,"caption":"Fir3net"},"image":{"@id":"https:\/\/www.fir3net.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.fir3net.com\/#\/schema\/person\/ab35009601b7687ee1c5310be6038037","name":"Rick Donato","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.fir3net.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d75d69a54c0ca3b32c24c3a9703b623c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d75d69a54c0ca3b32c24c3a9703b623c?s=96&d=mm&r=g","caption":"Rick Donato"},"description":"Rick Donato is a Network Automation Architect\/Evangelist and the founder of Packet Coders."}]}},"_links":{"self":[{"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/posts\/797"}],"collection":[{"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/comments?post=797"}],"version-history":[{"count":0,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/posts\/797\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/media?parent=797"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/categories?post=797"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/tags?post=797"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}