首页 > 其他分享 >一键安装wordpress

一键安装wordpress

时间:2023-02-22 14:23:01浏览次数:55  
标签:-- local 一键 nginx wordpress usr mysql php 安装

#!/bin/bash

 

nginx_souecepwd=/usr/local/nginx #源码安装路径

cdnginx_configpwd=/usr/local/nginx/conf

systemd_ExecStartpwd=/usr/local/nginx/sbin/nginx

if [ ! -d $nginx_souecepwd ];then

mkdir $nginx_souecepwd

echo "=========================开始安装Nginx==========================="


sed -i 's/SELINUX=enforcing/\SELINUX=disabled/' /etc/selinux/config #关闭selinux

 

for nginx_depend_pack in wget gcc pcre pcre-devel zlib zlib-devel;do
nginx_depend_result=$(rpm -qa $nginx_depend_pack)
if [ -z "$nginx_depend_result" ];then
yum install -y $nginx_depend_pack
else
echo "$nginx_depend_pack is 判断是否安装NGINX依赖包OK"
fi
done

 

nginxdownloadurl="http://192.168.80.113/nginx-1.22.0.tar.gz"

cd $nginx_souecepwd 

wget "$nginxdownloadurl"


nginx_targzname=$(echo $nginxdownloadurl | sed 's#.*/##') 

 

tar -zxvf $nginx_targzname 

dirname=$(echo $nginx_targzname | sed 's/.tar.gz//') )


cd $dirname #进入

./configure --prefix=$nginx_souecepwd

make -j4 && make install || exit 1

 

cp /etc/profile /etc/profile.bak 

sed -i '$ a export PATH=$PATH:/usr/local/nginx/sbin' /etc/profile #注意:这行可能导致配置文件消失 环境变量全无 (之前笔者由于多写或写多了一个字符就发生血案0.0)#
#往/etc/profile文件最后一行添加环境变量 添加环境变量的好处 可以便管理员直接执行“nginx”命令就可以调用Nginx的主程序#

 

echo "[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=$systemd_ExecStartpwd
ExecReload=$systemd_ExecStartpwd -s reload
ExecStop=$systemd_ExecStartpwd -s stop
[Install]
WantedBy=multi-user.target" > /usr/lib/systemd/system/nginx.service
#为了使Nginx服务器以systemctl运行

chmod 754 /lib/systemd/system/nginx.service

systemctl start nginx.service

systemctl enable nginx.service

cd $cdnginx_configpwd

cp nginx.conf nginx.conf.bak

sed -i '45s/index index.html index.htm;/ index index.php index.html index.htm ;/g' nginx.conf 

sed -i '65,71s/#/ /g' nginx.conf 

sed -i 's#/scripts#$document_root#g' 

source /etc/profile

nginx -t

firewall-cmd --zone=public --add-port=80/tcp --permanent

firewall-cmd --reload

programName=${0##*/}

echo $programName

source /etc/profile $programName

 

else

echo "=========================安装Nginx失败已经安装过Nginx==========================="

fi

 


#下面是编译PHP安装

php_souece_pwd=/usr/local/php

cd_php_configpwd=/usr/local/php/etc

phpfpm_systemd_ExecStartpwd=/usr/local/php/sbin/php-fpm

cp_phpconf_ini=/usr/local/php/etc/php-fpm.conf.default

cd_phpconf_ini=usr/local/php/etc/php-fpm.conf

if [ ! -d $php_souece_pwd ];then

mkdir $php_souece_pwd

echo "=========================开始安装php==========================="

yum -y install epel-release

for php_depend_pack in gcc gcc-c++ make pcre pcre-devel zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel openldap openldap-devel libmcrypt libmcrypt-devel;do
php_depend_result=$(rpm -qa $php_depend_pack)
if [ -z "$php_depend_result" ];then
yum install -y $php_depend_pack
else
echo "$php_depend_pack is 判断是否安装php依赖包OK"
fi
done


phpdownloadurl="http://192.168.80.113/php-5.6.40.tar.gz"

cd $php_souece_pwd

wget "$phpdownloadurl"

php_targz_name=$(echo $phpdownloadurl | sed 's#.*/##')

tar -zxvf $php_targz_name

php_dir_name=$(echo $php_targz_name | sed 's/.tar.gz//')

cd $php_dir_name

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-ctype --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --with-gettext --enable-fpm


#./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-ctype --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --with-gettext --enable-fpm

#./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --with-mhash --with-openssl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib --enable-bcmath --enable-gd --with-jpeg --with-freetype --enable-mbstring --enable-ftp --enable-sockets --with-gettext --enable-session --with-curl --enable-fpm --with-fpm-user=php --with-fpm-group=php --enable-pdo -enable-tokenizer --with-zip

make -j4 && make install


cp php.ini-production /usr/local/php/etc/php.ini

 

echo "[Unit]
Description=php-fpm
After=network.target
[Service]
Type=forking
ExecStart=$phpfpm_systemd_ExecStartpwd
[Install]
WantedBy=multi-user.target" > /usr/lib/systemd/system/php-fpm.service


chmod 754 /usr/lib/systemd/system/php-fpm.service


mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

cd $cd_php_configpwd

cp /etc/profile /etc/profile.php

#sed -i '164c listen = 0.0.0.0:9000' 

sed -i '190s/;//g' php-fpm.conf 

echo 'export PATH=$PATH:/usr/local/php/sbin/:/usr/local/php/bin/' >> /etc/profile


source /etc/profile


programName=${0##*/}

echo $programName

source /etc/profile $programName

systemctl start php-fpm.service

systemctl enable php-fpm.service

systemctl restart php-fpm.service

systemctl restart nginx.service

firewall-cmd --zone=public --add-port=9000/tcp --permanent

firewall-cmd --zone=public --add-port=9000/udp --permanent

firewall-cmd --reload

else

echo "=========================安装php失败已经安装过php==========================="

fi

 

 


mysql_souece_pwd=/usr/local/mysql

cd_mysql_cnfmypwd=/usr/local/mysql/etc/my.cnf

data_mysql=/data/mysql

cd_mysqlslow_log=/data/mysql/mysql-slow.log

cp_mysqlmy_conf_ini=

cd_mysqlmy_conf_ini=

if [ ! -d $mysql_souece_pwd ];then

mkdir $mysql_souece_pwd

echo "=========================开始安装mysql==========================="


yum -y install epel-release

useradd -s /sbin/nologin mysql

for mysql_depend_pack in gcc gcc-c++ make tar openssl openssl-devel cmake ncurses ncurses-devel;do
mysql_depend_result=$(rpm -qa $mysql_depend_pack)
if [ -z "$mysql_depend_result" ];then
yum install -y $mysql_depend_pack
else
echo "$mysql_depend_pack is 判断是否安装mysql依赖包OK"
fi
done


mysqldownloadurl="http://192.168.80.113/mysql-5.6.39.tar.gz"

cd $mysql_souece_pwd

wget "$mysqldownloadurl"

mysql_targz_name=$(echo $mysqldownloadurl | sed 's#.*/##')

tar -zxvf $mysql_targz_name

mysql_dir_name=$(echo $mysql_targz_name | sed 's/.tar.gz//')

cd $mysql_dir_name

 

cmake -DCMAKE_INSTALL_PREFIX=$mysql_souece_pwd -DMYSQL_DATADIR=$data_mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=all -DWITH_DEBUG=0 -DWITH_SSL=yes -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 2>/tmp/aa

make -j4 && make install

cp support-files/mysql.server /etc/init.d/mysqld

 

chmod a+x /etc/init.d/mysqld

cd "$mysql_dir_name"

cp my.cnf my.cnf.bak

mkdir /usr/local/mysql/etc

mv my.cnf /usr/local/mysql/etc/my.cnf.bak

rm -rf /usr/local/mysql/my.cnf

mkdir -pv /data


chmod 777 /data

chown -R mysql:mysql /data/

 

mkdir -pv /data/mysql


chmod 777 /data/mysql

chown -R mysql:mysql /data/mysql

chown -R mysql:mysql /usr/local/mysql/data

chown -R mysql:mysql /usr/local/mysql /data/mysql


echo "[mysqld]
bind-address=0.0.0.0
port=3306
datadir=/data/mysql
user=mysql
skip-name-resolve
long_query_time=2
slow_query_log_file=/data/mysql/mysql-slow.log
expire_logs_days=2
innodb-file-per-table=1
innodb_flush_log_at_trx_commit = 2
log_warnings = 1
max_allowed_packet = 512M
connect_timeout = 60
net_read_timeout = 120

[mysqld_safe]
log-error=/data/mysql/mysqld.log
pid-file=/data/mysql/mysqld.pid " > /usr/local/mysql/etc/my.cnf


chmod 777 /usr/lib/systemd/system/mysqld.service


mkdir /var/lib//mysql

chmod 777 /var/lib//mysql

 

yum install -y perl-Module-Install


/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --user=mysql --datadir=/data/mysql/

echo '[Unit]
Description=mysqld
After=network.target
[Service]
Type=forking
ExecStart=/etc/init.d/mysqld start
[Install]
WantedBy=multi-user.target' > /usr/lib/systemd/system/mysqld.service

chmod 777 /usr/lib/systemd/system/mysqld.service

ln -s /usr/local/mysql/bin/mysql /usr/bin

 

echo 'export PATH=$PATH:/usr/local/mysql/bin/' >>/etc/profile

programName=${0##*/}

source /etc/profile $programName


#systemctl daemon-reload

systemctl enable mysqld

systemctl restart mysqld.service

systemctl enable mysqld.service

firewall-cmd --zone=public --add-port=3306/tcp --permanent

firewall-cmd --reload

 

 

 

else

echo "=========================安装mysql失败已经安装过mysql==========================="

fi

 

 

#下面是安装wordpress


#mysqladmin -h 127.0.0.1 -u root password 'sjgtest666_SJG' <<EOF
#flush privileges;
#EOF

mysql -uroot -h 127.0.0.1 <<EOF
delete from mysql.user where user='';
set password for 'root'@'127.0.0.1'=password('sjgtest666_SJG');
flush privileges;
EOF


mysql -uroot -h 127.0.0.1 -p'sjgtest666_SJG' <<EOF
#create user 'wordpress'@'127.0.0.1' identified with mysql_native_password by 'sjgtest666_SJG';
#grant all privileges on wordpress.* to 'wordpress'@'127.0.0.1' with grant option;
create database wordpress character set utf8;
set names utf8;
create user wordpress@'127.0.0.1' identified by 'sjgtest666_SJG';
grant all privileges on wordpress.* to wordpress@'127.0.0.1';
flush privileges;
quit
EOF


cd /usr/local/src

wget 'http://192.168.80.113/wordpress-6.0.1-zh_CN.zip'

yum install -y unzip

#unzip latest-zh_CN.zip

unzip wordpress-6.0.1-zh_CN

 

mv wordpress/ /usr/local/nginx/html/

cd /usr/local/nginx/html/wordpress/

cp wp-config-sample.php wp-config.php

 

 

sed -i "23c define('DB_NAME', 'wordpress');" /usr/local/nginx/html/wordpress/wp-config.php

sed -i "26c define('DB_USER', 'wordpress');" /usr/local/nginx/html/wordpress/wp-config.php

sed -i "29c define('DB_PASSWORD', 'sjgtest666_SJG');" /usr/local/nginx/html/wordpress/wp-config.php

sed -i "32c define('DB_HOST', '127.0.0.1');" /usr/local/nginx/html/wordpress/wp-config.php

 

 

#chmod 757 /usr/local/nginx/conf/nginx.conf/wp-content/ 


chmod 757 /usr/local/nginx/html/wordpress/wp-content/ 

 

yum install unzip wget -y

cd /usr/local/nginx/html/

wget 'http://192.168.80.113/phpMyAdmin-4.8.1-all-languages.zip'

unzip phpMyAdmin-4.8.1-all-languages.zip

mv phpMyAdmin-4.8.1-all-languages phpmyadmin4.8.1

cd phpmyadmin4.8.1

cp libraries/config.default.php config.inc.php

sed -i "131c "'$cfg'"['Servers']["'$i'"]['host'] = '127.0.0.1';" /usr/local/nginx/html/phpmyadmin4.8.1/config.inc.php

sed -i "262c "'$cfg'"['Servers']["'$i'"]['user'] = 'root';" /usr/local/nginx/html/phpmyadmin4.8.1/config.inc.php

sed -i "269c "'$cfg'"['Servers']["'$i'"]['password'] = 'sjgtest666_SJG';" /usr/local/nginx/html/phpmyadmin4.8.1/config.inc.php

systemctl restart nginx.service


根据51cto实践哥课程编写脚本,,,,本文版权归作者所有,欢迎转载,转载请注明链接,如果文章有写的不足的地方,或者是写得错误的地方,请你一定要指出,因为这样不光是对我写文章的一种促进,也是一份对后面看此文章的人的责任。谢谢

一键安装wordpress - LY龙 - 博客园 (cnblogs.com)

标签:--,local,一键,nginx,wordpress,usr,mysql,php,安装
From: https://www.cnblogs.com/lypro/p/wordpress_low_version.html

相关文章

  • centos 7 安装python 3
    1.下载安装相关依赖,用来下载编译python3yum-yinstallzlib-develbzip2-developenssl-develncurses-develsqlite-develreadline-develtk-develgccmake2.安装epe......
  • 一键安装zhabix4.0.3
    #!/bin/bash nginx_souecepwd=/usr/local/nginx#源码安装路径cdnginx_configpwd=/usr/local/nginx/confsystemd_ExecStartpwd=/usr/local/nginx/sbin/nginxif[!-......
  • Python爬虫常用:谷歌浏览器驱动——Chromedriver 插件安装教程
    我们在做爬虫的时候经常要使用谷歌浏览器驱动,今天分享下这个Chromedriver插件的安装方法。第一步、打开谷歌浏览器打开设置面板第二步、查看当前谷歌浏览器版本号第三步、......
  • docker安装nacos集群
    1.临时启动dockerrun--namenacos-d-p8848:8848-p9848:9848-p9849:9849nacos/nacos-server:v2.1.12.创建配置文凭挂载目录mkdir-p/opt/docker/nacos/con......
  • maven的安装、仓库的种类和彼此关系
    maven的安装     maven仓库的种类和彼此的关系本地仓库:用来存储从远程仓库或中央仓库下载的插件和jar包,项目使用一些插件或jar包,优先从本地仓库查找默认本......
  • centos安装docker
    0.安装DockerDocker分为CE和EE两大版本。CE即社区版(免费,支持周期7个月),EE即企业版,强调安全,付费使用,支持周期24个月。DockerCE分为stabletest和nightly......
  • 我的Github-博客左上角可一键进入
    我的Github主页网址:https://github.com/BXF-Aurora168博客左上角可一键进入  github我很早就注册了,只是由于访问速度的问题一直没有使用。使用Steamcommunity30......
  • 如果个人pc上要装不同社区版本的pycharm,安装时需要注意的一点
    pycharm下载地址[包含了目前发行的所有版本]:https://www.jetbrains.com/pycharm/download/other.html选择指定的版本,点击     勾选uninstallsilently(sett......
  • hadoop - hadoop2.6 分布式 - 集群环境搭建 - JDK安装配置和SSH安装配置与免密码登陆(
    1.背景  我的搭建环境是自己的笔记本(deepinlinux系统)+VriutalBox(3台ubuntu系统);              网络配置上篇已经说过了,但是出了点差错,......
  • Containerd安装配置及基本操作
    一、安装1.下载(https://github.com/containerd/containerd)wgethttps://github.com/containerd/containerd/releases/download/v1.6.10/cri-containerd-1.6.10-linux-amd64.......