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环境的更多相关文章

  1. Ubuntu-server14.04搭建LAMP环境

    转自:http://www.cnblogs.com/myzhibie/p/4330327.html 对于很多PHP初学开发者来讲,搭建一个可用于生产的LAMP环境是一件费时费力的事情,本文以 ubun ...

  2. Ubuntu 20.04 搭建 LAMP 环境

    LAMP环境即Linux下配置Apache.Mysql.Php,话不多说 GO ! 0.下载之前先更新一波: 更新源 sudo apt-get update 更新软件 sudo apt-get upg ...

  3. ubuntu-kylin16.04搭建lamp环境。

    首先下载安装apache2 输入:sudo apt-get install apache2 安装完毕后,在浏览器中输入:localhost 显示如下图,说明安装正确. 紧接着安装php7.0 输入:s ...

  4. ubuntu14.04搭建LAMP环境(nginx,php,mysql,linux)详解

    最近更换开发环境至ubuntu,整理开发环境和常用软件的安装配置(更新排版) 以下安装过程经过多次操作得出,参照步骤进行操作即可 一.LAMP基本环境搭建 1 切换root账号 sudo su 2,安 ...

  5. Linux操作系统下搭建LAMP环境

    准备:先在目录home/csy/下建website代码目录,然后新建php文件,命名为test.php. 在test.php编写代码如下: <? php phpinfo(); ?> 保存并 ...

  6. Ubuntu14.04搭建LAMP环境

    安装Apache2                                                             sudo apt-get install apache2   ...

  7. 阿里云ubantu16.04 搭建LAMP环境

    1.登录服务器 2.sudo apt-get update 更新软件列表 3.sudo apt-get install lamp-server^  (注意右上角的' ^ '这个不能少) 输入apach ...

  8. linux下搭建lamp环境以及安装swoole扩展

    linux下搭建lamp环境以及安装swoole扩展   一.CentOS 6.5使用yum快速搭建LAMP环境 准备工作:先更新一下yum源  我安装的环境是:apache2.2.15+mysql5 ...

  9. Ubuntu18.04下搭建LAMP环境

    一.Apache2 web 服务器的安装 : 可以先更新一下服务器 1.sudo apt-get update             # 获取最新资源包 2.sudo apt-get upgrade ...

随机推荐

  1. vscode python文件注释乱码怎么办?

    VS Code 中文注释显示乱码 解决方法 将设置中的"files.autoGuessEncoding"项的值改为true即可. 1.文件 2.首选项 3.设置 4.搜索 &quo ...

  2. Java8-ConcurrentUtils

    import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; public class Conc ...

  3. BZOJ 4013/Luogu P3240 [HNOI2015] 实验比较 (树形DP)

    题目传送门 分析 放一个dalao博客: xyz32768 的博客,看完再回来看本蒟蒻的口胡吧(其实嘛-不回来也行) 精髓是合并的方案数的计算,至于为什么是Ci−1j−1\large C_{i-1}^ ...

  4. 4、Spring Boot 2.x 自动配置原理

    1.4 Spring Boot 自动配置原理 简介 spring boot自动配置功能可以根据不同情况来决定spring配置应该用哪个,不应该用哪个,举个例子: Spring的JdbcTemplate ...

  5. KETTLE 更新表的两种方式-更新控件和sql更新 2种方式的实现比较

    在实际工作中,我们有可能遇见只更新不插入的情况,可以由以下2种方式去实现: 1.更新控件 如下图所示,根据id字段,更新name和cjsj时间字段 该控件不足的地方是,用来查询关键值得字段不够灵活,一 ...

  6. MySQL GROUP BY 语句

    GROUP BY 语句根据一个或多个列对结果集进行分组. 在分组的列上我们可以使用 COUNT, SUM, AVG,等函数. GROUP BY 语法 SELECT column_name, funct ...

  7. Flutter 初始化数据完成后再加载页面

    一.初始化数据完成后再加载数据 1.为了达成这个目标尝试了多种方法总是失败 在Init 和didChangeDependencies 初始化数据过也不行 @override void didChang ...

  8. 安裝PHPBB

    1.下載PHPBB https://www.phpbb.com/downloads/ 2下載PHP http://windows.php.net/download/ 很多教程都介紹在WIN7用ISAP ...

  9. DE2-115 以太网通信之一88E1111网卡接收PC数据

    想利用手头上的DE2-115 写一个关于以太网通信的驱动,经过了这么多天的实验调试终于有了一些认识. 1.我在观察网卡发送数据与接收数据的过程中发现,我从fpga上的一个网卡发送数据,然后另一个网卡接 ...

  10. Ubuntu14.04 打开关闭图形桌面

    使用 Ctrl+Alt+t 打开命令行界面 #关闭桌面 sudo service lightdm stop #恢复桌面 sudo service lightdm start Ctrl+Alt+F1 可 ...