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

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

此地如故要计算一下自个儿的LAMP环境的搭建步骤。
本人先在微型总括机里装了虚拟机,在虚拟机中测试了多次自此,再在服务器上搭建的。
说说自个儿的环境:
虚拟机是:VMware-workstation-full-8.0.0-471780.exe;
Linux系统用的是:CentOS-7-x86_64-Minimal-1503-01.ios;(Ali云上也是用的CentOS7-64bit)
安不忘危好这五个之后,就早先一步一步搭建大家的LAMP环境了。

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

一 、安装虚拟机

  • Dropping test database…
    … Success!
  • Removing privileges on test
    database…
    … Success!

现今,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.

在网上搜资料,自个儿在本地虚拟机上尝试搭建,弄了任何一天一夜,终于弄好了.
网上的资料,尽管很多,但基本上都是重新的,拿去试领悟后,又很多都不能够博得正确的结果.最后找到了适合作者的linux环境的搭建格局;在此间贴出来:
Install Apache, PHP And MySQL On CentOS 7
(LAMP)

度娘真不给力啊,没搜出来可靠的主意。最后用喜乐搜找到的可信的学科。

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

四、安装PHP
1.安装
yum -y install php
2.重启apache服务
systemctl restart httpd或者systemctl restart httpd.service
然后,你可以写3个php文件在浏览器中运作一下了;
eg:
vi /var/www/html/info.php
i
<?php phpinfo(); ?>
Esc
:wq
下一场,在投机电脑浏览器输入 192.168.1.1/info.php
运维,会冒出php的有的音信

Cleaning up…

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

壹 、安装虚拟机

柒 、安装常用的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,你会看出安装的模块的音信;

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

五、安装MySQL
自笔者那边根据所学的不行教程,也安装了玛丽亚DB
1.安装
yum -y install mariadb-service mariadb
2.开启MySQL服务
systemctl start mariadb.service
3.装置开机运维MySQL服务
systemctl enable mariadb.service
4.安装root帐户的密码
mysql_secure_installation
接下来会出现一串东西,能够仔细读一下,假如你懒得读,就在提醒出来的时候,按Enter就好了,让您设置密码的时候,你就输入你想要的密码就行,然后继续在让您采纳y/n是,Enter就好了;当全体截至的时候,你能够输入mysql -uroot -p的办法,验证一下;

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

六 、将PHP和MySQL关联起来
yum search php,选择你须求的安装:yum -y install php-mysql

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.

二、安装CentOS7

5.登陆数据库测试

三、安装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
(Ali云不必要用那种方法查看,外网ip已经在你主机列表那里给您写出来了的;)
此间是访问不成功的
(Ali云用外网访问,能打响,不须要做以下步骤)
查了材质,说法是,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服务了;

虚拟机:win10种类自带的虚构机Hyper-v(虚拟机都大致)

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

Thanks for using MariaDB!

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

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.

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

四、安装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的有的音讯

Reload privilege tables now? [Y/n]
y

… Success!

[root@localhost ~]#
mysql_secure_installation

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

二、安装CentOS7

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.

MariaDB [(none)]>

自己在网上搜了过多荣辱与共资料,然后本身举办了一晃结缘,把重复的清除,不另行的采取性获取过滤,整合完掌握后在地头虚拟机上尝试搭建了下,很顺畅的搭建成功。

Set root password? [Y/n]
y

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

Disallow root login remotely? [Y/n]
n

… skipping.

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

[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

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

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

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

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

迄今,LAMP环境就搭建好了。

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

Linux系统:centos7

柒 、安装常用的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,你会看出安装的模块的音信;

发表评论

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

网站地图xml地图