这个操作指南解释了你将如何安装 Apache 在 RHEL、CentOS 7 linux 上使用最新 MariaDB 和 PHP 的服务器,通过 Yum 工具使用 Remi 存储库。
安装 REMI 存储库
第一的 启用 remi 存储库:
rpm -ivh https://dl.fedoraproject.org/pub/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm
安装 MariaDB (MySQL)
要安装 MySQL,我们确实像这样安装 mariadb:
yum -y install mariadb-server mariadb
现在,创建 MySQL 的系统启动链接并启动 MySQL 服务器:
systemctl start mariadb.service systemctl enable mariadb.service
为 MySQL 根帐户设置密码:
mysql_secure_installation
[[email protected] ~]# mysql_secure_installation /usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): <--ENTER OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] New password: <--yourmariadbpassword Re-enter new password: <--yourmariadbpassword Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] <--ENTER ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] <--ENTER ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] <--ENTER - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] <--ENTER ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB! [[email protected] ~]#
安装 Apache 服务器
CentOS 7.0 附带 apache 2.4。 Apache2 可直接作为 CentOS 7.0 软件包使用,因此我们可以像这样安装它:
yum -y install httpd
现在,配置您的系统以启动 Apache 在启动时:
systemctl start httpd.service systemctl enable httpd.service
在 CentOS 7.0 中使用 Firewall-cmd。 使用以下命令允许 http 和 https 外部访问。
firewall-cmd --permanent --zone=public --add-service=http firewall-cmd --permanent --zone=public --add-service=https firewall-cmd --reload
现在将您的浏览器定向到 https://ip.add.re.ss/,您应该会看到 Apache2 占位符页面:
安装 PHP
我们可以安装 PHP 宽度 MySQL 支持和一些常见的 PHP 模块,这些模块是 CMS 系统(如 WordPress、Joomla 和 Drupal)所需的,使用以下命令:
yum -y install php php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
默认网站的文档根目录是 /var/www/html。 我们现在将在该目录中创建一个小的 PHP 文件 (info.php) 并在浏览器中调用它。 该文件将显示有关我们的 PHP 安装的许多有用的详细信息,例如已安装的 PHP 版本。
vi /var/www/html/info.php
现在我们在浏览器中调用该文件(例如 https://ip.add.re.ss/info.php):