如何在Fedora 27上安装LAMP Stack
“ LAMP”堆栈是一组免费软件,通常会一起安装以使服务器能够托管动态和Web应用程序。
该术语实际上是首字母缩写词,代表Linux操作系统以及Apache Web服务器,MySQL和PHP。
其中站点数据存储在MySQL数据库中,动态内容由PHP处理。
Fedora 27是我们的最新免费,领先的操作系统,具有最佳的GNOME桌面环境。
在本文中,我将解释如何在Fedora 27上使用WordPress安装LAMP堆栈。
安装Apache
服务器存储库本身中包含所有最新版本的Apache,Mysql和PHP。
因此,我们可以使用简单的dnf命令安装所有软件包,而无需任何第三方存储库。
我们可以通过在下面运行以下命令来安装Apache:
#dnf install httpd
确保启用并启动服务。
# systemctl enable httpd.service Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service. # systemctl start httpd.service # systemctl status httpd.service ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2016-11-29 04:20:06 UTC; 6s ago Docs: man:httpd.service(8) Main PID: 9498 (httpd) Status: "Processing requests..." Tasks: 213 (limit: 4915) CGroup: /system.slice/httpd.service ├─9498 /usr/sbin/httpd -DFOREGROUND ├─9499 /usr/sbin/httpd -DFOREGROUND ├─9500 /usr/sbin/httpd -DFOREGROUND ├─9501 /usr/sbin/httpd -DFOREGROUND └─9502 /usr/sbin/httpd -DFOREGROUND
现在,我们可以通过在浏览器中访问服务器IP来确认已安装的Apache版本并测试其是否正常工作,就像>> >>“ http://服务器IP或者主机名/”
# httpd -V Server version: Apache/2.4.29 (Fedora) Server built: Oct 25 2016 12:34:45 Server's Module Magic Number: 20120211:68 Server loaded: APR 1.6.3, APR-UTIL 1.6.1 Compiled using: APR 1.6.2, APR-UTIL 1.6.0 Architecture: 64-bit Server MPM: event threaded: yes (fixed thread count) forked: yes (variable process count)
安装MariaDB
其次,我们需要安装数据库服务器。
我们可以通过运行以下命令来安装最新版本:
# dnf install mariadb-server # mysql -V mysql Ver 15.1 Distrib 10.2.9-MariaDB, for Linux (x86_64) using readline 5.1
启动/启用MariaDB服务并检查其状态。
# systemctl start mariadb.service # systemctl enable mariadb.service Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service. # systemctl status mariadb.service ● mariadb.service - MariaDB 10.2 database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2016-11-29 04:26:32 UTC; 15s ago Main PID: 12371 (mysqld) Status: "Taking your SQL requests now..." Tasks: 43 (limit: 4915) CGroup: /system.slice/mariadb.service └─12371 /usr/libexec/mysqld --basedir=/usr
接下来,我们将需要保护数据库服务器的安全。
我们可以运行以下命令来保护MariaDB数据库并设置root密码:
# mysql_secure_installation
安装PHP
要安装最新的PHP及其一些重要模块,请在终端上使用以下命令:
# dnf install php php-common # dnf install php php-common php-mysqlnd php-gd php-imap php-xml php-cli php-opcache php-mbstring # systemctl restart httpd
我们需要重新启动Apache才能使这些更改生效。
现在,我们可以在域文档根目录下创建一个php信息页面,以确认其版本。
# cd /var/www/html #echo "<?php phpinfo(); ?>" >> info.php
我们可以浏览URL >>'http://ServerIP/info.php'以确认其正常工作。
我们已经在Fedora 27上成功安装了LAMP stack。
现在,是时候建立我们的WordPress教程 了。
让我们按照以下步骤安装WordPress:
安装WordPress
我们可以从其官方下载最新的WordPress下载文件,并将其解压缩到根目录/var/www/html中进行安装。
# dnf install wget # wget http://wordpress.org/latest.tar.gz # tar -xvf latest.tar.gz -C /var/www/html/
为WordPress创建MariaDB/MySQL数据库
我们需要为WordPress安装创建数据库和用户,为此,请运行以下命令:
mysql -u root -p Enter password: MariaDB [(none)]> CREATE USER wpuser@localhost IDENTIFIED BY "password"; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> CREATE DATABASE wp_database; Query OK, 1 row affected (0.01 sec) MariaDB [(none)]> GRANT ALL ON wp_database.* TO wpuser@localhost; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)
我们已经连接到MySQL Shell,并为用户WordPress安装创建了名为“ wp_database”和用户“ wpuser”的数据库。
现在,我们需要从模板“ wp-config-sample.php”文件创建“ wp-config.php”,并使用我们创建的MySQL设置修改MySQL设置,以开始安装。
#cd /var/www/html/wordpress/ #cp wp-config-sample.php wp-config.php
我已经使用创建的数据库详细信息修改了文件设置。
//** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'wp_database'); /** MySQL database username */ define('DB_USER', 'wpuser'); /** MySQL database password */ define('DB_PASSWORD', 'password'); /** MySQL hostname */ define('DB_HOST', 'localhost');
现在,我们可以浏览以下URL >>'http://服务器IP或者主机名/wordpress /'以完成我们的安装。
我们可以设置管理员凭据和标题以完成安装阶段。
现在,我们可以使用创建的凭据浏览URL >>'http://Server IP/wordpress/wp-login.php',访问管理区域。
就这样!我们已在Fedora 27服务器上成功安装了WordPress。
现在,我们可以按照要求自定义WordPress 。