如何搭建lamp,20下安装搭建LAMP环境Apache

本身在网上搜了诸多有关材料,然后自己举办了瞬间整合,把重复的清除,不另行的采取性获取过滤,整合完了将来在本地虚拟机上尝试搭建了下,很顺畅的搭建成功。

CentOS7 安装 MariaDB

CentOS7以上版本上,不再动用MySQL数据库,而是选择玛丽亚DB数据库,其中玛丽亚DB是MySQL的一个分支.现在写上个体在CentOS7里安装配置玛丽亚DB的步骤:

  1. 下载安装玛丽亚DB

**yum -y install mariadb-server mariadb

  1. 起步玛丽亚DB,并安装root用户的密码:

#启动MariaDB服务
**

[[如何搭建lamp,20下安装搭建LAMP环境Apache。email protected]
/]# systemctl start mariadb

#安装玛丽亚DB开机默许启动
[[email protected]
/]# systemctl enable mariadb

ln -s ‘/usr/lib/systemd/system/mariadb.service’
‘/etc/systemd/system/multi-user.target.wants/mariadb.service’

#测试是还是不是成功启动
[[email protected]
/]# mysql
如何搭建lamp,20下安装搭建LAMP环境Apache。Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.47-MariaDB MariaDB Server

Copyright (c) 2000, 2015, 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 |
| test |
+——————–+
4 rows in set (0.00 sec)

#退出
MariaDB [(none)]> exit
Bye

#在生育环境里安装完后,提议一定要运行三次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.

#鉴于一起初设置玛丽亚DB数据库后, root用户默许密码为空,
所以只必要按Enter键
Enter current password for root (enter for none):
OK, successfully used password, moving on…

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

#是或不是设置root用户的新密码

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.

#是或不是禁止root远程登录,按照自己的需求选用
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.

#是或不是删除test数据库
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!

#平安设置落成后,测试使用root用户登录操作
[[email protected]
/]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 5.5.47-MariaDB MariaDB Server

Copyright (c) 2000, 2015, 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.00 sec)

安装 玛丽亚DB
CentOS7之上版本上,不再利用MySQL数据库,而是选取玛丽亚DB数据库,其中玛丽亚DB是MySQL的一个分支.现在写上个体在CentOS7里设置配置…

LAMP网站服务器是Linux、
Apache、MySQL、PHP的简写。在Linux系统上安装apache服务器不是一件难事,因为大致主流的Linux发行版本软件库都席卷了要安装的软件,本文将向大家展示在Fedora
20系统上什么设置Apache2 web服务,PHP5 (mod_php)和 MySQL 数据库

LAMP是Linux+apache+MySQL+PHP的缩写。本课程演示如何设置在一台CentOS
5.6与PHP5(mod_php)和MySQL数据库加Apache2 web服务器。
1.始发证实
在本教程中选择的主机名为server1.example.com,IP地址192.168.0.100。那些设置可能与您的装置分歧,所以您必须在适合情况下更换。
2.安装MySQL 5.0
开拓终端输入:
yum install mysql mysql-server
输入以下命令,让mysql数据库伴随系统活动启动:
chkconfig --levels 235 mysqld on/etc/init.d/mysqld start
安装MySQL的root帐户密码:
mysql_secure_installation
微机终端突显,按提醒操作:

虚拟机:win10连串自带的虚拟机Hyper-v(虚拟机都大约)

或是有不得法的地点,希望我们指正!

[root@server1 ~]# mysql_secure_installation

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

In order to log into MySQL to secure it, we’ll need the current
password for the root user. If you’ve just installed MySQL, 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):
OK, successfully used password, moving on…

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

Set root password? [Y/n] <–
回车
New password: <– 你的root密码
Re-enter new password: <–
再输入四遍root密码
Password updated successfully!
Reloading privilege tables..
… Success!

By default, a MySQL installation has an anonymous user, allowing
anyone
to log into MySQL 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] <–
回车
… 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] style=”COLOR: #ff0000″><– 回车
… Success!

By default, MySQL 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] style=”COLOR: #ff0000″> <– 回车

  • 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] style=”COLOR: #ff0000″><– 回车
… Success!

Cleaning up…

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

Thanks for using MySQL!

[root@server1 ~]#

Linux系统:centos7

1 安全前提示:

本文使用的主机名为:server1.example.com ,IP地址为 192.168.0.100。这个需求依照你的主机意况作相应修改!

3.安装Apache2
CentOS已经封装了apache2,使用直接在终端输入安装:
yum install httpd
布署种类并启动apache:
chkconfig --levels 235 httpd on
启动apache:
/etc/init.d/httpd start
现行浏览器输入IP地址,看看是或不是运行:

引进先在虚拟机中测试了后头,再在服务器上搭建环境。

2 安装数据库,有五个数据库可选:MySQL/MariaDB 5

选拔下边的指令安装MySQL:

yum install mysql mysql-server

为MySQL创设启动连接 (那样 MySQL 将随系统自动启动)并启动 MySQL服务:

systemctl enable mysqld.service

留意:假设你收到那样的不当

Failed to issue method call: No such file or directory

运用下边的授命

systemctl enable mariadb.service

一发启动mysql的劳务

systemctl start mysqld.service

www.5929.com,运行

mysql_secure_installation

设置root用户密码(否则任何人都得以访问你MySQL数据库!):

[root@server1 ~]#
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): <–(直接回车)
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:
<–
(设置密码)
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] <– (直接回车)
… 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] <– (直接回车)
… 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] <– (直接回车)

  • 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] <– (直接回车)
… 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!
[root@server1 ~]#

www.5929.com 1

一、安装虚拟机

3 安装Apache2服务器

运作下边的一声令下:

yum install httpd

近日计划您的系统在开机时起步Apache…

systemctl enable httpd.service

还要启动Apache:

systemctl start httpd.service

在浏览器输入地点访问

www.5929.com 2

表达:在CentOS中Apache的默许根目录是/var/www/html,配置文件/etc/httpd/conf/httpd.conf。其余安顿存储在/etc/httpd/conf.d/目录。

二、安装CentOS7

————————————–分割线

Ubuntu 13.04 安装
LAMP\Vsftpd\Webmin\phpMyAdmin 服务及安装

http://www.linuxidc.com/Linux/2013-06/86250.htm

CentOS
5.9下编译安装LAMP(Apache 2.2.44+MySQL 5.6.10+PHP 5.4.12)
http://www.linuxidc.com/Linux/2013-03/80333p3.htm

RedHat
5.4下Web服务器架设之源码创设LAMP环境及使用PHPWind
http://www.linuxidc.com/Linux/2012-10/72484p2.htm

LAMP源码环境搭建WEB服务器Linux+Apache+MySQL+PHP
http://www.linuxidc.com/Linux/2013-05/84882.htm

LAMP+Xcache 环境搭建
http://www.linuxidc.com/Linux/2014-05/101087.htm

————————————–分割线
————————————– 

在Fedora系统中Apache默许根目录为 /var/www/html ,配置文件地方: /etc/httpd/conf/httpd.conf。其余安排文件目录
/etc/httpd/conf.d/。

越多详情见请继续阅读下一页的出色内容
http://www.linuxidc.com/Linux/2014-05/101266p2.htm

www.5929.com 3

4.安装PHP5
安装PHP5和Apache PHP5模块如下命令:
yum install php
再一次开动Apache
/etc/init.d/httpd restart
5.测试PHP5并获取有关PHP5安装细节
在web服务器创制phpinfo文档:
vi /var/www/html/info.php
增加如下代码,因为这些是函数,在wordpress里面回运行,所以你需求把双引号改为单引号:

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

《?php
phpinfo();

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

前几天在浏览器中输入

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

www.5929.com 4

四、安装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的有些信息

设若您看到如上截图,PHP5工作正常化,继续向下滚动,看看您早就启动的PHP5模块。MySQL是绝非列出,那意味大家有没有在PHP5中添加MySQL模块辅助。

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

www.5929.com 5

[root@localhost ~]#
mysql_secure_installation

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):
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]
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环境就搭建好了。

Leave a Comment.