本文介绍在Arch Linux/Manjaro操作系统上安装Apache、PHP、MariaDB的方法,内容有安装Apache httpd Web服务器、安装PHP和基本扩展、安装MariaDB数据库。
建议先更新Arch Linux/Manjaro系统 在安装Apache、PHP和MariaDB之前,建议运行以下命令更新Arch Linux/Manjaro系统: $ sudo pacman -Syu 返回的信息如下: :: Synchronizing package databases... core is up to date extra 1549.6 KiB 3.78 MiB/s 00:00 [########################] 100% community 5.5 MiB 8.95 MiB/s 00:01 [########################] 100% :: Starting full system upgrade... resolving dependencies... looking for conflicting packages... Packages (1) libldap-2.4.58-3 Total Download Size:0.30 MiB Total Installed Size:0.91 MiB Net Upgrade Size:0.00 MiB :: Proceed with installation? [Y/n] y
安装Apache httpd Web服务器 系统更新后,执行Apache Web服务器的安装: $ sudo pacman -Sy apache vim bash-completion 返回的信息如下: :: Synchronizing package databases... core is up to date extra is up to date community is up to date resolving dependencies... looking for conflicting packages... Packages (3) apr-1.7.0-3 apr-util-1.6.1-8 apache-2.4.47-1 Total Download Size:2.10 MiB Total Installed Size:8.16 MiB :: Proceed with installation? [Y/n] y 设置服务器名称: $ sudo vim /etc/httpd/conf/httpd.conf ServerName mysite.example.com 安装后启动Apache Web服务器: sudo systemctl enable --now httpd 让我们确认服务状态: $ systemctl status httpd 返回信息大致如下: httpd.service - Apache Web Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: active (running) archlinux systemd[1]: Started Apache Web Server.
在Arch Linux/Manjaro Linux上安装PHP 运行以下命令在Arch Linux/Manjaro上安装PHP和PHP的基本扩展: $ sudo pacman -Sy php php-{cgi,gd,pgsql,fpm,apache} 返回的信息如下: :: Synchronizing package databases... core is up to date extra is up to date community is up to date resolving dependencies... looking for conflicting packages... warning: dependency cycle detected: warning: harfbuzz will be installed before its freetype2 dependency Packages (38) aom-3.1.0-1 dav1d-0.9.0-1 fontconfig-2:2.13.93-4 freetype2-2.10.4-1 gd-2.3.2-2 giflib-5.2.1-2 graphite-1:1.3.14-1 harfbuzz-2.8.1-1 libavif-0.9.0-2 libde265-1.0.8-1 libheif-1.12.0-1 libice-1.0.10-3 libjpeg-turbo-2.1.0-1 libpng-1.6.37-3 libsm-1.2.3-2 libtiff-4.3.0-1 libwebp-1.2.0-1 libx11-1.7.1-1 libxau-1.0.9-3 libxcb-1.14-1 libxdmcp-1.1.3-3 libxext-1.3.4-3 libxpm-3.5.13-2 libxt-1.2.1-1 libyuv-r2212+dfaf7534-2 libzip-1.7.3-2 oniguruma-6.9.7.1-1 postgresql-libs-13.3-2 rav1e-0.4.1-1 svt-av1-0.8.7-1 x265-3.5-1 xcb-proto-1.14.1-3 xorgproto-2021.4-1 php-8.0.6-1 php-cgi-8.0.6-1 php-fpm-8.0.6-1 php-gd-8.0.6-1 php-pgsql-8.0.6-1 Total Download Size:27.55 MiB Total Installed Size:143.27 MiB :: Proceed with installation? [Y/n] y 将/etc/php/php.ini中的以下行取消注释到MySQL/MariaDB扩展: $ sudo vim /etc/php/php.ini extension=pdo_mysql extension=mysqli 参考:在Arch Linux/Manjaro系统上安装PHP 7.3的方法。
安装MariaDB数据库服务器 在Arch Linux/Manjaro上安装MariaDB数据库服务器: $ sudo pacman -S libmariadbclient mariadb mariadb-clients 返回的信息如下: resolving dependencies... looking for conflicting packages... Packages (6) jemalloc-1:5.2.1-3 libaio-0.3.112-2 lzo-2.10-3 mariadb-10.5.10-1 mariadb-clients-10.5.10-1 mariadb-libs-10.5.10-1 Total Download Size:36.35 MiB Total Installed Size:305.29 MiB :: Proceed with installation? [Y/n] y 使用以下命令初始化数据库服务器: $ sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql 相关截图如下:
启动并启用MariaDB服务: sudo systemctl enable --now mysqld.service 保护您的数据库服务器: $ sudo mysql_secure_installation 相关截图如下:
以root用户身份打开MySQL Shell: $ mysql -u root -p 返回的信息大致如下: Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 14 Server version: 10.5.10-MariaDB Arch Linux 至此,安装MariaDB数据库完成。
相关主题 |