标签:manage art request ESS uwsgi templates fast tar systemctl
LNMP架构环境部署
1) 使用官方仓库安装Nginx
[root@nginx ~]# vim etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
#安装Nginx
[root@nginx ~]# yum install nginx -y
2) 启动Nginx,并将Nginx加入开机自启
[root@nginx ~]# systemctl start nginx
[root@nginx ~]# systemctl enable nginx
3) 使用第三方扩展源安装php7.1
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
[root@nginx ~]# yum remove php-mysql-5.4 php php-fpm php-common
[root@nginx ~]# /etc/yum.repos.d/php.repo
[php]
name = php Repository
baseurl = http://us-east.repo.webtatic.com/yum/el7/x86_64/
gpgcheck = 0
[root@nginx ~]# yum -y install php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-mysqlnd php71w-opcache php71w-pecl-memcached php71w-pecl-redis php71w-pecl-mongodb
3) 配置php-fpm用户与Nginx的运行用户保持一致
[root@nginx ~]# sed -i ‘/^user/c user = www‘ /etc/php-fpm.d/www.conf
[root@nginx ~]# sed -i ‘/^group/c group = www‘ /etc/php-fpm.d/www.conf
4) 启动php-fpm,并将其加入开机自启
[root@nginx ~]# systemctl start php-fpm
[root@nginx ~]# systemctl enable php-fpm
5) 安装mysql数据库
[root@nginx ~]# mysqladmin password ‘123‘
[root@nginx ~]# mysql -uroot -p123
2.LNMP架构环境配置
vim /etc/nginx/conf.d/php.conf
server {
server_name 10.0.0.12;
listen 80;
root /code/wordpress;
index index.php index.html;
location ~ \.php$ {
root /code/bbs;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
yum -y groupinstall "Development tools"
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
pip3 install django
pip3 install uwsgi
cat test.py
def application(env, start_response):
start_response(‘200 OK‘, [(‘Content-Type‘,‘text/html‘)])
return [b"Hello Django"]
uwsgi --http :8888 --wsgi-file test.py
[root@web01 code]# cat /code/BBS/uwsgi.ini
[uwsgi]
socket = 127.0.0.1:9090
#chdir = /code/BBS/BBS
workers = 2
max-requests = 1000
buffer-size = 30000
pidfile = /run/uwsgi.pid
daemonize = /var/log/uwsgi.log
[root@web01 code]# cat /etc/nginx/conf.d/py.conf
server {
listen 80;
server_name py.test.com;
index index.html;
client_max_body_size 100M;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9090;
uwsgi_param UWSGI_SCRIPT BBS.wsgi;
uwsgi_param UWSGI_CHDIR /code/BBS;
}
}
django-admin.py startproject mysite
python3 manage.py startapp blog
vim /code/mysite/mysite/settings.py
在INSTALLED_APPS 列表里添加‘blog‘APP
修改ALLOWED_HOSTS,[‘*‘],可以让任何IP访问
TEMPLATES里添加模板路径os.path.join(BASE_DIR, ‘templates‘)
尾部添加
STATICFILES_DIRS = (
os.path.join(BASE_DIR,‘static‘),
)
vim /code/mysite/templates/index.html
标签:manage art request ESS uwsgi templates fast tar systemctl
原文地址:https://www.cnblogs.com/yuanxiaohui/p/10264629.html