manjaro+vmware+ubuntu server+LAMP配置静态ip服务器

本文转载加工:

https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-20-04

https://www.digitalocean.com/community/tutorials/apache-configuration-error-ah00558-could-not-reliably-determine-the-server-s-fully-qualified-domain-name

https://wiki.manjaro.org/index.php/VMware

https://stackoverflow.com/questions/43094726/your-password-does-not-satisfy-the-current-policy-requirements

这些链接可能打不开,不过都是一些官方社区文档教程,基本按照他们的就不会出错,出问题也是别人遇到的,基本都可以有比较确定的方法解决,相当节约时间。所以学习这些的时候可以多翻翻官方文档之类的,别人教程其实大多是他们翻译加工的,所以加入了他们自己的理解。对于小白了说就容易出错。(他们知道怎么回事简简单单就解决了,对小白来说就很难受<*_*>)下面的文字就偷懒了。大家有兴趣可以去看原文。

 

1>环境:物理机manjaro5.9+vmware+ubuntu server(20.04/18也可以)+LA(apache)M(mysql)P(php) +wifi

2>需求:配置一台能连接外网,本地网络可以通过域名(www.your_domain.com)访问的linux服务器

第一步:manjaro上安装vmware (默认大家源,包管理都ok啦)

 pamac build vmware-workstation
 sudo modprobe -a vmw_vmci vmmon
 sudo systemctl enable --now vmware-networks.service
 sudo systemctl enable --now vmware-usbarbitrator.service
 sudo systemctl enable --now vmware-hostd.service

第二步:傻瓜化安装ubuntu server(基本不需要换源,看个人情况)配置安装ssh因为vm没法复制滚动

ubuntu 20默认没有root,需要自己添加
sudo passwd root

sudo apt-get update
sudo apt-get install openssh-server
修改配置文件(vim)也行
sudo nano /etc/ssh/sshd_config 
添加
PermitRootLogin yes
注释这一行
#PermitRootLogin prohibit-password

重启服务

sudo /etc/ini.d/ssh restart    或者sudo systemctl restart ssh sshd
开机启动   sudo systemctl enable ssh
终端连接ubuntu linux
ssh username@ip_addr
例如  ssh root@192.168.188.11
查看ip 用
ip a           
ubunt 可以用
ifconfig  


第三部,配置静态ip这个只需要设置vmnet tool 和 ubuntu server就可以了,manjaro不需要

这里需要把dhcp取消了。然后记住网关ip gateway ip(192.168.111.2)一般以2结尾,子网掩码(255.255.255.0)有24个1哦二进制  进入ubuntu 配置ip

 

在ubuntu中查看网卡
ip a  或则  ifconfig 一般有两个网卡一个ens33  一个lo(回环网卡,不用管)
然后
cd /etc/netplan
ls
00-installer-config.yaml(类似这样的。)
cp 00-installer-config.yaml 00-installer-config.yaml.backup  (保持配置文件备份的好习惯)
sudo nano 00-installer-config.yaml
编辑如下

network:
  ethernets:
    ens33:       //你用ip a 看到的网卡名
      dhcp4: no     //不自动分配ip
      dhcp6: no                                                                                              
      addresses : [192.168.111.122/24]  //最后122只要不是1 2 255就行  后面24要有哦
      gateway4: 192.168.111.2  //这个是我们开始看得哪个gateway哦
      nameservers: 
            addresses: [192.168.111.1,8.8.8.8]         //这个你前三个和gatway相同最后个为1 
  version: 2

最好复制粘贴在修改地址。缩进要一样用nano打开要ctrl+x  y  enter退出。
然后
sudo nano /etc/resolv.conf
添加
nameserver 8.8.8.8

然后ip应该就可以了,可以ping一下能不能行

ip修改了如果你就是用的dhcp分配的地址当静态ip可能你的ssh就不行了,要重新匹配密钥,看下面

https://blog.csdn.net/guhong888/article/details/82532391   感谢作者

第四步 安装 apache,mysql,php直接拷贝命令了,原文有很多知识很详细建议去看一看

sudo apt update
sudo apt install apache2
sudo ufw app list
sudo ufw allow in "Apache"
sudo ufw status
到这里就可以在manjaro浏览器上看看安好apache了没
http://your_server_ip
这个里安装中可能会出现Apache Configuration Error AH00558: Could not reliably determine the server's fully qualified domain name
H00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 Set the 'ServerName' directive globally to suppress this messag

sudo nano /etc/apache2/apache2.conf
添加     ServerName 127.0.0.1   保存退出


//sudo nano /etc/httpd/conf/httpd.conf//  这个是centos的位置ubuntu 不用管
//添加     ServerName 127.0.0.1   保存退出//

sudo apachectl configtest
sudo systemctl restart apache2.service





mysql安装
sudo apt install mysql-server
如果用来学习什么的可以不安这个安了设置密码什么的比较麻烦
//sudo mysql_secure_installation
这里选择0 最好。(如果安装了安全服务)
//Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
测试安装好没。
sudo mysql
exit退出


php
sudo apt install php libapache2-mod-php php-mysql
php -v


创建虚拟主机名方便访问,也就是可以用www访问在本地访问

your_domain  写个好记自己喜欢的。建议不要写百度。。。

sudo mkdir /var/www/your_domain
sudo chown -R $USER:$USER /var/www/your_domain

sudo nano /etc/apache2/sites-available/your_domain.conf
这一段拷贝进去修改your_domain
<VirtualHost *:80>
    ServerName your_domain   //
    ServerAlias www.your_domain   //
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/your_domain  //
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

ctrl+x  Y  enter 保存退出


sudo a2ensite your_domain
sudo a2dissite 000-default
sudo apache2ctl configtest
sudo systemctl reload apache2
nano /var/www/your_domain/index.html
编辑:
<html>
  <head>
    <title>your_domain website</title>
  </head>
  <body>
    <h1>Hello World!</h1>

    <p>This is the landing page of <strong>your_domain</strong>.</p>
  </body>
</html>

编辑:
nano /var/www/your_domain/info.php

<?php
phpinfo();
?>

退出

到这里进入物理机manjaro中修改网络映射

sudo vim /etc/hosts
然后添加

192.168.111.122 www.your_domain.com   //第一个就是ubuntu的静态ip 第二个是你自己前面写的域名

然后浏览器打开
www.your_domain.com/index.html
www.your_domain.com/info.php   //测试了记得在ubuntu中删除这个页面

到这里基本就完了。比较懒所以没怎么截图。大家可以去看下原文,讲的很详细。中间可能会有些地方步骤遗漏了,希望大家见谅,查一下。如果有问题可以留言我看下我有没有遇到。
 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值