Linux 18.04 搭建lamp环境
Linux 18.04 下搭建lamp环境
一、 安装服务器
a) 在配置好sources.list文件后,apt-get updata&upgrade更新软件;

二、 安装apache2
a) Apt install apache2
b) systemctl status apache2 开启apache2服务 如图:

c) # 开启 、关闭和重启Apache服务器
i. systemctl start apache2 # 开启
ii. systemctl stop apache2 # 关闭
iii. systemctl restart apache2 # 重启
d)测试访问你的 Web 服务器,打开浏览器并输入Ubuntu18.04的IP地址

三、 数据库的安装:
a) 安装mysql:
i. apt install mysql-server
ii. 安装成功

iii. 登陆mysql设置:mysql -u root -p
root@ubuntu-virtual-machine:~# mysql_secure_installation
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin? # 要安装验证密码插件吗?
Press y|Y for Yes, any other key for No: N # 这里我选择N
Please set the password for root here.
New password: # 输入要为root管理员设置的数据库密码
Re-enter new password: # 再次输入密码
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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : N # 禁止root管理员从远程登录,这里我没有禁止
... skipping.
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? (Press y|Y for Yes, any other key for No) : y # 删除test数据库并取消对它的访问权限
- 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? (Press y|Y for Yes, any other key for No) : y # 刷新授权表,让初始化后的设定立即生效
Success.
All done!
iv. 配置mysql允许远程访问,首先编辑 /etc/mysql/mysql.conf.d/mysqld.cnf 配置文件:
vim /etc/mysql/mysql.conf.d/mysqld.cnf
注释掉bind-address = 127.0.0.1

v. 保存退出,然后进入mysql数据库,执行授权命令:
mysql -u root -p
mysql> grant all on *.* to root@'%' identified by '你的密码' with grant option;
mysql> flush privileges; # 刷新权限
mysql> exit
然后执行exit命令退出mysql服务,再执行如下命令重启mysql:
systemctl restart mysql

成功连接
四、 PHP的安装
a) apt install php
b) 让apache首先提供php界面
打开 /etc/apache2/mods-enabled/dir.conf 文件并将其更改为首先列出index.php

systemctl restart apache2 重启一下apache2
在/var/www/html中创建一个名为index.php的新文件。
vim /var/www/html/index.php
输入以下内容
<?php
phpinfo();
?>
保存并退出该文件
c) 测试,访问ubuntu的ip,可通过ipconfig查到,IP地址后面输入/index.html也能访问到Apache的默认信息页面

五、 Php模块安装:
a) apt install php-curl
六、 Phpmyadmin安装:
a) apt install phpmyadmin
b) 安装完成后,创建phpMyAdmin的软链接到Apache的根目录下(我的是/var/www/html/)
ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
现在开始尝试访问phpMyAdmin,打开浏览器并输入:IP地址/phpmyadmin

至此,成功在Linux 18.04中搭建lamp环境。
总结:
遇到三个问题:
第一个是在mysql授权的时候,没有敲‘;’,导致命令无效,花了不少时间找问题。
第二个是第二次访问192.168.234.130时,浏览器始终停在apache的index.html界面,并未跳转到php的界面,折腾了一会儿才发现是浏览器缓存没清理,清理后就访问成功;
第三个是#1698 - Access denied for user 'root'@'localhost'(phpmyadmin的登陆界面报错),查看mysql的user表,发现root的plugin并不是本地密码,因此需要修改它,update mysql.user set authentication_string=PASSWORD('你的密码'), plugin='mysql_native_password' where user='root';再刷新一下flush privileges;重启终端就可以登陆了。
参考资料:
https://blog.csdn.net/qq_35846773/article/details/80992155
https://www.cnblogs.com/opsprobe/p/9126411.html
https://www.cnblogs.com/opsprobe/p/9126864.html

Linux 18.04 搭建lamp环境的更多相关文章
- Ubuntu-server14.04搭建LAMP环境
转自:http://www.cnblogs.com/myzhibie/p/4330327.html 对于很多PHP初学开发者来讲,搭建一个可用于生产的LAMP环境是一件费时费力的事情,本文以 ubun ...
- Ubuntu 20.04 搭建 LAMP 环境
LAMP环境即Linux下配置Apache.Mysql.Php,话不多说 GO ! 0.下载之前先更新一波: 更新源 sudo apt-get update 更新软件 sudo apt-get upg ...
- ubuntu-kylin16.04搭建lamp环境。
首先下载安装apache2 输入:sudo apt-get install apache2 安装完毕后,在浏览器中输入:localhost 显示如下图,说明安装正确. 紧接着安装php7.0 输入:s ...
- ubuntu14.04搭建LAMP环境(nginx,php,mysql,linux)详解
最近更换开发环境至ubuntu,整理开发环境和常用软件的安装配置(更新排版) 以下安装过程经过多次操作得出,参照步骤进行操作即可 一.LAMP基本环境搭建 1 切换root账号 sudo su 2,安 ...
- Linux操作系统下搭建LAMP环境
准备:先在目录home/csy/下建website代码目录,然后新建php文件,命名为test.php. 在test.php编写代码如下: <? php phpinfo(); ?> 保存并 ...
- Ubuntu14.04搭建LAMP环境
安装Apache2 sudo apt-get install apache2 ...
- 阿里云ubantu16.04 搭建LAMP环境
1.登录服务器 2.sudo apt-get update 更新软件列表 3.sudo apt-get install lamp-server^ (注意右上角的' ^ '这个不能少) 输入apach ...
- linux下搭建lamp环境以及安装swoole扩展
linux下搭建lamp环境以及安装swoole扩展 一.CentOS 6.5使用yum快速搭建LAMP环境 准备工作:先更新一下yum源 我安装的环境是:apache2.2.15+mysql5 ...
- Ubuntu18.04下搭建LAMP环境
一.Apache2 web 服务器的安装 : 可以先更新一下服务器 1.sudo apt-get update # 获取最新资源包 2.sudo apt-get upgrade ...
随机推荐
- 「Django」Django内置email发送邮件
Django内置email发送邮件 1.首先在settings.py文件设置相关参数 STATIC_URL = '/static/' # 设置邮件域名 EMAIL_HOST = 'smtp.163.c ...
- chrome插件编写中需要了解的几个概念和一些方法
1.插件文件结构 1.1.manifest.json 每一个扩展.可安装的WebApp.皮肤,都有一个JSON格式的manifest文件,里面存放重要的插件相关信息. 一个最基本的配置例子: { &q ...
- php 中秒杀
控制器层 2 //秒杀 首先要判断库存 其次高并发 然后入库 3 public function goods_do() 4 { 5 $gid=input("get.gid"); 6 ...
- word黏贴图片显示不出来
word图片转存,是指UEditor为了解决用户从word中复制了一篇图文混排的文章粘贴到编辑器之后,word文章中的图片数据无法显示在编辑器中,也无法提交到服务器上的问题而开发的一个操作简便的图片转 ...
- 树莓派打造mini广播(FM)系统
树莓派打造mini广播(FM)系统 注意相关法律限制功率大小和频段.,以下只能用于测试目的 github项目: https://github.com/miegl/PiFmAdv 安装: apt-get ...
- JVM备忘点(1.8以前)
1.内存结构 左边两个线程共享,右边三个线程私有. 方法区:.class文件的类信息.常量.static变量.即时编译器编译后的代码(动态代理).HotSpot将方法区称为永久代 堆:分为新生代和老年 ...
- 七、find 文件查找
在文件系统上查找符合条件的文件 locate :依赖于事先构建的索引,索引的构建是在系统较为空闲时自动进行(周期性任务) 手动更新数据库(updatedb) 非实时查找 模糊查找 索引构建过程需要遍历 ...
- 软件构造实验二-拷贝一个c文件 将其中的关键字int替换成float
1,新建 Parser Generator 点击project --> new 2,填写工程名字 随意取一个名字 点击OK 3,点击Project选项下的 parserwizard 分析器向导选 ...
- 游览器中javascript的执行过程
在讲这个问题之前,先来补充几个知识点,如果对此已经比较了解可以直接跳过 大多数游览器的组件构成如图 在最底层的三个组件分别是网络,UI后端和js解释器.作用如下: (1)网络- 用来完成网络调用,例如 ...
- ubuntu dnsmasq问题
在很多ubuntu开启wifi热点的教程中,配置比较繁琐的是hostapd+dnsmasq,很多教程都给出了dnsmasq的安装过程,其实在ubuntu桌面版系统下,已经集成到NetworkManag ...