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

ps做网站难吗简述什么是seo

ps做网站难吗,简述什么是seo,个人可以做电影网站吗,php动态网站作业通过学习ansible自动化运维,初步对ansible有了一定的了解,此次分享两个案例,希望对大家有所帮助 案例一:自动化安装nginx 本次案例目的是ansible自动化安装nginx并配置 首先创建如图所示目录 在主机上安装好nginx,如…

通过学习ansible自动化运维,初步对ansible有了一定的了解,此次分享两个案例,希望对大家有所帮助

案例一:自动化安装nginx

本次案例目的是ansible自动化安装nginx并配置

首先创建如图所示目录

在主机上安装好nginx,如下:

使用wget下载nginx包,下载地址:http://mirrors.sohu.com/nginx/nginx-1.9.6.tar.gz
对nginx进行解压
tar -zxvf nginx-1.9.6.tar.gz -C /usr/local
cd /usr/local/nginx-1.9.6
./configure --prefix=/usr/local/nginx
若是报错,根据提示安装好缺少的依赖
make && makeinstall

修改/etc/init.d/nginx 内容如下:

#!/bin/bash
# chkconfig: - 30 21
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings
NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usx/local/nginx/logs/nginx.pid"
RETVAL=0
prog="Nginx"start()
{echo -n $"Starting $prog: "mkdir -p /dev/shm/nginx_tempdaemon $NGINX_SBIN -c $NGINX_CONFRETVAL=$?echoreturn $RETVAL
}
stop()
{echo -n $"Stopping $prog: "killproc -p $NGINX_PID $NGINX_SBIN -TERMrm -rf /dev/shm/nginx_tempRETVAL=$?echoreturn $RETVAL
}
reload()
{echo -n $"Reloading $prog: "killproc -p $NGINX_PID $NGINX_SBIN -HUPRETVAL=$?echoreturn $RETVAL
}
restart()
{stopstart
}
configtest()
{$NGINX_SBIN -c $NGINX_CONF -treturn 0
}
case "$1" instart)start;;stop)stop;;reload)reload;;restart)restart;;configtest)configtest;;*)echo $"Usage: $0 {start|stop|reload|restart|configtest}"RETVAL=1
esac
exit $RETVAL

授予权限

chmod 777 /etc/init.d/nginx

清空该文件并进行如下配置/usr/local/nginx/conf/nginx.conf

user nobody nobody;             #定义nginx运行的用户和用户组
worker_processes 2;             #nginx进程数,一般为CPU总核心数
error_log /usr/local/nginx/logs/nginx_error.log crit;   #全局错误日志定义类型
pid /usr/local/nginx/logs/nginx.pid;    #进程文件
worker_rlimit_nofile 51200;
events          #工作模式与连接数上限
{
use epoll;
worker_connections 6000;
}
http            #http下的一些配置
{
include mime.types;             #文件扩展名与文件类型映射表
default_type application/octet-stream;          #默认文件类型
server_names_hash_bucket_size 3526;
server_names_hash_max_size 4096;
log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
'$host "$request_uri" $status'
'"$http_referer" "$http_user_agent"';
sendfile on;            #开启高效文件传输模式
tcp_nopush on;          #防止网络阻塞
keepalive_timeout 30;           #长连接超时时间,单位为秒
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
connection_pool_size 256;
client_header_buffer_size 1k;
large_client_header_buffers 8 4k;
request_pool_size 4k;
output_buffers 4 32k;
postpone_output 1460;
client_max_body_size 10m;
client_body_buffer_size 256k;
client_body_temp_path /usr/local/nginx/client_body_temp;
proxy_temp_path /usr/local/nginx/proxy_temp;
fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
fastcgi_intercept_errors on;
tcp_nodelay on;         #防止网络阻塞
gzip on;                #开启gzip压缩输出
gzip_min_length 1k;
gzip_buffers 4 8k;
gzip_comp_level 5;
gzip_http_version 1.1;
gzip_types text/plain application/x-javascript text/css text/htm
application/xml;
server          #虚拟主机配置
{
listen 80;
server_name localhost;
index index.html index.htm index.php;
root /usr/local/nginx/html;
location ~ \.php$
{
include fastcgi_params;
fastcgi_pass unix:/tmp/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/1ocal/nginx/html$fastcgi_script_name;
}
}
}

启动服务

service nginx start

将nginx的压缩包移动至目标目录下,复制启动脚本和配置文件到目标目录下

mv nginx-1.9.6.tar.gz /etc/ansible/nginx_install/roles/install/files/
cp /usr/local/nginx/conf/nginx.conf /etc/ansible/nginx_install/roles/install/templates/
cp /etc/init.d/nginx /etc/ansible/nginx_install/roles/install/templates/

在nginx_install目录下编写启动文件install.yml

---
- hosts: testremote_user: rootgather_facts: Trueroles:- common- install

在roles/common/tasks/main.yml文件下编写需要安装的依赖文件

- name: install initialization require softwareyum: name={{ item }} state=installedwith_items:- zlib-devel- pcre-devel- gcc

在 roles/install/vars/main.yml文件下定义各种变量

nginx_user: www
nginx_port: 80
nginx_basedir: /usr/local/nginx

在roles/install/tasks/copy.yml文件下编写需要复制的文件

- name: Copy Nginx Software   #复制nginx安装包copy: src=nginx-1.9.6.tar.gz dest=/tmp/nginx-1.9.6.tar.gz owner=root group=root
- name: Uncompression Nginx Software  #解压nginxshell: tar zxf /tmp/nginx-1.9.6.tar.gz -C /usr/local/
- name: Configure Nginx   #编译安装nginxshell: cd /usr/local/nginx-1.9.6 && ./configure --prefix=/usr/local/nginx
- name: Make Nginx   #初始化nginxshell: cd /usr/local/nginx-1.9.6 && make && make install
- name: Copy Nginx Start Script   #复制nginx启动脚本template: src=nginx dest=/etc/init.d/nginx owner=root group=root mode=0755
- name: Copy Nginx Config  #复制nginx配置文件template: src=nginx.conf dest={{ nginx_basedir }}/conf/ owner=root group=root mode=0644

在roles/install/tasks/install.yml下编写启动文件

- name: create nginx useruser: name={{ nginx_user }} state=present createhome=no shell=/sbin/nologin
- name: start nginx serviceshell: /etc/init.d/nginx start
- name: add boot start nginx serviceshell: chkconfig --level 345 nginx on
- name: delete nginx compression filesshell: rm -rf /tmp/nginx-1.9.6.tar.gz

在 roles/install/tasks/main.yml中编写主要文件

- include: copy.yml
- include: install.yml

执行脚本,结果如图所示

在test主机中查看nginx是否启动

可以看到启动成功

案例二:管理nginx配置文件

首先创建如下目录:

roles目录下分为new目录和old目录,new目录表示需要更新的配置文件,old目录为备份的文件。在做配置文件的时候,备份非常重要,在执行update.yml文件前应该备份好当前配置文件,出现错误时可以及时的回滚操作。

 rsync -av /etc/ansible/nginx_config/roles/new/  /etc/ansible/nginx_config/roles/old/

使用该命令可以将new目录中的配置文件备份到old目录中

files目录中表示的是配置文件,可以自行添加,此处放置的为空目录。

handlers目录中表示的是重启服务,内容如下

- name: restart nginx   #用于重新加载nginx服务shell: /etc/init.d/nginx reload

tasks目录中就是主要的命令,内容如下:

- name: copy conf file  #复制.conf和hosts文件copy: src={{ item.src }} dest={{ nginx_basedir }}/{{ item.dest }} backup=yes owner=root group=root mode=0644with_items:- { src: nginx.conf, dest: conf/nginx.conf }- { src: vhosts, dest: conf/ }notify: restart nginx

vars目录中表示变量,内容如下:

nginx_basedir: /usr/local/nginx #定义变量

update.yml文件为更新文件,内容为:

---
- hosts: test  #入口文件user: rootroles:- new         #这里只有new

执行命令,结果如下:

由于此处的files目录中放置的是空目录,所以结果没有任何改变,可以自行添加配置文件进行修改。

http://www.hkea.cn/news/368945/

相关文章:

  • 柳州建设局网站广告买卖网
  • 做外贸一般上哪些网站google play谷歌商店
  • 泉州手机网站制作如何做企业产品推广
  • 徐州手机网站设计汕头网站建设优化
  • 有没有专业收费做网站优化的百度百科优化排名
  • 常州网站建设哪家便宜江西seo推广软件
  • 如何用pageadmin做网站品牌宣传策略有哪些
  • 网站免费优化软件需要优化的地方
  • 24小时学会网站建设下载厦门百度竞价开户
  • 怎样学做网站网站权重等级
  • 做网站好还是做淘宝好北京seo推广
  • 郑州门户网站建设哪家好网站首页不收录
  • 网站制作营销型哪些网站可以发广告
  • 最新政府网站建设理念广州头条新闻最新
  • 济宁网站建设神华线上推广的三种方式
  • 我要表白网站在线制作如何做网站的教程
  • 福州论坛建站模板策划网络营销活动
  • 网站建设 天津百度市场应用官方app
  • 动态网站制作流程友情链接的定义
  • 企业网站开发方案免费建立一个网站
  • 网站引导页面制作的四个任务名称推广引流的10个渠道
  • 南宁网站建设制作后台网站关键词优化价格
  • 微信小程序商城制作公司宁波seo推广服务
  • 响应式购物网站公司seo是什么意思
  • 360未经证实的网站如何做电商运营方案
  • 网站建设类公司排名营销方案范文100例
  • 郑州网站设计 郑州网站开发网络优化有前途吗
  • 黑河做网站首页关键词排名优化
  • 网站二级域名怎么解析公司网络搭建
  • wordpress做网店win10优化大师是官方的吗