The document summarizes the steps taken to install and configure NGINX, PostgreSQL, Python, and uWSGI on a CentOS 7 server. Key steps include:
1) Installing NGINX using yum and enabling it to start automatically at boot;
2) Installing and initializing PostgreSQL, configuring it to allow local connections, and creating a database user;
3) Installing Python 3.7 using pyenv and setting it as the global version;
4) Installing uWSGI and using it to run a simple Python application served over HTTP on port 9090.
5. 総ダウンロード容量: 772 k
インストール容量: 2.7 M
Downloading packages:
nginx-1.18.0-1.el7.ngx.x86_64.rpm | 772 kB 00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
インストール中 : 1:nginx-1.18.0-1.el7.ngx.x86_64 1/1
----------------------------------------------------------------------
Thanks for using nginx!
Please find the official documentation for nginx here:
* http://nginx.org/en/docs/
Please subscribe to nginx-announce mailing list to get
the most important news about nginx:
* http://nginx.org/en/support.html
Commercial subscriptions for nginx are available on:
* http://nginx.com/products/
----------------------------------------------------------------------
検証中 : 1:nginx-1.18.0-1.el7.ngx.x86_64 1/1
インストール:
nginx.x86_64 1:1.18.0-1.el7.ngx
完了しました!
6. [root@cent75 ~]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
□ Step 1-2 Set NGINX to start automatically.
□ Step 1-4 Startup NGINX
□ Step 1-5 Stop NGINX
[root@cent75 ~]# systemctl start nginx
[root@cent75 ~]# systemctl stop nginx
□ Step 1-6 Retart NGINX
[root@cent75 ~]# systemctl restart nginx
[root@cent75 ~]# systemctl status nginx
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since 月 2020-05-11 22:44:50 JST; 2min 29s ago
Docs: http://nginx.org/en/docs/
Process: 11916 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)
Process: 11929 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 11932 (nginx)
...
□ Step 1-7 Show NGINX status
9. □ Step 2-3 Initialize database instance
[root@cent75 ~]# PGSETUP_INITDB_OPTIONS="-E UTF8 --no-locale" postgresql-setup initdb
Initializing database ... OK
[root@cent75 ~]# vi /var/lib/pgsql/data/pg_hba.conf
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
□ Step 2-4 startup PostgreSQL
[root@cent75 ~]# systemctl start postgresql
[root@cent75 ~]# systemctl status postgresql
● postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled; vendor preset: disabled)
Active: active (running) since 火 2020-05-12 23:34:48 JST; 5s ago
Process: 10538 ExecStart=/usr/bin/pg_ctl start -D ${PGDATA} -s -o -p ${PGPORT} -w -t 300 (code=exited, status=0/SUCCESS)
tq10547 postgres: autovacuum launcher process
mq10548 postgres: stats collector process
・・・
5月 12 23:34:47 cent75 systemd[1]: Starting PostgreSQL database server...
5月 12 23:34:48 cent75 systemd[1]: Started PostgreSQL database server.
10. □ Step 2-5 Set PostgreSQL to start automatically
[root@cent75 ~]# systemctl enable postgresql
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql.service to /usr/lib/systemd/system/postgresql.service.
□ Step 2-6 Create database role
[postgres@cent75 ~]$ psql -U postgres -c "CREATE ROLE ¥"jppf¥" WITH CREATEDB LOGIN PASSWORD 'jppf'"
[postgres@cent75 ~]$ psql -U postgres -c '¥du'
ロール一覧
ロール名 | 属性 | メンバー
----------+----------------------------------------------------------------------+----------
jppf | DBを作成できる | {}
postgres | スーパーユーザ, ロールを作成できる, DBを作成できる, レプリケーション | {}
11. □ Step 3-1 pyenv and pyenv-virtualenv Install
[root@cent75 ~]# cd /root
[root@cent75 ~]# git clone https://github.com/yyuu/pyenv.git ~/.pyenv
[root@cent75 ~]# git clone https://github.com/yyuu/pyenv-virtualenv.git ./.pyenv/plugins/pyenv-virtualenv
[root@cent75 ~]# vi /root/.bash_profile
export PATH=$PATH:$HOME/bin:/usr/local/bin
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
[root@cent75 ~]# .bash_profile
[root@cent75 ~]# PYTHON_CFLAGS=-fPIC pyenv install 3.7.1
[root@cent75 ~]# pyenv global 3.7.1
[root@cent75 ~]# pyenv versions
system
* 3.7.1 (set by /root/.pyenv/version)
[root@cent75 ~]# python
Python 3.7.1 (default, Apr 30 2020, 21:21:52)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
12. □ Step 4-1 uWSGI Install
[root@cent75 ~]# pip install uwsgi==2.0.18
Collecting uwsgi==2.0.18
Downloading uwsgi-2.0.18.tar.gz (801 kB)
|????????????????????????????????| 801 kB 2.8 MB/s
Building wheels for collected packages: uwsgi
Building wheel for uwsgi (setup.py) ... done
Created wheel for uwsgi: filename=uWSGI-2.0.18-cp37-cp37m-linux_x86_64.whl size=5002578
sha256=5aa2a14ec4226467f3b7699ce69ea9360259dce09e1f71ef34173cb0cf6a3d41
Stored in directory: /root/.cache/pip/wheels/e7/d0/f2/b93905969980eaf9fe18183b0c43470d63b13fcd3a1f6c8efe
Successfully built uwsgi
Installing collected packages: uwsgi program
Successfully installed uwsgi-2.0.18
[root@cent75 ~]# pip install uwsgi==2.0.18
□ Step 4-2 check program
[root@cent75 ~]# vi /tmp/test.py
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
rvalue = b"Hello World¥n"
return [rvalue]
13. □ Step 4-3 startup uWSGI server
[root@cent75 ~]# uwsgi --plugin http,python --http :9090 --wsgi-file /tmp/test.py
open("./http_plugin.so"): No such file or directory [core/utils.c line 3724]
!!! UNABLE to load uWSGI plugin: ./http_plugin.so: cannot open shared object file: No such file or directory !!!
open("./python_plugin.so"): No such file or directory [core/utils.c line 3724]
!!! UNABLE to load uWSGI plugin: ./python_plugin.so: cannot open shared object file: No such file or directory !!!
*** Starting uWSGI 2.0.18 (64bit) on [Wed May 13 00:36:11 2020] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-39) on 12 May 2020 15:25:11
os: Linux-3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018
nodename: cent75
machine: x86_64
clock source: unix
・・・
□ Step 4-4 Access check