当前位置: 首页 > news >正文

七牛云上市给你一个网站怎么优化

七牛云上市,给你一个网站怎么优化,南宁网站建设设计,汕头网站网站建设LNMP分布式剧本 一:环境设置二:编写Nginx剧本准备nginx下载源准备配置文件并开放PHP的访问路径准备php测试页面编写nginx剧本 三:编写Mysql剧本编写密码获取脚本准备Mysql的yum源编写mysql剧本 四:准备PHP剧本准备两个配置文件编写…

LNMP分布式剧本

  • 一:环境设置
  • 二:编写Nginx剧本
    • 准备nginx下载源
    • 准备配置文件并开放PHP的访问路径
    • 准备php测试页面
    • 编写nginx剧本
  • 三:编写Mysql剧本
    • 编写密码获取脚本
    • 准备Mysql的yum源
    • 编写mysql剧本
  • 四:准备PHP剧本
    • 准备两个配置文件
    • 编写php剧本

一:环境设置

主机部署应用
192.168.52.100ansible
192.168.52.110nginx
192.168.52.120mysql
192.168.52.130php

二:编写Nginx剧本

准备nginx下载源

mkdir -p /etc/ansible/playbook/nginx
cd /etc/ansible/playbook/nginx
vim nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

准备配置文件并开放PHP的访问路径

vim default.conf 
...
location / {root   /usr/share/nginx/html;index  index.html index.htm index.php;# 添加Nginx.php匹配项}
....
location ~ \.php$ {root           html;fastcgi_pass   192.168.52.130:9000;  #执行php的服务器和端口fastcgi_index  index.php;fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;include        fastcgi_params;

准备php测试页面

vim /etc/ansible/playbook/nginx/index.php
<?php
phpinfo();
?>

编写nginx剧本

vim /etc/ansible/playbook/nginx/nginx.yml 
- name: LAMP nginxhosts: webserversremote_user: roottasks:- name: stop firewalld #关闭防火墙service: name=firewalld state=stopped enabled=no- name: stop selinux #关闭selinuxcommand: '/usr/sbin/setenforce 0'ignore_errors: true- name: nginx.repo #准备Nginx的yum源copy: src=/etc/ansible/playbook/nginx/nginx.repo dest=/etc/yum.repos.d/nginx.repo- name: install nginx #下载nginxyum: name=nginx- name: start nginx #启动Nginxservice: name=nginx state=started enabled=yes- name: copy nginx.conf #修改配置文件copy: src=/etc/nginx/conf.d/default.conf dest=/etc/nginx/conf.d/default.confnotify: "restart nginx" #指定触发器- name: index.php #准备网页测试王建copy: src=/etc/ansible/playbook/nginx/index.php dest=/usr/share/nginx/htmlhandlers:- name: restart nginx #触发器任务,重启Nginxservice: name=nginx state=restarted
ansible-playbook nginx.yml  

三:编写Mysql剧本

编写密码获取脚本

mkdir -p /etc/ansible/playbook/mysql
vim /etc/ansible/playbook/mysql/passwd.sh#!/bin/bash
#获取Mysql的密码
passd=$(grep "password" /var/log/mysqld.log | awk '{print $NF}' | head -1)
#更改密码
mysql -uroot -p"$passd" --connect-expired-password -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'Admin@123';"
#授权
mysql -uroot -pAdmin@123 -e "grant all privileges on *.* to root@'%' identified by 'Admin@123' with grant option;

准备Mysql的yum源

sed -i 's/gpgcheck=1/gpgcheck=0/' /etc/yum.repos.d/mysql-community.repo

编写mysql剧本

vim /etc/ansible/playbook/mysql/mysql.yml
- name: LAMP mysqlhosts: mysqlremote_user: roottasks:- name: stop firewalldservice: name=firewalld state=stopped enabled=no- name: stop selinuxcommand: '/usr/sbin/setenforce 0'ignore_errors: true- name: install mysql.repo #转变mysql瞎子啊源shell: wget https://repo.mysql.com/mysql57-community-release-el7-11.noarch.rpm && rpm -ivh mysql57-community-release-el7-11.noarch.rpmignore_errors: true- name: mysql.repo #修改yum源,把仓库打开copy: src=/etc/yum.repos.d/mysql-community.repo dest=/etc/yum.repos.d/mysql-community.repo- name: install mysql #下载mysqlyum: name=mysql-server- name: start msql #启动mysqlservice: name=mysqld state=started enabled=yes- name: grep passwd #指定修改密码脚本,修改密码并授权script: /etc/ansible/playbook/mysql/passwd.sh
ansible-playbook mysql.yml  

四:准备PHP剧本

准备两个配置文件

php.ini

#添加修改时时区
date.timezone = Asia/Shanghai

www.conf文件

user = php
group = php
listen = 192.168.52.130:9000
listen.allowed_clients = 192.168.52.110

编写php剧本

vim //etc/ansible/playbook/php.yml
- name: LAMP nginxhosts: dbserversremote_user: roottasks:- name: stop firewalldservice: name=firewalld state=stopped enabled=no- name: stop selinuxcommand: '/usr/sbin/setenforce 0'ignore_errors: true- name: install php1 #准备php下载源shell: rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpmignore_errors: true- name: install php2 #下载PHP及依赖包shell: yum -y install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-pdo php72w-xml php72w-fpm php72w-mysqlnd php72w-opcacheignore_errors: true- name: start php #开启phpservice: name=php-fpm state=started enabled=yes- name: user php #创建运行用户user: name=php create_home=no shell=/sbin/nologin- name: php.ini #修改配置文件copy: src=/etc/ansible/playbook/php.ini dest=/etc/php.ini- name: www.confcopy: src=/etc/ansible/playbook/www.conf dest=/etc/php-fpm.d/www.conf- name: create nginxfile: name=/usr/share/nginx state=directory- name: create nginxfile: name=/usr/share/nginx/html state=directory- name: index.php #准备测试页面copy: src=/etc/ansible/playbook/nginx/index.php dest=/usr/share/nginx/html
ansible-playbook php.yml  
http://www.hengruixuexiao.com/news/43885.html

相关文章:

  • 偃师网站制作互联网广告投放
  • 朝阳网站建设公司南宁百度快速优化
  • 西安做企业网站手机优化大师官方免费下载
  • 幼儿园主题网络图设计美丽鹭岛搜索引擎优化seo多少钱
  • 电器网站建设目的全网网站推广
  • 网站制作框架网络搭建是干什么的
  • 哈尔滨手机建站模板网站流量统计分析工具
  • app开发和网站开发新闻发稿公司
  • 郑州做网站hnmaorui朋友圈推广文案
  • 昆明php网站建设网络营销的作用和意义
  • 电脑怎么做网站电商运营培训机构哪家好
  • 怎么给自己的网站做模版沈阳网站建设制作公司
  • wix建站教程营销推广手段有什么
  • 设计网站注意哪些问题流量平台有哪些
  • 网站建设 html5视频营销的策略与方法
  • 软件测试网站开发与测试唐山公司做网站
  • 网站图片标题背景怎样做的seo网络推广经理
  • 做深度的互联网站免费推广论坛
  • python做的网站有什么漏洞培训教育机构
  • 性做爰网站今日广州新闻最新消息
  • 郑州做商城网站微商怎么引流被加精准粉
  • 制作网站的公司(深圳)新人跑业务怎么找客户
  • 大石桥网站制作学网络运营需要多少钱
  • 网站不收录友链申请
  • php版本不同于wordpress使用网站seo应用
  • 怎么做免费公司网站专业网络推广
  • 学做网站论坛全部视频厦门seo外包公司
  • 甪直做网站常见的微信营销方式有哪些
  • 动态网站开发工程师证搜索引擎推广方案案例
  • 区块链平台定制开发桔子seo工具