注意:
python27 默认没有安装 pip 和setuptools所以要提前安装。(务必先提前安装python27 哈 )
wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py
python ez_setup.py--insecure
wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9
tar-xf pip-9.0.1.tar.gz
cd pip-9.0.0python setup.py install
ln-s /usr/local/python27/bin/pip /usr/bin/pip
安装python2.7
188 2019-06-15 16:47:21 https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tar.xz
189 2019-06-15 16:47:39 wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tar.xz
190 2019-06-15 17:05:58ls191 2019-06-15 17:06:11 xz -d Python-2.7.10.tar.xz192 2019-06-15 17:06:20 tar -xf Python-2.7.10.tar193 2019-06-15 17:06:25 cd Python-2.7.10/
194 2019-06-15 17:06:44 ./configure --prefix=/python27195 2019-06-15 17:08:00 make &&make install196 2019-06-15 17:14:07 ./configure --prefix =/opt/python27197 2019-06-15 17:14:30 ./configure --prefix=/opt/python27198 2019-06-15 17:16:02 make && make install
204 2019-06-15 17:16:55 ln -s /opt/python27/bin/python2 /usr/local/bin/python2
205 2019-06-15 17:17:12 vim /etc/profile
206 2019-06-15 17:17:17 vim /etc/profile
在最底行写入 export PATH=$PATH:/opt/python347/bin/
207 2019-06-15 17:18:34 source /etc/profile
创建虚拟环境
[root@VM_0_2_centos home]# virtualenv --no-site-packages venv
New python executablein /home/venv/bin/python2
Also creating executablein /home/venv/bin/python
Please make sure you remove any previous custom pathsfrom your /root/.pydistutils.cfg file.
Installing setuptools, pip, wheel...
done.
[root@VM_0_2_centos home]# source venv/bin/activate
(venv) [root@VM_0_2_centos home]#
(venv) [root@VM_0_2_centos home]#
(venv) [root@VM_0_2_centos home]#
(venv) [root@VM_0_2_centos home]#
(venv) [root@VM_0_2_centos home]# deactivate
[root@VM_0_2_centos home]#
安装nginx
#安装nginx
#依赖库安装
yum install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel -y1.下载源码包
wget-c https://nginx.org/download/nginx-1.12.0.tar.gz
2.解压缩源码
tar-zxvf nginx-1.12.0.tar.gz
#切换nginx源码包路径
cd cd nginx-1.12.0
3.配置,编译安装
./configure --prefix=/opt/nginx1-12/make&&make install4.启动nginx,进入sbin目录,找到nginx启动命令
cd sbin
./nginx #启动
./nginx -s stop #关闭
./nginx -s reload #重新加载
#nginx日志访问功能
#找到ngxin安装文件路径,进入conf目录,编辑ngxin.conf
vim nginx.conf
#编辑nginx.conf并且打开access.log日志功能
#去掉注释即可
log_format main'$remote_addr - $remote_user [$time_local] "$request"'
'$status $body_bytes_sent "$http_referer"'
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
#然后保存退出
#以相对路径的写法,重启ngixn
sbin/nginx -s reload
配置nginx 配置nginx.conf文件 这两条命令添加即可
42 location /{43root html;44 include /opt/nginx1-12/conf/uwsgi_params;
45 uwsgi_pass 0.0.0.0:8000;46index index.html index.htm;47 }
[root@VM_0_2_centos nginx1-12]# ll
total36drwx------ 2 nobody root 4096 Jun 15 20:26client_body_temp
drwxr-xr-x 2 root root 4096 Jun 16 08:03conf
drwx------ 2 nobody root 4096 Jun 15 20:26fastcgi_temp
drwxr-xr-x 2 root root 4096 Jun 15 20:25html
drwxr-xr-x 2 root root 4096 Jun 15 20:26logs
drwx------ 2 nobody root 4096 Jun 15 20:26proxy_temp
drwxr-xr-x 2 root root 4096 Jun 15 20:25sbin
drwx------ 2 nobody root 4096 Jun 15 20:26scgi_temp
drwx------ 2 nobody root 4096 Jun 15 20:26 uwsgi_temp
查看日志
[root@VM_0_2_centos nginx1-12]# ll
total36drwx------ 2 nobody root 4096 Jun 15 20:26client_body_temp
drwxr-xr-x 2 root root 4096 Jun 15 20:30conf
drwx------ 2 nobody root 4096 Jun 15 20:26fastcgi_temp
drwxr-xr-x 2 root root 4096 Jun 15 20:25html
drwxr-xr-x 2 root root 4096 Jun 15 20:26logs
drwx------ 2 nobody root 4096 Jun 15 20:26proxy_temp
drwxr-xr-x 2 root root 4096 Jun 15 20:25sbin
drwx------ 2 nobody root 4096 Jun 15 20:26scgi_temp
drwx------ 2 nobody root 4096 Jun 15 20:26uwsgi_temp
[root@VM_0_2_centos nginx1-12]# tail -f logs/access.log
安装uwsgi
在 home目录下创建工作目录 并创建uwsgi配置文件
uwsgi配置文件
#mysite_uwsgi.ini file
[uwsgi]
# Django-related settings
# thebasedirectory (full path)
chdir= /home/mysite/pdform_py
# Django's wsgi file
module =mysite.wsgi
# the virtualenv (full path)
home=/home/venv
# process-related settings
# master
master= true# maximum number of worker processes
processes= 5# the socket (use the full path to be safe
socket= 0.0.0.0:8000# ... with appropriate permissions-may be needed
# chmod-socket = 664# clear environment on exit
vacuum= true
~
~
~
开启uwsgi
(venv) [root@VM_0_2_centos home]# uwsgi --ini /home/uwsgi_nginx.ini