[步骤] Linux 图形桌面的安装 (GNOME 版) (openSUSE & SLE 版)

步骤目录:

步骤一:系统环境要求

步骤二:显示 openSUSE & SLE 可安装的软件包组

步骤三:安装 GNOME 图形界面
3.1 安装 GNOME 图形界面
3.2 将系统默认的图形桌面设置为 GNOME 图形桌面

步骤四:进入图形界面
4.1 设置系统开机进入图形桌面
4.2 立刻进入图形桌面

具体的操作步骤:

步骤一:系统环境要求

服务器系统要配置好可用的软件源

步骤二:显示 openSUSE & SLE 可安装的软件包组

# zypper se -t pattern

步骤三:安装 GNOME 图形桌面
3.1 安装 GNOME 图形桌面

# zypper in -t pattern gnome

3.2 将系统默认的图形桌面设置为 GNOME 图形桌面

# vim /etc/sysconfig/displaymanager

将以下内容:

......
DISPLAYMANAGER_XSERVER="Xorg"

修改为:

......
DISPLAYMANAGER_XSERVER="gdm"

步骤四:进入图形桌面
4.1 设置系统开机进入图形桌面

# systemctl set-default graphical.target

4.2 立刻进入图形桌面

# startx

或者:

# init 5

[步骤] bond 网卡捆绑组的添加(CentOS Linux & RHEL 版)

步骤目录:

步骤一:显示现有的网卡有哪些

步骤二:添加网卡捆绑组
2.1 添加网卡捆绑组
2.1.1 添加网卡捆绑组的命令格式
2.1.2 添加网卡捆绑组的案例
2.2 添加网卡捆绑组的子网卡
2.2.1 添加网卡捆绑组子网卡的命令格式
2.2.2 添加网卡捆绑组子网卡的案例

步骤三:给网卡捆绑组配置 IP 地址

步骤四:启动网卡捆绑组
4.1 显示现有的网卡捆绑组和对应的子网卡有哪些
4.2 启动网卡捆绑组里的子网卡
4.2.1 启动网卡捆绑组里子网卡的命令格式
4.2.2 启动网卡捆绑组里的子网卡
4.3 启动网卡捆绑组
4.3.1 启动网卡捆绑组的命令格式
4.3.2 启动网卡捆绑组的案例

步骤五:确认网卡捆绑组的 IP 地址配置成功

步骤六:显示网卡捆绑组的成员
6.1 显示网卡捆绑组的成员命令格式
6.2 显示网卡捆绑组的成员的案例

具体的操作步骤:

步骤一:显示现有的网卡有哪些

# nmcli connection show

步骤二:添加网卡捆绑组
2.1 添加网卡捆绑组
2.1.1 添加网卡捆绑组的命令格式

# nmcli connection add type bond con-name <connection name of network card binding group> ifname <name of network card binding group> mode <network card binding group type> miimon <delay time>

2.1.2 添加网卡捆绑组的案例

# nmcli connection add type bond con-name bond0 ifname bond0 mode active-backup miimon 100

(补充:这里以创建连接名为 bond0 设备名为 bond0 延迟为 100 的网卡捆绑组为例)

2.2 添加网卡捆绑组的子网卡
2.2.1 添加网卡捆绑组子网卡的命令格式

# nmcli connection add type bond-slave con-name <network card connection name> ifname <subnet card name> master <network card binding group type>

2.2.2 添加网卡捆绑组子网卡的案例

# nmcli connection add type bond-slave con-name eth0 ifname eth0 master bond0
# nmcli connection add type bond-slave con-name eth1 ifname eth1 master bond0

(补充:这里以将连接名为 eth0 和 eth1 的网卡添加到 bond0 网卡捆绑组为例)

步骤三:给网卡捆绑组配置 IP 地址

# nmcli connection modify bond-bond0 ipv4.addresses 192.168.100.5/24 ipv4.gateway 192.168.100.1 autoconnect yes

(补充:这里给 bond-bon0 网卡捆绑组添加 192.168.100.5/24 IP 地址,192.168.100.1 网关并且自动启动为例)

步骤四:启动网卡捆绑组
4.1 显示现有的网卡捆绑组和对应的子网卡有哪些

# nmcli connection show

4.2 启动网卡捆绑组里的子网卡
4.2.1 启动网卡捆绑组里子网卡的命令格式

# nmcli connection up <subnet card name>

4.2.2 启动网卡捆绑组里的子网卡

# nmcli connection up bond-slave-em1
# nmcli connection up bond-slave-em2

(补充:这里以重启 bond-slave-em1 或者 bond-slave-em2 为例)

或者:

# nmcli connection reload

4.3 启动网卡捆绑组
4.3.1 启动网卡捆绑组的命令格式

# nmcli connection up <connection name of network card binding group>

4.3.2 启动网卡捆绑组的案例

# nmcli connection up bond-bond0

(补充:这里以启动 bond-bond0 网卡组为例)

步骤五:确认网卡捆绑组的 IP 地址配置成功

# ip address show 

(补充:如果网卡组里出现了我们配置的 IP 地址,则代表 IP 地址配置成功)

步骤六:显示网卡捆绑组的成员
6.1 显示网卡捆绑组的成员命令格式

# cat /proc/net/bonding/<bond name>

6.2 显示网卡捆绑组的成员的案例

# cat /proc/net/bonding/bond-bond0

[实验] LNMP 平台的搭建 (openSUSE Leap 15 版)

步骤目录:

步骤一:LNMP 简介

步骤二:系统环境要求

步骤三:搭建 LNMP
3.1 Nginx 网页服务
3.1.1 安装 Nginx 网页服务
3.1.2 配置 Nginx 网页服务的配置文件
3.1.2.1 删除原有的 Nginx 服务的配置文件
3.1.2.2 创建新的 Nginx 网页服务的配置文件
3.1.2.3 配置 Nginx 网页服务的配置文件
3.1.3 启动 nginx 网页服务
3.2 MariaDB 数据库
3.2.1 安装 MariaDB 数据库
3.2.2 启动 MariaDB 数据库
3.3 PHP 环境和连接服务
3.3.1 安装 PHP 环境和连接服务
3.3.2 创建提供 PHP 连接服务的用户
3.3.3 配置 PHP 连接服务的配置文件

步骤四:后续工作

步骤五:测试 LNMP 平台

具体的操作步骤:

步骤一:LNMP 简介

LNMP 是一个实现网站服务的方法,它由 4 样东西组成:
1) Linux 系统
2) Nginx 网页服务
3) MariaDB 数据库
4) PHP 网页程序

步骤二:系统环境要求

1) 服务器的系统需要是 openSUSE 15 版本
2) 服务器要关闭防火墙
3) 服务器系统要配置好可用的软件源(最好是软件数量最多的官方版本)

步骤三:搭建 LNMP
3.1 Nginx 网页服务
3.1.1 安装 Nginx 网页服务

# zypper -n install nginx

3.1.2 配置 Nginx 网页服务的配置文件
3.1.2.1 删除原有的 Nginx 服务的配置文件

# rm /etc/nginx/nginx.conf

3.1.2.2 创建新的 Nginx 网页服务的配置文件

# cp /etc/nginx/nginx.conf.default /etc/nginx.conf

3.1.2.3 配置 Nginx 网页服务的配置文件

# vi /etc/nginx/nginx.conf

将其中的:

......
        location / {
            root   html;
            index  index.html index.htm;
        }
......
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}
......

修改为:

......
        location / {
            root   html;
            index  index.php index.html index.htm;
        }
......
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
        #   fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi.conf;
        }
......

(补充:这里以让 Nginx 将对于 PHP 的请求传递到本机的 9000 端口为例)

3.1.3 启动 Nginx 网页服务

# systemctl start nginx

3.2 MariaDB 数据库
3.2.1 安装 MariaDB 数据库

# zypper -n install mariadb mariadb-server

3.2.2 启动 MariaDB 数据库

# systemctl start mariadb

3.3 PHP 环境和连接服务
3.3.1 安装 PHP 环境和连接服务

# zypper -n install php7 php7-fpm php7-mysql php7-gd php7-mbstring php7-opcache php7-json php7-xmlrpc php7-zlib

3.3.2 创建提供 PHP 连接服务的用户

# useradd php-fpm -s /sbin/nologin

3.3.3 配置 PHP 连接服务的配置文件

# vi /etc/php-fpm.conf

将以下内容:

......
user = nouser
group = nouser
......

修改为:

......
user = php-fpm
group = users
listen = 127.0.0.1:9000
......


补充:这里以
1) 以 php-fpm 用户和 users 用户组的身份启动 php-fpm
2) 让 php-fpm 监听本地 9000 端口为例

步骤四:后续工作

1) 给 MariaDB 数据库设置用于存储网页数据的用户和密码
2) 将 PHP 网页程序放到 Nginx 的网页目录下(/srv/www/htdocs)
3) 给 PHP 网页程序设置用于连接 MariaDB 数据库的用户和密码

步骤五:测试 LNMP 平台

使用浏览器访问服务器 IP 地址就可以看到对应 PHP 网页了

[步骤] Django 数据表的重建 (不影响原有的数据)

注意:

在重建 Django 数据表之前要先安装 Django 服务

正文:

(django_env) [root@python mysite]# python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying sessions.0001_initial... OK

[实验] Django 服务的搭建

纪念:站主于 2020 年 3 月完成了此开源实验,并将过程中的所有命令经过整理和注释以后,形成以下教程

注意:

文中的 python 系统名和 mysite 项目只是站主在本次操作中随意取的名称,读者可以根据自己的喜好换成任意别的名称

步骤目录:

步骤一:系统环境要求

步骤二:安装 Django
2.1 安装 Python3
2.2 创建并进入 Django 项目的目录
2.3 将 Django 项目的目录指定为 Django 环境
2.4 进入 Django 环境
2.5 检验 Django 环境是否成功

步骤三:创建 mysite 项目
3.1 创建 mysite 项目
3.2 mysite 项目的目录
3.2.1 安装 tree 目录显示软件
3.2.2 显示 mysite 项目的目录
3.3 Django 项目目录介绍

步骤四:启动 Django 服务
4.1 启动 Django 服务
4.2 测试 Django 服务

具体的操作步骤:
步骤一:系统环境要求

1) 服务器的系统需要是 CentOS Linux 7 版本
2) 服务器要关闭防火墙
3) 服务器要关闭 SELinux
4) 服务器系统要配置好可用的软件源
5) 服务器要能够连接外网

步骤二:安装 Django
2.1 安装 Python3

[root@python ~]# yum -y install python3

2.2 创建并进入 Django 项目的目录

[root@python ~]# mkdir project
[root@python ~]# cd project

2.3 将 Django 项目的目录指定为 Django 环境

[root@python project]# python3 -m venv django_env

2.4 进入 Django 环境

[root@python project]# source django_env/bin/activate
(django_env) [root@python project]# pip install django==1.11.6
Collecting django==1.11.6
  Downloading https://files.pythonhosted.org/packages/82/33/f9d2871f3aed5062661711bf91b3ebb03daa52cc0e1c37925f3e0c4508c5/Django-1.11.6-py2.py3-none-any.whl (6.9MB)
    100% |████████████████████████████████| 7.0MB 12kB/s 
Collecting pytz (from django==1.11.6)
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/pytz/
  Downloading https://files.pythonhosted.org/packages/e7/f9/f0b53f88060247251bf481fa6ea62cd0d25bf1b11a87888e53ce5b7c8ad2/pytz-2019.3-py2.py3-none-any.whl (509kB)
    100% |████████████████████████████████| 512kB 15kB/s 
Installing collected packages: pytz, django
Successfully installed django-1.11.6 pytz-2019.3
You are using pip version 9.0.3, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(django_env) [root@python project]# 


补充:
1) 这里以安装 1.11.6 版本的 django 为例
2) 如果向直接安装最新版本的 django 可以使用 pip install django 命令

2.5 检验 Django 环境是否成功

(django_env) [root@python project]# python
Python 3.6.8 (default, Aug  7 2019, 17:28:10) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.__version__
'1.11.6'
>>> exit()

步骤三:创建 mysite 项目
3.1 创建 mysite 项目

(django_env) [root@python project]# django-admin startproject mysite

3.2 mysite 项目的目录
3.2.1 安装 tree 目录显示软件

# yum -y install tree

3.2.2 显示 mysite 项目的目录

(django_env) [root@python project]# cd mysite
(django_env) [root@python mysite]# tree
.
├── manage.py
└── mysite
    ├── __init__.py
    ├── settings.py
    ├── urls.py
    └── wsgi.py

1 directory, 5 files

3.3 Django 项目目录介绍

1) mysite 此 Django 项目的容器
2) manage.py 命令行工具,与 Django 项目进行交互
3) mysite/init.py 空文件,通知 Python 此项目是一个 Python 包
4) mysite/settings.py 此 Django 项目的配置文件
5) mysite/urls.py 此 Django 项目的 URL 声明和 Django 的网站“目录”
6) mysite/wsgi.py WSGI 兼容 Web 服务器的入口

步骤四:启动 Django 服务
4.1 启动 Django 服务

(django_env) [root@python mysite]# python manage.py runserver 0.0.0.0:8000
Performing system checks...

System check identified no issues (0 silenced).
February 27, 2020 - 05:35:30
Django version 1.11.6, using settings 'mysite.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.

(补充:这里以使用 8000 端口开启网站服务为例)

4.2 测试 Django 服务

通过浏览器访问以下网址:

http://127.0.0.1:8000/admin