mirror of https://github.com/syswonder/rux-nginx
nginx-app
This commit is contained in:
parent
9a30b91f51
commit
8a7579bc85
|
@ -1 +1,4 @@
|
|||
*.o
|
||||
nginx-*
|
||||
html
|
||||
*.img
|
||||
mnt
|
||||
|
|
56
README.md
56
README.md
|
@ -1,5 +1,51 @@
|
|||
# rux-nginx
|
||||
This repo is the nginx app lib for [RuxOS](https://github.com/syswonder/ruxos) to build nginx web server
|
||||
## How to use?
|
||||
If you want to run nginx app on RuxOS, you don't need to clone this repo.
|
||||
You can clone [RuxOS](https://github.com/syswonder/ruxos) and follow the instructions on `apps/c/nginx/README.md` to run the nginx
|
||||
# How to run nginx on ruxos
|
||||
|
||||
## commands
|
||||
|
||||
### download web page
|
||||
|
||||
You should make sure there is a html folder in apps/c/nginx which contains the web page of nginx server.
|
||||
|
||||
If you not use your own web page , you can run commands below:
|
||||
|
||||
```shell
|
||||
git clone https://github.com/syswonder/syswonder-web.git
|
||||
mkdir -p apps/c/nginx/html
|
||||
cp -r syswonder-web/docs/* apps/c/nginx/html
|
||||
rm -f -r syswonder-web
|
||||
```
|
||||
|
||||
### run nginx
|
||||
|
||||
The commands below is to run nginx with different features. These examples run in aarch64 with musl, if you want to run in x86_64, just replace `ARCH=aarch64` with `ARCH=x86_64`, and if you do not want to run with musl , just delete `MUSL=y`.
|
||||
|
||||
use v9p and musl in aarch64:
|
||||
|
||||
```shell
|
||||
make A=apps/c/nginx/ LOG=info NET=y BLK=y FEATURES=virtio-9p V9P=y V9P_PATH=./apps/c/nginx/html/ ARCH=aarch64 SMP=4 MUSL=y run
|
||||
```
|
||||
|
||||
not use v9p,but use musl in aarch64:
|
||||
|
||||
```shell
|
||||
make A=apps/c/nginx/ LOG=info NET=y BLK=y ARCH=aarch64 SMP=4 MUSL=y run
|
||||
```
|
||||
|
||||
If you change running option or source code , remember to clean the compile files before running.
|
||||
|
||||
```shell
|
||||
make clean_c A=apps/c/nginx
|
||||
```
|
||||
|
||||
## ruxgo
|
||||
if you want to use ruxgo to run nginx, remember to run `apps/c/nginx/create_nginx_img.sh` first to make sure disk.img is right, or you can build your own disk.img
|
||||
|
||||
# nginx conf
|
||||
|
||||
You can change next files to change nginx conf:
|
||||
|
||||
`/nginx/conf/nginx.conf`
|
||||
|
||||
`/nginx/conf/mime.types`
|
||||
|
||||
After change you should copy them to disk.img (you can run `apps/c/nginx/create_nginx_img.sh` to do that)
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
nginx-version = 1.24.0
|
||||
nginx-src := $(APP)/nginx-$(nginx-version)
|
||||
nginx-objdir := $(APP)/objs
|
||||
nginx-objs := objs/nginx_app.o
|
||||
|
||||
app-objs := $(nginx-objs)
|
||||
|
||||
CFLAGS += -Wno-format
|
||||
|
||||
nginx-build-args := \
|
||||
CC=$(CC) \
|
||||
CFLAGS="$(CFLAGS)" \
|
||||
USE_JEMALLOC=no \
|
||||
-j
|
||||
|
||||
ifneq ($(V),)
|
||||
nginx-build-args += V=$(V)
|
||||
endif
|
||||
|
||||
ifeq ($(V9P),y)
|
||||
DISK_ARG = 9p
|
||||
else
|
||||
DISK_ARG = no_9p
|
||||
endif
|
||||
|
||||
|
||||
disk.img:
|
||||
echo "nginx makefile create_nginx_img"
|
||||
./$(APP)/create_nginx_img.sh $(DISK_ARG)
|
||||
|
||||
$(APP)/$(nginx-objs): build_nginx
|
||||
|
||||
clean_c::
|
||||
find . -type f \( -name "*.o" -o -name "*.elf" -o -name "*.bin" \) -exec rm -f {} +
|
||||
|
||||
build_nginx: disk.img $(nginx-objdir)
|
||||
cd $(nginx-objdir) && $(MAKE) $(nginx-build-args)
|
||||
|
||||
|
||||
.PHONY: build_nginx
|
|
@ -0,0 +1,40 @@
|
|||
#!/bin/bash
|
||||
|
||||
# From https://github.com/rafalh/rust-fatfs/blob/master/scripts/create-test-img.sh
|
||||
CUR_DIR=$(dirname $0)
|
||||
|
||||
echo $OUT_DIR
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
CONF="$CUR_DIR/nginx.conf"
|
||||
echo "not us 9p"
|
||||
elif [ "$1" == "9p" ]; then
|
||||
CONF="$CUR_DIR/nginx_9p.conf"
|
||||
echo "use 9p"
|
||||
else
|
||||
CONF="$CUR_DIR/nginx.conf"
|
||||
echo "not use 9p"
|
||||
fi
|
||||
|
||||
create_test_img() {
|
||||
local name=$1
|
||||
local blkcount=$2
|
||||
local fatSize=$3
|
||||
dd if=/dev/zero of="$name" bs=1024 count=$blkcount
|
||||
mkfs.vfat -s 1 -F $fatSize -n "Test!" -i 12345678 "$name"
|
||||
mkdir -p mnt
|
||||
sudo mount -o loop "$name" mnt -o rw,uid=$USER,gid=$USER
|
||||
mkdir -p "mnt/nginx/logs"
|
||||
mkdir -p "mnt/nginx/conf"
|
||||
cp "$CONF" "mnt/nginx/conf/nginx.conf"
|
||||
cp "$CUR_DIR/mime.types" "mnt/nginx/conf/mime.types"
|
||||
mkdir -p "mnt/html"
|
||||
cp -r "$CUR_DIR/html" "mnt/"
|
||||
sudo umount mnt
|
||||
}
|
||||
|
||||
create_test_img "$CUR_DIR/fat32.img" 40000 32
|
||||
echo $CUR_DIR
|
||||
echo "nginx create disk"
|
||||
rm -f disk.img
|
||||
cp $CUR_DIR/fat32.img disk.img
|
|
@ -0,0 +1,14 @@
|
|||
alloc
|
||||
paging
|
||||
fp_simd
|
||||
irq
|
||||
multitask
|
||||
fs
|
||||
blkfs
|
||||
net
|
||||
pipe
|
||||
epoll
|
||||
poll
|
||||
select
|
||||
rtc
|
||||
signal
|
|
@ -0,0 +1,98 @@
|
|||
|
||||
types {
|
||||
text/markdown md;
|
||||
text/html html htm shtml;
|
||||
text/css css;
|
||||
text/xml xml;
|
||||
image/gif gif;
|
||||
image/jpeg jpeg jpg;
|
||||
application/javascript js;
|
||||
application/atom+xml atom;
|
||||
application/rss+xml rss;
|
||||
|
||||
text/mathml mml;
|
||||
text/plain txt;
|
||||
text/vnd.sun.j2me.app-descriptor jad;
|
||||
text/vnd.wap.wml wml;
|
||||
text/x-component htc;
|
||||
|
||||
image/png png;
|
||||
image/svg+xml svg svgz;
|
||||
image/tiff tif tiff;
|
||||
image/vnd.wap.wbmp wbmp;
|
||||
image/webp webp;
|
||||
image/x-icon ico;
|
||||
image/x-jng jng;
|
||||
image/x-ms-bmp bmp;
|
||||
|
||||
font/woff woff;
|
||||
font/woff2 woff2;
|
||||
|
||||
application/java-archive jar war ear;
|
||||
application/json json;
|
||||
application/mac-binhex40 hqx;
|
||||
application/msword doc;
|
||||
application/pdf pdf;
|
||||
application/postscript ps eps ai;
|
||||
application/rtf rtf;
|
||||
application/vnd.apple.mpegurl m3u8;
|
||||
application/vnd.google-earth.kml+xml kml;
|
||||
application/vnd.google-earth.kmz kmz;
|
||||
application/vnd.ms-excel xls;
|
||||
application/vnd.ms-fontobject eot;
|
||||
application/vnd.ms-powerpoint ppt;
|
||||
application/vnd.oasis.opendocument.graphics odg;
|
||||
application/vnd.oasis.opendocument.presentation odp;
|
||||
application/vnd.oasis.opendocument.spreadsheet ods;
|
||||
application/vnd.oasis.opendocument.text odt;
|
||||
application/vnd.openxmlformats-officedocument.presentationml.presentation
|
||||
pptx;
|
||||
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
|
||||
xlsx;
|
||||
application/vnd.openxmlformats-officedocument.wordprocessingml.document
|
||||
docx;
|
||||
application/vnd.wap.wmlc wmlc;
|
||||
application/x-7z-compressed 7z;
|
||||
application/x-cocoa cco;
|
||||
application/x-java-archive-diff jardiff;
|
||||
application/x-java-jnlp-file jnlp;
|
||||
application/x-makeself run;
|
||||
application/x-perl pl pm;
|
||||
application/x-pilot prc pdb;
|
||||
application/x-rar-compressed rar;
|
||||
application/x-redhat-package-manager rpm;
|
||||
application/x-sea sea;
|
||||
application/x-shockwave-flash swf;
|
||||
application/x-stuffit sit;
|
||||
application/x-tcl tcl tk;
|
||||
application/x-x509-ca-cert der pem crt;
|
||||
application/x-xpinstall xpi;
|
||||
application/xhtml+xml xhtml;
|
||||
application/xspf+xml xspf;
|
||||
application/zip zip;
|
||||
|
||||
application/octet-stream bin exe dll;
|
||||
application/octet-stream deb;
|
||||
application/octet-stream dmg;
|
||||
application/octet-stream iso img;
|
||||
application/octet-stream msi msp msm;
|
||||
|
||||
audio/midi mid midi kar;
|
||||
audio/mpeg mp3;
|
||||
audio/ogg ogg;
|
||||
audio/x-m4a m4a;
|
||||
audio/x-realaudio ra;
|
||||
|
||||
video/3gpp 3gpp 3gp;
|
||||
video/mp2t ts;
|
||||
video/mp4 mp4;
|
||||
video/mpeg mpeg mpg;
|
||||
video/quicktime mov;
|
||||
video/webm webm;
|
||||
video/x-flv flv;
|
||||
video/x-m4v m4v;
|
||||
video/x-mng mng;
|
||||
video/x-ms-asf asx asf;
|
||||
video/x-ms-wmv wmv;
|
||||
video/x-msvideo avi;
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
worker_processes 1;
|
||||
daemon off;
|
||||
master_process off;
|
||||
|
||||
error_log logs/error.log debug;
|
||||
|
||||
events {
|
||||
worker_connections 32;
|
||||
}
|
||||
|
||||
http {
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
keepalive_timeout 65;
|
||||
|
||||
server {
|
||||
listen 5555;
|
||||
server_name localhost;
|
||||
|
||||
index index.html;
|
||||
|
||||
root /html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /404.html;
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
location = /404.html {
|
||||
root /html;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /html;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
worker_processes 1;
|
||||
daemon off;
|
||||
master_process off;
|
||||
|
||||
error_log logs/error.log debug;
|
||||
|
||||
events {
|
||||
worker_connections 32;
|
||||
}
|
||||
|
||||
http {
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
keepalive_timeout 65;
|
||||
|
||||
server {
|
||||
listen 5555;
|
||||
server_name localhost;
|
||||
|
||||
index index.html;
|
||||
|
||||
root /v9fs;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /404.html;
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
location = /404.html {
|
||||
root /v9fs;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /v9fs;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
*.o
|
|
@ -0,0 +1,5 @@
|
|||
# rux-nginx
|
||||
This repo is the nginx app lib for [RuxOS](https://github.com/syswonder/ruxos) to build nginx web server
|
||||
## How to use?
|
||||
If you want to run nginx app on RuxOS, you don't need to clone this repo.
|
||||
You can clone [RuxOS](https://github.com/syswonder/ruxos) and follow the instructions on `apps/c/nginx/README.md` to run the nginx
|
Loading…
Reference in New Issue