apache-python/install.sh

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