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 ...
随机推荐
- 基于 Go 的可嵌入脚本语言 zygomys
zygomys zygomys 是一种可嵌入的脚本语言. 它是一个具有面向对象风格的现代化 Lisp,提供了一个解释器和 REPL(Read-Eval-Print-Loop:也就是说,它带有一个命令行 ...
- LOJ2265. 「CTSC2017」最长上升子序列
题意:中文题意很清楚 LOJ2263 分析: 根据Dilworth定理,最小链覆盖=最长反链. 问题转化为求 $k$ 个最小不上升序列能覆盖的最大数的个数. 参考链接: 1. https://blog ...
- [2019HDU多校第一场][HDU 6584][G. Meteor]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6584 题目大意:求所有满足\(0<\frac{p}{q}\leq1, gcd(p,q)=1,p\ ...
- C#中一些常用的方法使用
一.string.Empty string.Empty就相当于 "" ,一般用于字符串的初始化 , 比如: string a; Console.WriteLine(a);//这里会 ...
- JQuery实践--插件
jQuery插件的概览http://docs.jquery.com/Pluginshttp://jquery.com/plugins/most_popular 官方的表单插件http://jquery ...
- 015_linux驱动之_signal
1. 首先看应用程序 1. 首先分析第二点使用函数signal(SIGIO, my_signal_fun);来设置,当驱动程序传递信号给应用程序时候会调用第一点的程序 2. 第三点是设置相关参数 (二 ...
- 彻底搞懂prototype和__proto__
prototype是函数特有的属性,是Function的静态属性:__proto__是对象特有的属性. 因为函数本身是一种对象,所以函数既有prototype属性也有__proto__属性. 当函数使 ...
- Myeclipse10打开jsp页面卡死问题
在Myeclipse的选项中.General->Editor->File Associations.在上边找到*.jsp.在下边设置Myeclipse JSP Editer为默认编辑器.以 ...
- Codeforces.520B.Two Buttons(正难则反)
题目链接 \(Description\) 给定两个数\(n,m\),每次可以使\(n\)减一或使\(n\)乘2.求最少需要多少次可以使\(n\)等于\(m\). \(Solution\) 暴力连边BF ...
- Bzoj 3942: [Usaco2015 Feb]Censoring(kmp)
3942: [Usaco2015 Feb]Censoring Description Farmer John has purchased a subscription to Good Hooveske ...