基于国产UOS操作系统第1章-web服务器

实验-安装apache,并提供服务
在UOS-server1上
apt-get install -y apache2
echo This is a UOS web server > /var/www/html/index.html
systemctl restart apache2
systemctl enable apache2

在server2 或真机上面
访问http://192.168.200.205

实验-基于域名的web虚拟主机
mkdir /var/www/uos
mkdir /var/www/deepin
echo UOS > /var/www/uos/index.html
cd /etc/apache2/sites-enabled/
cp 000-default.conf vhosts.conf
vim vhosts.conf

ServerName www.uos.com
DocumentRoot /var/www/uos


ServerName www.deepin.com
DocumentRoot /var/www/deepin

systemctl restart apache2

客户机访问
http://www.uos.com
http://www.deepin.com

实验-基于端口的虚拟主机
mkdir /var/www/8899
echo 8899 > /var/www/8899/index.html
vim /etc/apache2/sites-enabled/vhosts.conf
Listen 8899

ServerName 192.168.200.205
DocumentRoot /var/www/8899

systemctl restart apache2

客户端访问验证
http://192.168.200.205

实验-LAMP
apt-get install -y php-fpm mariadb* libapache2-mod-php7.3
systemctl restart mariadb
systemctl restart php7.3-fpm
systemctl enable mariadb
systemctl enable php7.3-fpm
mysqladmin -uroot password ‘123456’

客户端访问测试
http://192.168.200.205/index.php

实验-alias
还原uos-server1到基于域名的虚拟主机环境
mkdir /alias
echo alias > /alias/
vim vhosts.conf

ServerName www.uos.com
DocumentRoot /var/www/uos
Alias /net /alias


AllowOverride none
Require all granted

systemctl restart apache2

客户端访问验证
http://www.uos.com/net

实验-调用脚本
vim /var/www/cgi-bin/python.py
import time

def application (environ, start_response):
response_body = ‘UNIX EPOCH time is now: %s\n’ % time.time()
status = ‘200 OK’
response_headers = [(‘Content-Type’, ‘text/plain’),
(‘Content-Length’, ‘1’),
(‘Content-Length’, str(len(response_body)))]
start_response(status, response_headers)
return [response_body]

apt-get install libapache2-mod-wsgi
vim /etc/apache2/sites-enabled/mywsgi.conf

ServerName www.uos.com
DocumentRoot /var/www/ywj
WSGIScriptAlias /python /var/www/cgi-bin

客户端访问验证
http://www.uos.com/python/python.py

实验-拒绝谋客户端访问
echo deny > /var/www/ywj/deny/index.html

vim /etc/apache2/sites-enabled/wsgi.conf

ServerName www.uos.com
DocumentRoot /var/www/ywj
#
#ScriptAlias /jiaoben /var/www/cgi-bin
#
WSGIScriptAlias /python /var/www/cgi-bin


deny from 127.0.0.1

客户端访问验证
使用本地访问,被拒绝
使用其他客户端访问,可以访问进去

实验-ssl
apt-get install -y openssl
openssl genrsa >uos.key //生成私钥
openssl req -new -x509 -key uos.key > uos.pem //生成证书
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:BJ
Locality Name (eg, city) []:BJ
Organization Name (eg, company) [Internet Widgits Pty Ltd]:TX
Organizational Unit Name (eg, section) []:PXB
Common Name (e.g. server FQDN or YOUR name) []:YWJ
Email Address []:[email protected]

cd /etc/apache2/
cp sites-available/default-ssl.conf sites-enabled/
cd sites-enabled/
vim default-ssl.conf

systemctl restart apache2

客户端访问验证
https://192.168.200.201

你可能感兴趣的:(国产操作系统UOS的前世今生,Linux入门)