何以搭建lamp(CentOS7+Apache+MySQL+PHP)环境

我当网上搜了累累息息相关材料,然后自己进行了一晃组合,把更的铲除,不更的采取性获取过滤,整合了了未来在地点虚拟机上尝试扩充建筑了生,很顺畅的搭建成功。

以网上搜资料,自己在当地虚拟机上尝试搭建,弄了整一上一样夜间,终于打好了.
网上的素材,虽然多,但基本上都是再次的,拿去试了随后,又很多且非可知赢得不错的结果.最后找到了入自己的linux环境之搭建格局;在这边贴出:

虚拟机:win10类别自带的虚拟机Hyper-v(虚拟机都差不多)

度娘真不给力啊,没搜出来靠谱的措施。最后用喜乐搜找到的负谱的课程。

Linux系统:centos7

此要如总计一下自己的LAMP环境之搭建步骤。
自家先以电脑里装了虚拟机,在虚拟机中测试了数次后头,再以服务器上搭建的。
说说自家之环境:
虚拟机是:VMware® Workstation 12.1.1 Pro;
Linux系统用底是:CentOS-7-x86_64-DVD-1511.iso;(阿里云齐呢是为此底CentOS7-64bit)
备好就片独下,就起同步一步搭建我们的LAMP环境了。

推荐先以虚拟机中测试了随后,再在服务器上搭建环境。

同一、安装虚拟机

一样、安装虚拟机

二、安装CentOS7

二、安装CentOS7

注意:以下安装,我都是用的root权限。
注意:以下安装,我都是用的root权限。

三、安装Apache
1.安装
yum -y install httpd
2.开启apache服务
systemctl start httpd.service
3.设置apache服务开机启动
systemctl enable httpd.service
4.验证apache劳务是否安装成功
于本机浏览器被输入虚拟机的ip地址,CentOS7翻看看ip地址之点子啊:
ip addr
(阿里云不欲因而这种办法查看,外网ip已经以您主机列表这里给你写出来了的;)
此处是造访不成事之
(阿里云用外网访问,能打响,不需开以下步骤)
翻开了材料,说法是,CentOS7之所以的凡Firewall-cmd,CentOS7的前用的凡iptables防火墙;要想叫外网能顾到apache主目录,就需举办以下的操作:
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
接下来又拜外网ip,假设看到apache默认的页面–有Testing
123…字样,便是成安装了apache服务了;

三、安装Apache
1.安装
yum -y install httpd
2.开启apache服务
systemctl start httpd.service
3.装apache服务开机启动
systemctl enable httpd.service
4.验证apache劳动是否安装成功
以本机浏览器中输入虚拟机的ip地址,假设见到apache默认的页面–有Testing
123…字样,便是成功安装了apache服务了。

四、安装PHP
1.安装
yum -y install php
2.重启apache服务
systemctl restart httpd或者systemctl restart httpd.service
接下来,你可形容一个php文件于浏览器中运行一下了;
eg:
vi /var/www/html/info.php
i
<?php phpinfo(); ?>
Esc
:wq
下一场,在协调电脑浏览器输入 192.168.1.1/info.php
运转,会现出php的局部音信

CentOS7翻看看ip地址之办法吗:
ip addr
看该是败的,原因如下:
翻开了素材,说法是,CentOS7由此的凡Firewall-cmd,CentOS7往日用的是iptables防火墙;要牵挂让外网能顾到apache主目录,就用举办以下的操作:
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
下一场再拜访外网ip,就足以了。

五、安装MySQL
自身这里因所模拟的好教程,也安装了Maria(Maria)DB
1.安装

四、安装PHP
1.安装
yum -y install php
2.重启apache服务
systemctl restart httpd或者systemctl restart httpd.service
下一场,你可以描绘一个php文件于浏览器中运作一下了;
eg:
vi /var/www/html/info.php
i
<?php phpinfo(); ?>
Esc
:wq
下一场,在自己电脑浏览器输入 10.17.1.223/info.php
运行,会师世php的部分音

yum -y install mariadb*

五、安装MySQL
安装MariaDB
1.安装
yum install mariadb mariadb-server mariadb-libs mariadb-devel
2.开启MySQL服务
systemctl start mariadb.service
3.安装开机启动MySQL服务
systemctl enable mariadb.service
4.数据库安全设置

2.开启MySQL服务
systemctl start mariadb.service
3.安开机启动MySQL服务
systemctl enable mariadb.service
4.装root帐户的密码
mysql_secure_installation
然后会出现同等弄错东西,可以仔细读一下,如若您懒得读,就当指示下的时,按Enter就哼了,让您设置密码的下,你尽管输入而想要之密码便举行,然后继续当吃你选用y/n是,Enter就吓了;当所有了的早晚,你可以输入mysql -uroot -p的法门,验证一下;

[root@localhost ~]#
mysql_secure_installation

六、将PHP和MySQL关联起来
yum search php,采纳而待之装:yum -y install php-mysql

NOTE: RUNNING ALL PARTS OF THIS SCRIPT
IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ
EACH STEP CAREFULLY!

七、安装常用之PHP模块
例如,GD库,curl,mbstring,…
1.安装:
yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel

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.

2.重启apache服务
systemctl restart httpd.service
下一场,再一次以浏览器中运作info.php,你相会到安装的模块的音讯;

Enter current password for root (enter
for none):
OK, successfully used password, moving
on…

至今,LAMP环境就大增建筑好了。

Setting the root password ensures that
nobody can log into the MariaDB
root user without the proper
authorisation.

 

Set root password? [Y/n]
y

New password:
Re-enter new password:
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]
y

… 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]
n

… skipping.

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] y

  • 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]
y

… 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!

5.登陆数据库测试

[root@localhost ~]# mysql -uroot
-p
Enter password:
Welcome to the MariaDB monitor. Commands
end with ; or \g.
Your MariaDB connection id is
11
Server version: 5.5.52-MariaDB MariaDB
Server

Copyright (c) 2000, 2016, Oracle,
MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type
‘\c’ to clear the current input statement.

MariaDB [(none)]> show
databases;
+——————–+
| Database |
+——————–+
| information_schema |
| mysql |
| performance_schema |
+——————–+
3 rows in set (0.02 sec)

MariaDB [(none)]>

六、将PHP和MySQL关联起来
``yum -y install php-mysql

七、安装常用的PHP模块
例如,GD库,curl,mbstring,…
1.安装:
yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
2.重启apache服务
systemctl restart httpd.service
下一场,再一次当浏览器中运作info.php,你汇合视安装的模块的音讯;

由来,LAMP环境就是增建筑好了。

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图