首页 > linux运维 > 正文

如何使用LAMP+WordPress的一键安装脚本

原创 2018-09-15 15:46:04 0 108
赞助会员专享特权
本篇文章给大家带来的内容是关于如何使用LAMP+WordPress的一键安装脚本,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。

#!/bin/bash
# Description: This is a one-click script to compile the installation LAMP (PHP in FastCGI working mode)

# Environment: centos7.5, apr-1.6.3.tar.gz, apr-util-1.6.1.tar.gz, httpd-2.4.34.tar.bz2, php-7.1.18.tar.bz2, mariadb-10.2.16-linux-x86_64.tar.gz, wordpress-4.9.4-zh_CN
.tar.gz 

# Download the above packages and place them in the /app/ 

# Ensure that yum warehouses are set up, including local CDS and epel

# All the services after compilation and installation are placed in /app/lamp/
echo -e '\033[1;5;31mBEGIN \033[0m'
mkdir -p /app/lamp

# Install the required development kit groups
echo -e '\033[1;31mInstall the group tools \033[0m'
yum groupinstall -y 'development tools'
echo -e '\033[1;31mFinish Installing the group tools \033[0m'

# Create the function to compile and install HTTPD

httpd () {
# Unzip and move folders
        cd /app
        tar xf apr-1.6.3.tar.gz
        tar xf apr-util-1.6.1.tar.gz
        tar xf httpd-2.4.34.tar.bz2
        mv apr-1.6.3 httpd-2.4.34/srclib/apr
    mv apr-util-1.6.1 httpd-2.4.34/srclib/apr-util
# Create the user and install the packages required for compilation
        useradd -r -s /sbin/nologin apache
        yum install -y pcre-devel openssl-devel expat-devel
# Start compiling and installing
        cd httpd-2.4.34/
        ./configure --prefix=/app/lamp/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --enable-modules=most --enable-mpms-share
d=all --with-mpm=prefork --with-included-apr
        make && make install
# Modify configuration file
        cd /app/lamp/httpd24/conf
        sed -i '/^User/s/daemon/apache/' httpd.conf
        sed -i '/^Group/s/daemon/apache/' httpd.conf
        sed -i 's@^#Load.∗proxy.soLoad.∗proxy.so$@\1@' httpd.conf
        sed -i 's@^#Load.∗fcgi.soLoad.∗fcgi.so$@\1@' httpd.conf
        sed -i 's@[]\+D.∗[]\+D.∗@\1index.php @' httpd.conf
        echo "Include conf/extra/httpd-php.conf" >> httpd.conf
        cd extra/
        cat > httpd-php.conf <<-EOF
        AddType application/x-httpd-php .php
        AddType application/x-httpd-php-source .phps
        ProxyRequests Off
        ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/app/lamp/httpd24/htdocs/$1
        EOF
        cd
}

# Create the function to install mysql with binary package

mariadb () {

# Create the user
        useradd -r -s /sbin/nologin mysql
# Unzip the file and create a soft connection and modify permissions
        cd /app
        tar xf mariadb-10.2.16-linux-x86_64.tar.gz  -C /usr/local/
        cd /usr/local/
        ln -s mariadb-10.2.16-linux-x86_64/ mysql
        chown -R mysql.mysql mysql/
# Initialize the database and revise the configuration file
        mkdir /app/lamp/mysql
        chown -R mysql.mysql /app/lamp/mysql
        cd /usr/local/mysql/
        scripts/mysql_install_db  --datadir=/app/lamp/mysql --user=mysql
        mkdir /etc/mysql/
        cp support-files/my-huge.cnf  /etc/mysql/my.cnf
        sed -i '/^\[mysqld]/adatadir=/app/lamp/mysql' /etc/mysql/my.cnf
# Preparation for startup script 
        cp support-files/mysql.server  /etc/init.d/mysqld
        cd
}

# Create the function to compile and install PHP

php () {
# Install the packages required for compilation
        yum install -y libxml2-devel bzip2-devel libmcrypt-devel
# Unzip and start compiling and installing
        cd /app
        tar xf php-7.1.18.tar.bz2 &> /dev/null
        cd php-7.1.18/
        ./configure --prefix=/app/lamp/php --enable-mysqlnd --with-mysqli=mysqlnd --with-openssl --with-pdo-mysql=mysqlnd --enable-mbstring --with-freetype-dir --with-
jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --enable-fpm --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php
.d --enable-maintainer-zts --disable-fileinfo
        make && make install
# Modify some necessary files
        cp php.ini-production /etc/php.ini
        cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
        chmod +x /etc/init.d/php-fpm
        cd /app/lamp/php/etc
        cp php-fpm.conf.default php-fpm.conf
        cp php-fpm.d/www.conf.default php-fpm.d/www.conf
        cd
}

Main () {
        echo -e '\033[1;31mStart installing httpd \033[0m'
        httpd
        echo -e '\033[1;31mHTTPD is finished  \033[0m'
        echo -e '\033[1;31mStart installing MariaDB \033[0m'
        mariadb
        echo -e '\033[1;31mMariaDB is finished  \033[0m'
        echo -e '\033[1;31mStart installing PHP \033[0m'
        php
        echo -e '\033[1;31mPHP is finished \033[0m'
}
Main

# Add the binary to the path variable

echo 'PATH=/app/lamp/php/bin:/app/lamp/httpd24/bin:/usr/local/mysql/bin:$PATH' > /etc/profile.d/lamp.sh
source /etc/profile.d/lamp.sh

# Start the service

apachectl
service mysqld start
service php-fpm start

echo -e '\033[1;31mAll services are running \033[0m'

# Building a blog site

echo -e '\033[1;31mStart building the blog site \033[0m'

mysql -e "create database wpdb;grant all on wpdb.* to wpuser@'localhost' identified by 'centos'"
cd /app
tar xf wordpress-4.9.4-zh_CN.tar.gz
cp -r wordpress/* /app/lamp/httpd24/htdocs/
cd /app/lamp/httpd24/htdocs/
mv wp-config-sample.php wp-config.php
sed -i '/DB_NAME/s/database_name_here/wpdb/' wp-config.php
sed -i '/DB_USER/s/username_here/wpuser/' wp-config.php
sed -i '/DB_PASSWORD/s/password_here/centos/' wp-config.php

echo -e '\033[1;31mBlog is set up  \033[0m'

echo -e '\033[1;5;31mEND \033[0m'
# END

以上就是如何使用LAMP+WordPress的一键安装脚本的详细内容,更多请关注php中文网其它相关文章!

  • 相关标签:LAMP,Linux
  • 本文原创发布php中文网 ,转载请注明出处,感谢您的尊重!
  • 相关文章


  • CentOS 6.2使用yum安装LAMP以及phpMyadmin详解_php技巧
  • [视频教程]PHP_LAMP兄弟连之PHP 9.6.文件处理之目录操作
  • [视频教程]PHP_LAMP兄弟连之PHP 9.7.文件处理之目录操作
  • [视频教程]PHP_LAMP兄弟连之PHP 8.4.正则表达式处理函数
  • 如何使用LAMP+WordPress的一键安装脚本
  • 网友评论

    文明上网理性发言,请遵守 新闻评论服务协议

    我要评论
    独孤九贱(4)_PHP视频教程

    独孤九贱(4)_PHP视频教程

    江湖传言:PHP是世界上最好的编程语言。真的是这样吗?这个梗究竟是从哪来的?学会本课程,你就会明白了。 PHP中文网出品的PHP入门系统教学视频,完全从初学者的角度出发,绝不玩虚的,一切以实用、有用...

    独孤九贱(5)_ThinkPHP5视频教程

    独孤九贱(5)_ThinkPHP5视频教程

    ThinkPHP是国内最流行的中文PHP开发框架,也是您Web项目的最佳选择。《php.cn独孤九贱(5)-ThinkPHP5视频教程》课程以ThinkPHP5最新版本为例,从最基本的框架常识开始,将...

    独孤九贱(1)_HTML5视频教程

    独孤九贱(1)_HTML5视频教程

    《php.cn原创html5视频教程》课程特色:php中文网原创幽默段子系列课程,以恶搞,段子为主题风格的php视频教程!轻松的教学风格,简短的教学模式,让同学们在不知不觉中,学会了HTML知识。 ...

    ThinkPHP5实战之[教学管理系统]

    ThinkPHP5实战之[教学管理系统]

    本套教程,以一个真实的学校教学管理系统为案例,手把手教会您如何在一张白纸上,从零开始,一步一步的用ThinkPHP5框架快速开发出一个商业项目。

    PHP入门视频教程之一周学会PHP

    PHP入门视频教程之一周学会PHP

    所有计算机语言的学习都要从基础开始,《PHP入门视频教程之一周学会PHP》不仅是PHP的基础部分更主要的是PHP语言的核心技术,是学习PHP必须掌握的内容,任何PHP项目的实现都离不开这部分的内容,通...

    相关视频教程

  • Linux C语言结构体 Linux C语言结构体
  • 兄弟连新版Linux视频教程 兄弟连新版Linux视频教程
  • 后盾网Linux视频教程 后盾网Linux视频教程
  • 布尔教育Linux优化视频教程 布尔教育Linux优化视频教程
  • 相关视频章节