搜索
首页运维linux运维如何使用LAMP+WordPress的一键安装脚本

本篇文章给大家带来的内容是关于如何使用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 &#39;/^\[mysqld]/adatadir=/app/lamp/mysql&#39; /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 &#39;\033[1;31mStart installing httpd \033[0m&#39;
        httpd
        echo -e &#39;\033[1;31mHTTPD is finished  \033[0m&#39;
        echo -e &#39;\033[1;31mStart installing MariaDB \033[0m&#39;
        mariadb
        echo -e &#39;\033[1;31mMariaDB is finished  \033[0m&#39;
        echo -e &#39;\033[1;31mStart installing PHP \033[0m&#39;
        php
        echo -e &#39;\033[1;31mPHP is finished \033[0m&#39;
}
Main

# Add the binary to the path variable

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

# Start the service

apachectl
service mysqld start
service php-fpm start

echo -e &#39;\033[1;31mAll services are running \033[0m&#39;

# Building a blog site

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

mysql -e "create database wpdb;grant all on wpdb.* to wpuser@&#39;localhost&#39; identified by &#39;centos&#39;"
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 &#39;/DB_NAME/s/database_name_here/wpdb/&#39; wp-config.php
sed -i &#39;/DB_USER/s/username_here/wpuser/&#39; wp-config.php
sed -i &#39;/DB_PASSWORD/s/password_here/centos/&#39; wp-config.php

echo -e &#39;\033[1;31mBlog is set up  \033[0m&#39;

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

以上是如何使用LAMP+WordPress的一键安装脚本的详细内容。更多信息请关注PHP中文网其他相关文章!

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
Linux:基本命令和操作Linux:基本命令和操作Apr 24, 2025 am 12:20 AM

Linux中不可或缺的命令包括:1.ls:列出目录内容;2.cd:改变工作目录;3.mkdir:创建新目录;4.rm:删除文件或目录;5.cp:复制文件或目录;6.mv:移动或重命名文件或目录。这些命令通过与内核交互执行操作,帮助用户高效管理文件和系统。

Linux操作:管理文件,目录和权限Linux操作:管理文件,目录和权限Apr 23, 2025 am 12:19 AM

在Linux中,文件和目录管理使用ls、cd、mkdir、rm、cp、mv命令,权限管理使用chmod、chown、chgrp命令。1.文件和目录管理命令如ls-l列出详细信息,mkdir-p递归创建目录。2.权限管理命令如chmod755file设置文件权限,chownuserfile改变文件所有者,chgrpgroupfile改变文件所属组。这些命令基于文件系统结构和用户、组系统,通过系统调用和元数据实现操作和控制。

Linux中的维护模式是什么?解释了Linux中的维护模式是什么?解释了Apr 22, 2025 am 12:06 AM

MaintenancemodeInuxisAspecialBootenvironmentforforcalsystemmaintenancetasks.itallowsadMinistratorStoperFormTaskSlikerSettingPassingPassingPasswords,RepairingFilesystems,andRecoveringFrombootFailuresFailuresFailuresInamInimAlenimalenimalenrenmentrent.ToEnterMainterMainterMaintErmaintErmaintEncemememodeBoode,Interlecttheboo

Linux:深入研究其基本部分Linux:深入研究其基本部分Apr 21, 2025 am 12:03 AM

Linux的核心组件包括内核、文件系统、Shell、用户空间与内核空间、设备驱动程序以及性能优化和最佳实践。1)内核是系统的核心,管理硬件、内存和进程。2)文件系统组织数据,支持多种类型如ext4、Btrfs和XFS。3)Shell是用户与系统交互的命令中心,支持脚本编写。4)用户空间与内核空间分离,确保系统稳定性。5)设备驱动程序连接硬件与操作系统。6)性能优化包括调整系统配置和遵循最佳实践。

Linux体系结构:揭示5个基本组件Linux体系结构:揭示5个基本组件Apr 20, 2025 am 12:04 AM

Linux系统的五个基本组件是:1.内核,2.系统库,3.系统实用程序,4.图形用户界面,5.应用程序。内核管理硬件资源,系统库提供预编译函数,系统实用程序用于系统管理,GUI提供可视化交互,应用程序利用这些组件实现功能。

Linux操作:利用维护模式Linux操作:利用维护模式Apr 19, 2025 am 12:08 AM

Linux的维护模式可以通过GRUB菜单进入,具体步骤为:1)在GRUB菜单中选择内核并按'e'编辑,2)在'linux'行末添加'single'或'1',3)按Ctrl X启动。维护模式提供了一个安全环境,适用于系统修复、重置密码和系统升级等任务。

Linux:如何进入恢复模式(和维护)Linux:如何进入恢复模式(和维护)Apr 18, 2025 am 12:05 AM

进入Linux恢复模式的步骤是:1.重启系统并按特定键进入GRUB菜单;2.选择带有(recoverymode)的选项;3.在恢复模式菜单中选择操作,如fsck或root。恢复模式允许你以单用户模式启动系统,进行文件系统检查和修复、编辑配置文件等操作,帮助解决系统问题。

Linux的基本要素:为初学者解释Linux的基本要素:为初学者解释Apr 17, 2025 am 12:08 AM

Linux的核心组件包括内核、文件系统、Shell和常用工具。1.内核管理硬件资源并提供基本服务。2.文件系统组织和存储数据。3.Shell是用户与系统交互的接口。4.常用工具帮助完成日常任务。

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

VSCode Windows 64位 下载

VSCode Windows 64位 下载

微软推出的免费、功能强大的一款IDE编辑器

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

功能强大的PHP集成开发环境

螳螂BT

螳螂BT

Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

mPDF

mPDF

mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),