这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos
本次实战,所用nginx源码的版本是1.21.6,nginx-clojure源码的版本是0.5.2
整个编译和验证的过程,由以下步骤组成:
不说废话,直接开始动手
tar -zxvf jdk-8u291-linux-x64.tar.gz \
&& mkdir -p /usr/lib/jvm/ \
&& mv jdk1.8.0_291 /usr/lib/jvm/
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_291
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
[root@VM-20-17-centos ~]# java -version
java version "1.8.0_291"
Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)
yum update -y
yum install -y epel-release \
vim \
net-tools \
bridge-utils \
firewalld \
bc \
iotop \
bc \
gcc \
gcc-c++ \
glibc \
glibc-devel \
pcre \
pcre-devel \
openssl \
openssl-devel \
zip \
unzip \
zlib-devel \
lrzsz \
tree \
ntpdate \
telnet \
lsof \
tcpdump \
wget \
libevent \
libevent-devel \
systemd-devel \
bash-completion \
traceroute \
psmisc
lein是编译nginx-clojure源码时用到的工具
安装步骤如下:
curl -o /usr/bin/lein https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein \
&& chmod a+x /usr/bin/lein \
&& lein
[root@VM-20-17-centos ~]# lein -version
WARNING: You have $CLASSPATH set, probably by accident.
It is strongly recommended to unset this before proceeding.
Leiningen 2.9.8 on Java 1.8.0_291 Java HotSpot(TM) 64-Bit Server VM
cd ~ \
&& curl -O http://nginx.org/download/nginx-1.21.6.tar.gz \
&& curl -o nginx-clojure-0.5.2.zip https://codeload.github.com/nginx-clojure/nginx-clojure/zip/refs/tags/v0.5.2 \
&& tar -zxvf nginx-1.21.6.tar.gz \
&& unzip nginx-clojure-0.5.2.zip \
&& rm -f nginx-1.21.6.tar.gz nginx-clojure-0.5.2.zip
cd ~/nginx-1.21.6 \
&& ./configure \
--prefix=/usr/local/nginx \
--sbin-path=/usr/local/nginx/sbin/nginx \
--conf-path=/usr/local/nginx/conf/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx --group=nginx \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-pcre \
--add-module=/root/nginx-clojure-0.5.2/src/c \
&& make \
&& make install
groupadd nginx && useradd -d /home/nginx -g nginx -m nginx
mkdir -p /var/tmp/nginx/client
[root@VM-20-17-centos ~]# /usr/local/nginx/sbin/nginx -version
nginx version: nginx/1.21.6
cd ~/nginx-clojure-0.5.2 \
&& lein jar
mkdir /usr/local/nginx/jars \
&& mv ~/nginx-clojure-0.5.2/target/nginx-clojure-0.5.2.jar /usr/local/nginx/jars/
mkdir /usr/local/nginx/libs \
&& curl -o /usr/local/nginx/libs/clojure-1.7.0.jar https://raw.githubusercontent.com/zq2599/blog_download_files/master/files/clojure-1.7.0.jar
curl -o /usr/local/nginx/jars/simple-hello-1.0-SNAPSHOT.jar https://raw.githubusercontent.com/zq2599/blog_download_files/master/files/simple-hello-1.0-SNAPSHOT.jar
jvm_path auto;
jvm_classpath "/usr/local/nginx/libs/*:/usr/local/nginx/jars/*";
location /java {
content_handler_type 'java';
content_handler_name 'com.bolingcavalry.simplehello.HelloHandler';
}
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
jvm_path auto;
jvm_classpath "/usr/local/nginx/libs/*:/usr/local/nginx/jars/*";
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
location /java {
content_handler_type 'java';
content_handler_name 'com.bolingcavalry.simplehello.HelloHandler';
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#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;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}