| 1 |
|
| 2 |
semanage fcontext -at httpd_sys_rw_content_t "/srv(/.*)?" |
| 3 |
|
| 4 |
yum install firewalld -y |
| 5 |
systemctl start firewalld |
| 6 |
systemctl enable firewalld |
| 7 |
firewall-cmd --permanent --zone=public --add-interface=eth0 |
| 8 |
firewall-cmd --permanent --add-service=http --zone=public |
| 9 |
firewall-cmd --reload |
| 10 |
|
| 11 |
yum install httpd -y |
| 12 |
|
| 13 |
systemctl start httpd |
| 14 |
systemctl enable httpd |
| 15 |
|
| 16 |
#python |
| 17 |
|
| 18 |
yum install epel-release -y |
| 19 |
yum install git python34 python-pip -y 2> /dev/null |
| 20 |
pip install --upgrade pip |
| 21 |
pip install --upgrade virtualenv |
| 22 |
cd /srv |
| 23 |
virtualenv -p python3 webapi |
| 24 |
cd webapi |
| 25 |
source bin/activate |
| 26 |
git clone https://github.com/davidbetz/pywebapi content |
| 27 |
cd content |
| 28 |
pip install -r requirements.txt |
| 29 |
deactivate |
| 30 |
|
| 31 |
export PUBLIC_IP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') |
| 32 |
|
| 33 |
cat >> /etc/hosts << EOF |
| 34 |
$PUBLIC_IP webapi |
| 35 |
EOF |
| 36 |
|
| 37 |
yum install mod_wsgi -y |
| 38 |
|
| 39 |
cat > /etc/httpd/conf.d/webapi.conf << EOF |
| 40 |
WSGIPythonPath /srv/webapi/content:/srv/webapi/lib/python3.4/site-packages |
| 41 |
|
| 42 |
|
| 43 |
ServerName webapi |
| 44 |
ErrorLog logs/webapi-error.log |
| 45 |
CustomLog logs/webapi-access.log common |
| 46 |
|
| 47 |
WSGIDaemonProcess webapi python-path=/srv/webapi/content:/srv/webapi/lib/python3.4/site-packages |
| 48 |
WSGIProcessGroup webapi |
| 49 |
|
| 50 |
WSGIScriptAlias / /srv/webapi/content/app.py |
| 51 |
WSGICallableObject webapi_start |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
Require all granted |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
EOF |
| 60 |
|
| 61 |
restorecon -R -v /srv |
| 62 |
chown -R nobody:apache /srv |
| 63 |
|
| 64 |
systemctl restart httpd |
| 65 |
|