下载并配置基础rootfs镜像文件

一下所有的操作均需要再root用户下进行

1
wget http://cdimage.ubuntu.com/ubuntu-base/releases/16.04/release/ubuntu-base-16.04-core-arm64.tar.gz

解压

1
2
mkdir ubuntu
sudo tar -xpf ubuntu-base-16.04-core-armhf.tar.gz -C ubuntu

进入容器修改密码

1
2
systemd-nspawn -D ubuntu
passwd

使用boot模式进入容器

1
systemd-nspawn -D ubuntu -b

更新国内源

vim /etc/apt/source.list

1
2
3
4
5
6
7
8
9
10
11
12
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb [arch=ppc64el,arm64,i386] http://mirrors.neusoft.edu.cn/mariadb/repo/10.3/ubuntu xenial main
# deb-src [arch=ppc64el,arm64,i386] http://mirrors.neusoft.edu.cn/mariadb/repo/10.3/ubuntu xenial main

安装mariadb

apt-get update
apt-get install vim openssh-server python-pip mariadb-server libmysqlclient-dev
配置ssh vim /etc/ssh/sshd_config

1
2
3
4
……
Port 2222
PermitRootLogin yes
……

参考资料

安装ipmitool及一些依赖

apt install ipmitool kmod python-ldap

编译安装httpd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
./configure --prefix=/usr/local/apr

make & make install

cd ../apr-util-1.6.1

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config

make & make install

cd ../pcre-8.43

./configure --prefix=/usr/local/pcre

apt-get install automake libtool libssl-dev bison flex

make & make install

cd ../httpd-2.4.39

./configure --prefix=/usr/local/httpd \
--enable-so \
--enable-ssl \
--enable-cgi \
--enable-rewrite \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util/ \
--with-zlib \
--with-pcre=/usr/local/pcre \
--enable-modules=most \
--enable-mpms-shared=all \
--with-mpm=prefork

make & make install

打开rewrite
vim /usr/local/httpd/conf/httpd.conf +161

1
LoadModule rewrite_module modules/mod_rewrite.so

编写服务文件:vim /lib/systemd/system/httpd.service

1
2
3
4
5
6
7
8
9
10
11
[Unit]
Description=The httpd service
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/httpd/bin/apachectl start
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/usr/local/httpd/bin/apachectl stop
Restart=/usr/local/httpd/bin/apachectl restart
[Install]
WantedBy=multi-user.target

启动服务:

1
2
systemctl enable httpd
systemctl start httpd

安装redis

1
apt install redis-server

安装php

1
apt install php7.0 php7.0-cli php7.0-gd php7.0-gd php7.0-json php7.0-mysql php7.0-mbstring php7.0-opcache php7.0-fpm

php-fpm方式启动laravel需要注意:

配置httpd支持php-fpm

1
vim /usr/local/httpd/conf/httpd.conf

取消下面两行的注释

1
2
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

打包的vhost.conf中需要增加Ifmodule的代码段,完整的vhost.conf如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<VirtualHost *:80>
<IfModule mod_proxy.c>
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/xdfs-webng/public/$1
DirectoryIndex /index.php index.php
</IfModule>
DocumentRoot /var/www/html/xdfs-webng/public
<Directory /var/www/html/xdfs-webng/public>
Options FollowSymLinks
AllowOverride All
Require all granted
DirectoryIndex index.php
</Directory>
<Directory /var/www/html/xdfs-webng>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

配置方法参考:ubuntu16.04下apache,php-fpm配置

配置httpd支持django:

使用CMMI方法直接安装mod_wsgi到httpd:
下载mod_wsgi
然后cd到解压之后的目录,执行如下命令,产生配置编译配置文件;

1
./configure --with-apxs=/usr/local/httpd/bin/apxs --with-python=/usr/bin/python

其中/usr/local/httpd为httpd的安装目录,确保apxs存在于bin目录中,/usr/bin/python为Ubuntu中python默认安装位置。

接下来执行make 命令,进行编译;

1
make

最后执行如下命令,进行安装;

1
make install

照着提示输入命令即可:

1
chmod 755 /usr/local/httpd/modules/mod_wsgi.so

在httpd.conf中增加mod_wsgi模块

1
LoadModule wsgi_module modules/mod_wsgi.so

参考文档

安装django相关包

requirements.txt

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
amqp==2.5.0
anyjson==0.3.3
billiard==3.6.0.0
celery==4.3.0
Django==1.11.1
django-celery-beat==1.0.1
django-cors-headers==2.0.2
django-filter==1.0.4
django-unixdatetimefield==0.1.6
djangorestframework==3.6.3
kombu==4.6.3
mailer==0.7
Markdown==2.6.8
MySQL-python==1.2.5
pika==0.10.0
pip==8.1.1
Pygments==2.2.0
pyparsing==2.0.3
python-memcached==1.53
pytz==2019.2
PyYAML==3.11
redis==3.3.7
setuptools==20.7.0
six==1.10.0
SQLAlchemy==1.3.7
vine==1.3.0
wheel==0.29.0

系统清理

1
2
3
apt-get autoclean                清理旧版本的软件缓存
apt-get clean 清理所有软件缓存
apt-get autoremove 删除系统不再使用的孤立软件