In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
First, install Apache
# yum install-y httpd httpd-devel# systemctl start httpd.service # Startup # systemctl stop httpd.service # shutdown # systemctl restart httpd.service # restart # systemctl enable httpd.service # Boot
Firewall opens port 80
# firewall-cmd-zone=public-add-port=80/tcp-permanent# firewall-cmd-reload
Enable Apache, and the public network can already access the default page of Apache through ip.
Second, install Python36, pip3, virtualenv
# yum install- y epel-release# yum install- y python36# python36- VPython 3.6.The yum install- y python36-setuptools# easy_install-3.6 pip# pip3-Vpip 18.1 from / usr/local/lib/python3.6/site-packages/pip-18.1-py3.6.egg/pip (python3.6) # pip3 install virtualenv
Third, create a project
Create a flask project (at its simplest, one project folder, one startup file)
# mkdir / var/www/flask_test # Project folder # vi / var/www/flask_test/app.py # Startup File
Example of startup file:
From flask import Flask, request app = Flask (_ _ name__) @ app.route ('/') def hello_world (): return 'Hello World' @ app.route (' / hello') def hello (): name = request.args.get ('name','') return' Hello'+ name +'! If _ _ name__ = ='_ _ main__': app.run ()
Create a virtual environment under the project folder and install flask
# cd / var/www/flask_test# virtualenv py3env # create a virtual environment # source py3env/bin/activate # enter the virtual environment (py3env) # pip install flask # install flask (py3env) # deactivate # exit the virtual environment
4. Install mod_wsgi with pip in virtual environment
# yum install-y python36-devel.x86_64 # A dependency. If not installed, the following pip will report an error. # source py3env/bin/activate # enter the virtual environment (py3env) # pip install mod_wsgi # install mod_wsgi (py3env) # mod_wsgi-express install-module # execute this command Copy the output LoadModule wsgi_module "/ usr/lib64/httpd/modules/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so" WSGIPythonHome "/ var/www/flask_test/py3env" (py3env) # deactivate # exit the virtual environment
Modify the configuration of Apache
# vi / etc/httpd/conf/httpd.conf
Copy the line above and add it to the end of the configuration file
The copy code is as follows: LoadModule wsgi_module "/ usr/lib64/httpd/modules/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so"
5. Configure mod_wsgi
# vi / var/www/html/flask_test/app.wsgi
Write the following (according to: https://dormousehole.readthedocs.io/en/latest/deploying/mod_wsgi.html)
Activate_this ='/ var/www/flask_test/py3env/bin/activate_this.py'with open (activate_this) as file_: exec (file_.read (), dict (_ _ file__=activate_this)) import syssys.path.insert (0,'/ var/www/flask_test') from app import app as application
Configure Apache
# vi / etc/httpd/conf/httpd.conf
Write the following (according to: https://dormousehole.readthedocs.io/en/latest/deploying/mod_wsgi.html#id1)
ServerName example.com WSGIScriptAlias / / var/www/flask_test/app.wsgi Require all granted
OK, start Apache, and you can access the web page through the ip of this server
Test the two paths written in some app.py
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.
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.