菜单

什么样搭建lamp(CentOS7+Apache+MySQL+PHP)环境

2018年12月17日 - Php

Normally, root should only be allowed to
connect from ‘localhost’. This
ensures that someone cannot guess at the
root password from the network.

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

Remove anonymous users? [Y/n]
y

… Success!

六、将PHP和MySQL关联起来
yum search php,选择而需要之装置:yum -y install php-mysql

Thanks for using MariaDB!

迄今停止,LAMP环境就加建筑好了。

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.

度娘真不给力啊,没搜下靠谱的章程。最终所以喜乐搜找到的依赖谱的课程。

七、安装常用的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,你谋面视安装的模块的信;

一样、安装虚拟机

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

三、安装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服务了;

Disallow root login remotely? [Y/n]
n

… skipping.

yum -y install mariadb*

Remove test database and access to it?
[Y/n] y

此处仍然要总结一下自身之LAMP环境的搭建步骤。
自身事先在微机里装了虚拟机,在虚拟机中测试了数次过后,再在服务器上搭建之。
说说我的环境:
虚拟机是:VMware® Workstation 12.1.1 Pro;
Linux系统用的是:CentOS-7-x86_64-DVD-1511.iso;(阿里云及也是因而的CentOS7-64bit)
备好就半个下,就起初同步一步搭建大家的LAMP环境了。

同、安装虚拟机

七、安装常用之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

MariaDB [(none)]>

2.重启apache服务
systemctl restart httpd.service
下一场,再一次于浏览器被运行info.php,你会面看安装之模块的音;

5.登陆数据库测试

五、安装MySQL
自家此依据所学的良教程,也装了玛丽亚(Maria)DB
1.安装

[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

 

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

每当网上搜资料,自己当本土虚拟机上尝试搭建,弄了通一龙一样夜,终于将好了.
网上的素材,即使多,但大多依然重新的,拿去碰了后来,又过剩且无可知得不错的结果.末了找到了副自身的linux环境的搭建情势;在此贴出来:

五、安装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.数据库安全设置

二、安装CentOS7

自以网上搜了多系资料,然后自己开展了一下重组,把还的免,不还的采用性获取过滤,整合了了之后于当地虚拟机上尝试多建筑了产,很顺畅的搭建成功。

2.开启MySQL服务
systemctl start mariadb.service
3.装置开机启动MySQL服务
systemctl enable mariadb.service
4.设置root帐户的密码
mysql_secure_installation
接下来会产出一样错东西,可以仔细读一下,假设您懒得读,就在升迁下的当儿,按Enter就好了,让您设置密码的时,你即使输入你想只要之密码便推行,然后继续在吃你拣y/n是,Enter就哼了;当尽了的时候,你得输入mysql -uroot -p的艺术,验证一下;

Linux系统:centos7

四、安装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的一部分消息

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

四、安装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的片段音信

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,就足以了。

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

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

三、安装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服务了。

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

Cleaning up…

All done! If you’ve completed all of the
above steps, your MariaDB
installation should now be
secure.

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.

时至前些天,LAMP环境就加建筑好了。

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.

Reloading the privilege tables will
ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n]
y

… Success!

Set root password? [Y/n]
y

New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
… Success!

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

二、安装CentOS7

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

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

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

[root@localhost ~]#
mysql_secure_installation

相关文章

发表评论

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

网站地图xml地图