目录
3.2. 安装Apache
操作系统准备就绪,开始安装Apache
0000@0000:/root$ sudo apt install apache2 apache2-utils
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
apache2-bin apache2-data libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libcurl4
liblua5.3-0 ssl-cert
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser
The following NEW packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3
libaprutil1-ldap libcurl4 liblua5.3-0 ssl-cert
0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
Need to get 2,827 kB of archives.
After this operation, 9,236 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
安装完成后查看一下apache服务状态
0000@0000 ~$ sudo systemctl status apache2.service
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; preset: enabled)
Active: active (running) since Thu 2023-08-17 22:51:28 CST; 2 days ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 647 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Process: 1572 ExecReload=/usr/sbin/apachectl graceful (code=exited, status=0/SUCCESS)
Main PID: 736 (apache2)
Tasks: 6 (limit: 4915)
Memory: 94.8M
CPU: 1min 12.018s
CGroup: /system.slice/apache2.service
├─ 736 /usr/sbin/apache2 -k start
├─1629 /usr/sbin/apache2 -k start
├─1630 /usr/sbin/apache2 -k start
├─1631 /usr/sbin/apache2 -k start
├─1632 /usr/sbin/apache2 -k start
└─1633 /usr/sbin/apache2 -k start
Aug 17 22:51:16 0000 systemd[1]: Starting apache2.service - The Apache HTTP Server...
Aug 17 22:51:28 0000 apachectl[678]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 192.168>
Aug 17 22:51:28 0000 systemd[1]: Started apache2.service - The Apache HTTP Server.
Aug 18 00:00:45 0000 systemd[1]: Reloading apache2.service - The Apache HTTP Server...
Aug 18 00:00:45 0000 apachectl[1118]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 192.16>
Aug 18 00:00:45 0000 systemd[1]: Reloaded apache2.service - The Apache HTTP Server.
Aug 20 09:44:02 0000 systemd[1]: Reloading apache2.service - The Apache HTTP Server...
Aug 20 09:44:03 0000 apachectl[1619]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 192.16>
Aug 20 09:44:03 0000 systemd[1]: Reloaded apache2.service - The Apache HTTP Server.
如果发现apache没有启动,输入下面的命令手动启动一下
$ sudo systemctl start apache2
开启开机自动启动
$ sudo systemctl enable apache2
查看一下Apache版本
0000@0000:~$ sudo apache2 -v
Server version: Apache/2.4.57 (Debian)
Server built: 2023-04-13T03:26:51
3.3. 安装PHP
先查询下系统目前可以安装的版本
0000@0000:/root$ sudo apt-cache show php
Package: php
Source: php-defaults (93)
Version: 2:8.2+93
Installed-Size: 10
Maintainer: Debian PHP Maintainers <该邮件地址已受到反垃圾邮件插件保护。要显示它需要在浏览器中启用 JavaScript。 >
Architecture: all
Depends: php8.2
Description-en: server-side, HTML-embedded scripting language (default)
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
open source general-purpose scripting language that is especially suited
for web development and can be embedded into HTML.
.
This package is a dependency package, which depends on latest stable
PHP version (currently 8.2).
Description-md5: cf6b9bc7f5941aa2220d6d220e85135c
Section: php
Priority: optional
Filename: pool/main/p/php-defaults/php_8.2+93_all.deb
Size: 3628
MD5sum: f44a171e582055f5fdb390c88a77065a
SHA256: bed3564e74fbddb87d80c56f2b9b6f6be35b6519a80f1819257b2e3cdeb56057
开始安装PHP及apache和mysql支持模块
0000@0000:/root$ sudo apt install php libapache2-mod-php php-mysql -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
libapache2-mod-php8.2 php-common php8.2 php8.2-cli php8.2-common php8.2-mysql php8.2-opcache
php8.2-readline
Suggested packages:
php-pear
The following NEW packages will be installed:
libapache2-mod-php libapache2-mod-php8.2 php php-common php-mysql php8.2 php8.2-cli php8.2-common
php8.2-mysql php8.2-opcache php8.2-readline
0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,678 kB of archives.
继续安装PHP扩展
0000@0000:/var/www$ sudo apt install php8.2-cli php8.2-curl php8.2-gd php8.2-intl php8.2-mbstring php8.2-opcache php8.2-readline php8.2-xml php8.2-xsl php8.2-zip php8.2-bz2
安装完成后,启用Apache php8.2,然后重新启动Apache Web服务器。
0000@0000:/var/www$ sudo a2enmod php8.2
Considering dependency mpm_prefork for php8.2:
Considering conflict mpm_event for mpm_prefork:
Considering conflict mpm_worker for mpm_prefork:
Module mpm_prefork already enabled
Considering conflict php5 for php8.2:
Module php8.2 already enabled
0000@0000:/var/www$ sudo systemctl restart apache2
3.4. 安装Mariadb
安装完PHP后开始安装MariaDB
0000@0000:/root$ sudo apt install mariadb-server mariadb-client
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
galera-4 gawk libcgi-fast-perl libcgi-pm-perl libclone-perl libconfig-inifiles-perl
libdbd-mariadb-perl libdbi-perl libencode-locale-perl libfcgi-bin libfcgi-perl libfcgi0ldbl
libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl
libhttp-message-perl libio-html-perl liblwp-mediatypes-perl liblzo2-2 libmariadb3 libmpfr6
libncurses6 libnuma1 libregexp-ipv6-perl libsigsegv2 libsnappy1v5 libterm-readkey-perl
libtimedate-perl liburi-perl liburing2 mariadb-client-core mariadb-common
mariadb-plugin-provider-bzip2 mariadb-plugin-provider-lz4 mariadb-plugin-provider-lzma
mariadb-plugin-provider-lzo mariadb-plugin-provider-snappy mariadb-server-core mysql-common
psmisc pv rsync socat
Suggested packages:
gawk-doc libmldbm-perl libnet-daemon-perl libsql-statement-perl libdata-dump-perl
libipc-sharedcache-perl libbusiness-isbn-perl libwww-perl mailx mariadb-test netcat-openbsd
doc-base python3-braceexpand
The following NEW packages will be installed:
galera-4 gawk libcgi-fast-perl libcgi-pm-perl libclone-perl libconfig-inifiles-perl
libdbd-mariadb-perl libdbi-perl libencode-locale-perl libfcgi-bin libfcgi-perl libfcgi0ldbl
libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl
libhttp-message-perl libio-html-perl liblwp-mediatypes-perl liblzo2-2 libmariadb3 libmpfr6
libncurses6 libnuma1 libregexp-ipv6-perl libsigsegv2 libsnappy1v5 libterm-readkey-perl
libtimedate-perl liburi-perl liburing2 mariadb-client mariadb-client-core mariadb-common
mariadb-plugin-provider-bzip2 mariadb-plugin-provider-lz4 mariadb-plugin-provider-lzma
mariadb-plugin-provider-lzo mariadb-plugin-provider-snappy mariadb-server mariadb-server-core
mysql-common psmisc pv rsync socat
0 upgraded, 46 newly installed, 0 to remove and 0 not upgraded.
Need to get 20.2 MB of archives.
After this operation, 182 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
查看MariaDB状态:
0000@0000:/root$ sudo systemctl status mariadb
● mariadb.service - MariaDB 10.11.3 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; preset: enabled)
Active: active (running) since Thu 2023-07-27 12:53:10 CST; 1min 44s ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 3261 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 10 (limit: 4915)
Memory: 93.0M
CPU: 1.471s
CGroup: /system.slice/mariadb.service
└─3261 /usr/sbin/mariadbd
Jul 27 12:53:09 0000 mariadbd[3261]: 2023-07-27 12:53:09 0 [Note] InnoDB: log sequence number 46702;>
Jul 27 12:53:09 0000 mariadbd[3261]: 2023-07-27 12:53:09 0 [Note] InnoDB: Loading buffer pool(s) fro>
Jul 27 12:53:09 0000 mariadbd[3261]: 2023-07-27 12:53:09 0 [Note] Plugin 'FEEDBACK' is disabled.
Jul 27 12:53:10 0000 mariadbd[3261]: 2023-07-27 12:53:10 0 [Warning] You need to use --log-bin to ma>
Jul 27 12:53:10 0000 mariadbd[3261]: 2023-07-27 12:53:10 0 [Note] Server socket created on IP: '127.>
Jul 27 12:53:10 0000 mariadbd[3261]: 2023-07-27 12:53:10 0 [Note] InnoDB: Buffer pool(s) load comple>
Jul 27 12:53:10 0000 mariadbd[3261]: 2023-07-27 12:53:10 0 [Note] /usr/sbin/mariadbd: ready for conn>
Jul 27 12:53:10 0000 mariadbd[3261]: Version: '10.11.3-MariaDB-1' socket: '/run/mysqld/mysqld.sock'>
Jul 27 12:53:10 0000 systemd[1]: Started mariadb.service - MariaDB 10.11.3 database server.
Jul 27 12:53:10 0000 /etc/mysql/debian-start[3301]: Triggering myisam-recover for all MyISAM tables >
lines 1-23/23 (END)
如果发现Mariadb没有启动则手动开启,并配置自动启动
sudo systemctl start mariadb
sudo systemctl enable mariadb
最后运行安装后的安全脚本。
sudo mysql_secure_installation
执行这个命令后,当要求你输入MariaDB根密码时,请按Enter键,因为还未设置root密码。然后输入y设置MariaDB服务器的root密码。
接下来,只需一路按Enter即可回答所有剩余的问题。
这些问题删除匿名用户,禁用远程root登录并删除测试数据库。此步骤是MariaDB数据库安全性的基本要求。
然后现在可以使用以下命令登录到MariaDB服务器。
sudo mariadb -u root
3.5. 配置数据库
登录到mariadb后,先创建网站数据库,数据库名称自行定义,尽量好记忆。
输入以下命令:
0000@0000:/var/www/html$ mariadb -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 46
Server version: 10.11.3-MariaDB-1 Debian 12
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database 0000_db;
Query OK, 1 row affected (0.001 sec)
Query OK,即表示命令执行成功。
接下来,为刚才创建的数据库创建一个用户(此用户Joomla操作网站数据库的账户)并设置一个密码:
MariaDB [(none)]> create user name@localhost;
Query OK, 0 rows affected (0.002 sec)
MariaDB [(none)]> set password for 'name'@'localhost' = password("11111111");
Query OK, 0 rows affected (0.001 sec)
然后需要使用以下命令为刚才新建的数据库赋予权限:
MariaDB [(none)]> grant all privileges on ****_db.* to 'name'@'localhost' identified by '11111111' with grant option;
Query OK, 0 rows affected (0.002 sec)
刷新权限:
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.001 sec)
从MariaDB退出:
MariaDB [(none)]> exit
Bye
至此,数据库基础配置已完成,可以安装Joomla了。