Dynadot Jtti 搬瓦工 腾讯云

使用 LAMP 一键包部署 Linux 建站环境

GigsGigsCloud

做网站的第一步,就是配置网站的运行环境。今天以 Linux + Apache + MySQL + PHP 的环境为例,介绍一下 LAMP 一键包配置建站环境的过程。看完后相信大家都能独立的完成网站环境的部署。

准备工作

安装前我们需要做一些准备工作。

安装一些必要的软件:

yum -y install wget screen git // for CentOS 
apt-get -y install wget screen git // for Debian/Ubuntu

下载脚本,并赋予权限:

git clone https://github.com/teddysun/lamp.git 
cd lamp 
chmod +x *.sh

开始安装:

screen -S lamp 
./lamp.sh

开始安装

下面对安装过程中出现的选项做一下解答。

+-------------------------------------------------------------------+
| Auto Install LAMP(Linux + Apache + MySQL/MariaDB/Percona + PHP )  |
| Website: https://lamp.sh                                          |
| Author : Teddysun <i@teddysun.com>                                |
+-------------------------------------------------------------------+

--------------------- System Information ----------------------------

CPU model            : QEMU Virtual CPU version (cpu64-rhel6)
Number of cores      : 1
CPU frequency        : 2599.996 MHz
Total amount of ram  : 733 MB
Total amount of swap : 0 MB
System uptime        : 0days, 14:27:52
Load average         : 0.00, 0.02, 0.00
OS                   : Ubuntu 16.04.3 LTS
Arch                 : x86_64 (64 Bit)
Kernel               : 4.4.0-93-generic
Hostname             : oldtang.com
IPv4 address         : 

---------------------------------------------------------------------

-------------------------- apache setting ---------------------------

1) httpd-2.4.29
2) do_not_install

which apache you'd select (default httpd-2.4.29):   // 选择需要安装的 Apache 版本,默认即可。

your selection: httpd-2.4.29
-------------------------- apache_modules install --------------------------

1) mod_wsgi-4.5.22
2) mod_jk-1.2.42
3) do_not_install

Please input one or more number between 1 and 3 (default do_not_install) (for example: 1 2 3):   // 选择需要安装的 Apache 组件,不需要的话就默认。

your selection: do_not_install

-------------------------- mysql setting ---------------------------

1) mysql-5.5.58
2) mysql-5.6.38
3) mysql-5.7.20
4) mariadb-5.5.58
5) mariadb-10.0.33
6) mariadb-10.1.29
7) mariadb-10.2.11
8) Percona-Server-5.5.58-38.10
9) Percona-Server-5.6.38-83.0
10) Percona-Server-5.7.20-18
11) do_not_install

which mysql you'd select (default mariadb-10.1.29):   // 选择需要安装的数据库版本,建议默认。

your selection: mariadb-10.1.29

mariadb data location(default:/usr/local/mariadb/data, leave blank for default):   // 选择数据库位置,不改的话默认即可。

mariadb data location: /usr/local/mariadb/data

mariadb server root password (default:root, leave blank for default):   // 输入 MySQL 数据库密码,请牢记,并设置的复杂一些。

mariadb server root password: root

-------------------------- php setting ---------------------------

1) php-5.6.32
2) php-7.0.26
3) php-7.1.12
4) php-7.2.0
5) do_not_install

which php you'd select (default php-5.6.32):   // 选择 PHP 版本。

your selection: php-5.6.32

php-5.6.32 available modules:

-------------------------- php_modules install --------------------------

1) ioncube_loaders
2) xcache-3.2.0
3) php-imagick-3.4.3
4) php-gmagick-1.1.7RC3
5) php-memcached-3.0.3
6) php-redis-2.2.8
7) php-mongodb-1.3.1
8) php-swoole-2.0.10
9) xdebug-2.5.5
10) do_not_install

Please input one or more number between 1 and 10 (default do_not_install) (for example: 1 2 3):   // 选择需要安装的 PHP 模块。

your selection: do_not_install

-------------------------- phpmyadmin setting ---------------------------

1) phpMyAdmin-4.7.6-all-languages
2) do_not_install

which phpmyadmin you'd select (default phpMyAdmin-4.7.6-all-languages):   // 选择是否需要安装 phpmyadmin。

------------------------- Install Overview --------------------------

Apache: httpd-2.4.29
Apache Location: /usr/local/apache


MariaDB: mariadb-10.1.29
MariaDB Location: /usr/local/mariadb
MariaDB Data Location: /usr/local/mariadb/data
MariaDB Root Password: sqpzVqs34tVdzQnB

PHP: php-5.6.32
PHP Location: /usr/local/php

phpMyAdmin: phpMyAdmin-4.7.6-all-languages
phpMyAdmin Location: /data/www/default/phpmyadmin

---------------------------------------------------------------------

Press any key to start...or Press Ctrl+C to cancel  // 确认配置信息,没有问题的话按任意键开始安装,有问题的话按 Ctrl + C 取消,重新配置。

安装完成:

[Info] phpMyAdmin-4.7.6-all-languages.tar.gz download completed...
[Info] phpMyAdmin-4.7.6-all-languages install completed...
[Info] Starting clean up...
[Info] Clean up completed...

Congratulations, LAMP install completed!

看到这些信息,就代表安装完成了。

添加网站

使用命令:

lamp add

进行添加网站。

# lamp add
Please enter server names(example: www.lamp.sh lamp.sh): oldtang.com www.oldtang.com  // 输入域名。
Please enter website root directory(default:/data/www/oldtang.com):   // 输入网站根目录,建议默认。
Please enter Administrator Email address: contact@oldtang.com  // 输入邮箱。
Administrator Email address:contact@oldtang.com
Do you want to create a database and mysql user with same name? [y/n]:y  // 选择是否添加数据库。
Please enter your MariaDB root password:  // 输入之前设置的数据库密码。
Please enter the database name:qiaome  // 输入数据库名称。
Please set the password for user qiaome:qiaome  // 输入数据库密码。
Virtual host [oldtang.com] has been created
Website root directory is: /data/www/oldtang.com
Database [qiaome] and mysql user [qiaome] has been created
Reloading the apache config file...
Syntax OK
Reload success
Do you want to add a SSL certificate? [y/n]:y  // 选择是否添加 SSL 证书。
1: Use your own SSL Certificate and Key
2: Use Let's Encrypt to create SSL Certificate and Key
Please enter 1 or 2:   // 选择 SSL 证书添加方式。

此外,

lamp add 创建虚拟主机 
lamp del 删除虚拟主机 
lamp list 列出虚拟主机

升级、卸载

升级:

git pull // Get latest version 
./upgrade.sh // Select one to upgrade 
./upgrade.sh apache // Upgrade Apache 
./upgrade.sh db // Upgrade MySQL/MariaDB/Percona 
./upgrade.sh php // Upgrade PHP 
./upgrade.sh phpmyadmin // Upgrade phpMyAdmin

卸载:

./uninstall.sh

更多操作,可以查看参考文献。

相信大家看完后,都可以完成自己的网站环境的配置。笔者目前的所有网站都是基于这样配置的。

参考文献

Dynadot Hostwinds
赞(1)
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《使用 LAMP 一键包部署 Linux 建站环境
文章链接:https://oldtang.com/364.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。