Flask Apache Deployment

Source: Internet
Author: User

1. Download Apache Zip package decompression, placed in the C packing directory, cmd command switch to apache24/bin directory, enter command httpd-k install, httpd-k uninstall remove installation

C:\apache24\bin>httpd-k Install
Installing the ' Apache2.4 ' service
The ' Apache2.4 ' service is successfully installed.
Testing httpd.conf ....
Errors reported here must is corrected before the service can be started.

Description of successful installation, http://localhost in browser input will show it Works, indicating successful installation

2 Download the Mod_wsgi.whl file that corresponds to the Python version, pip install MOD_MSGI.WHL (note the path)

Go to Python's scripts path in cmd input mod_wsgi-express module-config

PS c:\users\user\appdata\local\programs\python\python36\scripts> mod_wsgi-express Module-config
LoadFile "C:/users/user/appdata/local/programs/python/python36/python36.dll"
LoadModule Wsgi_module "c:/users/user/appdata/local/programs/python/python36/lib/site-packages/mod_wsgi/server/ Mod_wsgi.cp36-win_amd64.pyd "
Wsgipythonhome "C:/users/user/appdata/local/programs/python/python36"

Copy the bold three words, paste the htppd.conf file to the end of the apache/conf

3 Create a wsgi.py file

Write

Import sys, OS
# My project is under the ' C:/users/user/desktop/flask_news
#Expand Python classes path with your app ' s path
Sys.path.insert (0, ' c:/users/user/desktop/flask_news ')


From Flask_news Import app

#Put Logging code (and imports) here ...

#Initialize WSGI App Object
application = App

4 Add the htppd.conf file at the end of the apache/conf

My port has been changed to 8081

<virtualhost *:8081>
ServerAdmin [email protected]
Wsgiscriptalias/app c:\mydir\wsgi.py

Path to #对应wsgi. py
<directory c:\mydir>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

5.cmd (Admin) switch both Apache bin directory execution httpd-k Uninstall, httpd-k install, net Sart Apache2.4

6. Browser Input http://localhost:8081/app/

Flask Apache Deployment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.