linux环境下配置apache ,mysql,php,超简单

#以下需要root权限   
#安装配置之前先设置一下防火墙                                 
# ufw是Ubuntu系列发行版自带的类似iptables的防火墙管理软件
# 命令ufw app list列出当前已经集成的应用名称
$: ufw app list
可用应用程序:
  CUPS
  OpenSSH
 #查看防火墙状态及规则列表
$: ufw status
状态:不活动
#让防火墙允许Openssh,可以远程链接
$: ufw  allow Openssh
防火墙规则已更新
规则已更新(v6) 
#启用ufw
$:  ufw enable
在系统启动时启用和激活防火墙
$: ufw status
状态: 激活
至                          动作          来自
-                          --          --
OpenSSH                    ALLOW       Anywhere                  
OpenSSH (v6)               ALLOW       Anywhere (v6)    
#接下来安装apache,一路yes
$: apt install apache2
然后让防火墙允许apache的进入
$: ufw allow in "Apache Full"
安装好之后在浏览器中输入本机的IP,回车
#出现以下画面就表示apache安装完毕

在这里插入图片描述

#如果没有出现以上画面,重启以下apache服务器即可
$: systemctl restart apache2
#以上画面显示的文件内容在 /var/www/html/index.html(学过php的应该很熟悉这个路径)
#接下来安装 mysql-server
$: apt install mysql-server
#基本上一路yes
#有两个地方,第一在你设置数据库密码之前会有一个验证你输入的密码的复杂度,可以选择验证,也可以输入no
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
#在一个就是是否禁止远程连接(安全性考虑),这里因为之后要用到远程连接,我选择的是no
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
# 然后一路yes就可以搞定了,
$: mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.30-0ubuntu0.18.04.1 (Ubuntu)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
#再接着就是安装php
$: apt install php libapache2-mod-php php-mysql
#一路yes,就搞定了。。。。
#等等还有一点,
#就是再浏览器只输入本机的ip的情况下,页面默认打开的是/var/www/html/index.html,既然我们是学习的php,
#那我们不妨设置一下默认打开的是index.php吧。
#很简单
#只需找到/etc/apache2/mods-enabled/dir.conf 配置文件,用vim打开
<IfModule mod_dir.c>
        DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
#可以看出index.html 排在了index.php的前面。我们只需把index.php跳到index.html之前保存退出就可以了。
#别忘了,改完配置之后记得重启一下apache2
$: systemctl restart apache2
#linux下的apache,mysql,php就都配置好了,开始你的学习之路吧...................................
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值