In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about how to use Apache and mod_wsgi to configure Django. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
How to use Django in Apache and mod_wsgi
Mod_wsgi can also be installed with yum, but the version may be out of date, with only 3.4 in my yum feed, when the latest version was 4.5.24 (there is now a newer version). If you want to use the latest version of mod_wsgi, it is recommended to compile the source code installation. Fortunately, the installation tutorial for the official mod_wsgi documentation is very detailed.
Download the source code first, download it in the current folder, and decompress it after the download is complete
$wget https://github.com/GrahamDumpleton/mod_wsgi/archive/4.5.24.tar.gz$ tar xvfz mod_wsgi-4.5.24.tar.gz
Then, when configuring, use the-with-python option to specify the location of the python executable
. / configure-with-python=/usr/local/python3/bin/python
If you do not specify the program will also automatically retrieve the location of python, but because my server has both python2 and 3, and the python soft chain points to python2, so the default mod_wsgi will find python2, then Apache will also open python2 at run time. In order for mod_wsgi to find python3 correctly, use the-with-python option. Even if you don't use this item, you can also specify the path to the Python through the WSGIPythonHome directive when configuring the django project with Apache later.
There is also a-with-apxs option to specify the location of the Apache build tool apxs. If an installation error prompts you that apxs cannot be found, make sure that apxs is installed and use this option to specify its location.
The next step is to build and compile
$sudo make$ sudo make install
If there is an error in the process of compiling and installing the source code, most of the errors are caused by incomplete dependency. take a closer look at the prompts in the error message and install the relevant dependencies. It is best to make sure that all the relevant dependencies are available before installation, and you can use yum deplist mod_wsgi to view all the dependencies.
After the mod_wsgi installation is complete, you also need to load the module in Apache and modify the Apache configuration file (your configuration file location may not be quite the same as mine).
$sudo vim / etc/httpd/conf/httpd.conf
Then add the following line to the file, and the final option is the location of the mod_wsgi.so.
LoadModule wsgi_module / usr/lib64/httpd/modules/mod_wsgi.so
Restart Apache after the change to make the configuration effective.
$apachectl restart
If successful, you can see the test page in the browser to visit the server id. If startup fails, check the error log, whose location can be found in the configuration file. Follow the prompts to find out the cause of the error, and common bug is also listed in mod_wsgi 's official documentation.
$sudo vim / var/log/httpd/error_log
For example, when I was configuring mod_wsgi, I encountered an error caused by python. Open the error log with the following key information:
Error while loading shared libraries: libpython3.6.4.so.1.0:\ cannot open shared object file: No such file or directory
There is an error that the libpython3.6m.so.1.0 file cannot be found (if it is a different version of python, the suffix code is different), there may be two reasons, one is that the file is not in the working directory of Apache, and the other is that there is no such file.
Use the find /-name libpython3.6m.so.1.0 command to find the file and connect to the library folder where mod_wsgi.so is located, usually in / usr/lib or / usr/lib64. For example, my file paths are / usr/lib64/httpd/modules/mod_wsgi.so and / usr/local/python3/lib/libpython3.6m.so.1.0, respectively, that is, link libpython3.6m.so.1.0 to / usr/lib64.
If you are source-compiled python and cannot find the libpython3.6m.so.1.0 file, you may not have added-- enable-shared to the configuration item, so you need to recompile python.
$. / configure-- enable-shared above is the editor's share of how to configure Django using Apache and mod_wsgi. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.