Shell nginx配置wordpress站点

浏览:71
jackios 2020-05-21 16:54

#!/bin/bash

nginx_src="/usr/src"

nginx_dir="/usr/local/nginx"

nginx_url="http://nginx.org/download"

nginx_ver="1.16.0"

nginx_soft="nginx-${nginx_ver}.tar.gz"

nginx_args="--prefix=${nginx_dir} --user=nginx --group=nginx --with-http_stub_status_module"

 

word_press_name="blog.wordpress.com"

word_press_conf="blog.wordpress.com.conf"

word_press_dir="wordpress"

 

yum install gcc pcre pcre-devel zlib zlib-devel wget make openssl-devel net-tools -y

sed -i 's/enforcing/disabled/g' /etc/selinux/config

systemctl stop firewalld.service

 

cd $nginx_src

wget -c $nginx_url/$nginx_soft

tar xf $nginx_soft

cd nginx-${nginx_ver}

 

useradd -s /sbin/nologin nginx

./configure $nginx_args

 

make&&make install

$nginx_dir/sbin/nginx

ps -ef | grep nginx | grep -v grep

 

echo -e "\033[32m-----------------config Nginx vhost now------------------------------\033[0m"

sleep 3s

 

#config Nginx vhost 

cd $nginx_dir/conf

\cp nginx.conf nginx.conf.bak

\cp $nginx_src/nginx-${nginx_ver}/conf/nginx.conf $nginx_dir/conf

 

sed -i -e '/#/d' -e '/^$/d' -e '/server/,$d'  nginx.conf

echo -e "include /usr/local/nginx/conf/vhosts/*.conf; \n}" >>nginx.conf

 

mkdir -p $nginx_dir/html/$word_press_dir

chown -R  nginx:nginx $nginx_dir/html/$word_press_dir

 

mkdir -p vhosts

cd vhosts

 

cat >$word_press_conf<<EOF

server {

        listen       80;

        server_name  $word_press_name;

        location / {

            root   html/$word_press_dir;

            index index.php index.html index.htm;

        }

        

error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

       

location ~ \.php$ {

root html/wordpress;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; #反斜杠\转义$,让其$原样打印出来

include fastcgi_params;

  }

}

EOF

 

 

$nginx_dir/sbin/nginx -t

$nginx_dir/sbin/nginx -s reload



如果觉得我的文章对你有用,请随意赞赏

待完善
不要去追一匹马,用追马的时间种草,待到春暖花开时,就会有一批骏马任你挑选;不要去刻意巴结一个人,用暂时没有朋友的时间,去提升自己的能力,待到时机成熟时,就会有一批的朋友与你行。用人情做出来的朋友只是暂时的,用人格吸引来的朋友才是长久的。所以种下梧桐树,引得凤凰来。你若盛开,蝴蝶自来,你若精彩,天自安排
微信扫码登录测试

Powered by Jackios V1.0 Copyright © 2019-2020 liuql 版权所有 备案号: 鲁ICP19026293号