Linux: LAMP environment to build a cloud server centos7

Copyright: Original, welcome to reprint https://blog.csdn.net/weixin_43731793/article/details/91471007

1, install Apache

1.1 Installation

sudo yum -y install httpd
Here Insert Picture Description
Here Insert Picture Description

1.2, Apache started on the server

sudo systemctl start httpd.service

1.3, the Apache can boot

sudo systemctl enable httpd.service

Here Insert Picture Description

1.4, the browser enter your IP or Web site, you can see the Apache welcome page

Here Insert Picture Description

2, installation of MySQL (MariaDB)

MariaDB is an open source version of MySQL database management system branch. Basically, it will organize and visit our web site can store database information.

2.1 Installation

sudo yum install mariadb-server mariadb
Here Insert Picture Description

2.2 start

sudo systemctl start mariadb

2.3, set a password

2.3.1, and now we are running the MySQL database, we want to run a simple script to safety, it removes some of the risk of defaults, and lock access to our database system. Run the following script to start interactive:

sudo mysql_secure_installation
Here Insert Picture Description

2.3.2 prompts will ask your current root password. Since you have just installed MySQL, you will most likely not have one, so press the Enter key blank. Then prompt will ask if you want to set the root password. Continue input Y, and set a password in accordance with the instructions:

Here Insert Picture Description

2.3.3, remove the default anonymous user

By default, a MariaDB installation has an anonymous user, allowing anyone

By default, Mariadb fitted with an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

Login Mariadb without having to create a user account

them. This is intended only for testing, and to make the installation

they. Only for testing and installation

go a bit smoother. You should remove them before moving into aproduction environment.

稍微平稳一点。在进入生产环境之前,应将其移除
Here Insert Picture Description

2.3.4、是否关闭远程连接mysql数据库

Normally, root should only be allowed to connect from ‘localhost’. This

通常,只允许根目录从“localhost”连接。这个

ensures that someone cannot guess at the root password from the network.

确保有人无法猜测网络中的根密码。
Here Insert Picture Description

2.3.5、删除默认测试数据库

By default, MariaDB comes with a database named ‘test’ that anyone can

默认情况下,Mariadb提供了一个名为“test”的数据库,任何人都可以

access. This is also intended only for testing, and should be removed

访问。这也仅用于测试,应将其移除。

before moving into a production environment.

在进入生产环境之前。
Here Insert Picture Description

2.3.6、重新加载,立刻生效

Reloading the privilege tables will ensure that all changes made so far

重新加载特权表将确保到目前为止所做的所有更改

will take effect immediately.

将立即生效。
Here Insert Picture Description

2.4、最后一件事就是让 MariaDB 开机启动

sudo systemctl enable mariadb.service

Here Insert Picture Description

3、安装PHP

3.1、安装

sudo yum install php php-mysql

Here Insert Picture Description
Here Insert Picture Description

3.2、重新启动 Apache Web 服务器才能使用 PHP

sudo systemctl restart httpd.service

3.3、安装PHP模块

为了增强 PHP 的功能,我们可以选择安装一些其他模块。

要查看 PHP 模块和库的可用选项,可以在系统中键入:

yum search php-
结果都是您可以安装的可选组件。它会给你一个简短的描述:

php-bcmath.x86_64 : A module for PHP applications for using the bcmath library

php-cli.x86_64 : Command-line interface for PHP php-common.x86_64 : Common files for PHP php-dba.x86_64 : A database abstraction layer module for PHP applications php-devel.x86_64 : Files needed for building PHP extensions php-embedded.x86_64 : PHP library for embedding in applications php-enchant.x86_64 : Enchant spelling extension for PHP applications php-fpm.x86_64 : PHP FastCGI Process Manager php-gd.x86_64 : A module for PHP applications for using the gd graphics library . . .
要获得有关每个模块的更多信息,您可以搜索互联网,也可以通过键入以下内容查看包中的长描述:

yum info package_name
会有很多输出,一个字段称为Description的提供的功能的详细解释。

例如,要了解 php-fpm 模块的功能,我们可以键入:

yum info php-fpm
除了大量的其他信息,您会发现如下所示:

. . .
Summary : PHP FastCGI Process Manager URL : http://www.php.net/ License : PHP and Zend and BSD Description : PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI : implementation with some additional features useful for sites of : any size, especially busier sites.
如果在研究之后,您决定要安装一个软件包,可以使用 yum install 像我们一直在为其他软件做的命令这样做。

如果我们决定这 php-fpm 是我们需要的,我们可以输入:

sudo yum install php-fpm
如果要安装多个模块,可以按照以下 yum install 命令,列出每个模块,按空格分隔:

sudo yum install 模块1 模块2 …
此时,您的 LAMP 已安装并配置。我们仍然应该测试我们的 PHP。

4、配置防火墙-(安全组)

4.1、填写端口

Here Insert Picture Description

4.2、关联实例

Here Insert Picture Description

5、在Web服务器上测试PHP处理

为了测试我们的系统正确配置 PHP,我们可以创建一个非常基本的 PHP 脚本。

我们将调用这个脚本info.php。为了使Apache能够找到文件并正确地提供该文件,它必须保存到一个特定的目录,称为“Web根目录”。

在 CentOS 7 中,此目录位于 /var/www/html/。我们可以通过键入以下内容在该位置创建文件:

sudo vi /var/www/html/info.php
This will open a blank document. We would like to put the following text in the document, which is valid PHP code:

<?php phpinfo(); ?>

When finished, save and close the file.

6, install phpMyAdmin

phpMyAdmin is a PHP-based, Web-Base mode architecture MySQL database management tool on the website of the host, so that managers available Web interface to manage MySQL database. Installation is as follows:

yum –y install phpmyadmin

Guess you like

Origin blog.csdn.net/weixin_43731793/article/details/91471007