Last active
December 29, 2015 15:19
-
-
Save tkuchiki/7689614 to your computer and use it in GitHub Desktop.
nginx rpmbuild(built in lua-module, perl-module)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Error</title> | |
<style> | |
body { | |
width: 35em; | |
margin: 0 auto; | |
font-family: Tahoma, Verdana, Arial, sans-serif; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>An error occurred.</h1> | |
<p>Sorry, the page you are looking for is currently unavailable.<br/> | |
Please try again later.</p> | |
<p>If you are the system administrator of this resource then you should check | |
the <a href="http://nginx.org/r/error_log">error log</a> for details.</p> | |
<p><em>Faithfully yours, nginx.</em></p> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name localhost; | |
#charset koi8-r; | |
#access_log /var/log/nginx/log/host.access.log main; | |
location / { | |
root /usr/share/nginx/html; | |
index index.html index.htm; | |
} | |
#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 /usr/share/nginx/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; | |
#} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VERSION=1.4.4 | |
NGX_DIR="nginx-$VERSION" | |
NGX_SRC="$NGX_DIR.tar.gz" | |
RPM_BUILD_DIR=$HOME/rpmbuild | |
RPM_BUILD_SOURCES=$RPM_BUILD_DIR/SOURCES | |
RPM_BUILD_SPECS=$RPM_BUILD_DIR/SPECS | |
NGX_SPEC=$RPM_BUILD_DIR/SPECS/nginx.spec | |
NGX_LOGROTATE=$RPM_BUILD_SOURCES/nginx.logrotate | |
NGX_INIT=$RPM_BUILD_SOURCES/nginx.init | |
LUAJIT_LIB=/usr/lib | |
curl "http://nginx.org/download/$NGX_SRC" -o $RPM_BUILD_SOURCES/$NGX_SRC | |
# require epel | |
yum install -y pcre pcre-devel | |
yum install -y openssl openssl-devel zlib zlib-devel readline readline-devel libxml2 libxml2-devel libxslt-devel perl perl-devel perl-ExtUtils-Embed GeoIP-devel gd-devel | |
cd $RPM_BUILD_SPECS | |
curl -O https://gist.github.com/tkuchiki/7689614/raw/41a6a302ea986c66b509359cc886071a81e1dcb5/nginx.spec | |
sed -i -e "s/__VERSION__/$VERSION/" $NGX_SPEC | |
sed -i -e "s|__LUAJIT_LIB__|$LUAJIT_LIB|" $NGX_SPEC | |
cd $RPM_BUILD_SOURCES | |
#git clone https://github.com/simpl/ngx_devel_kit.git | |
git clone https://github.com/chaoslawful/lua-nginx-module.git | |
curl -O https://gist.github.com/tkuchiki/7689614/raw/77dc0b6ca837cbac7fa07c615ac1ea8fea29050d/index.html | |
curl -O https://gist.github.com/tkuchiki/7689614/raw/6246855b65b002aabebee32e517063bdf5677161/50x.html | |
curl -O https://gist.github.com/tkuchiki/7689614/raw/72717613031839d27102bd7ef1f9d0d4473593b4/nginx.conf | |
curl -O https://gist.github.com/tkuchiki/7689614/raw/9e1eab08555e8529a9c0f69cf27507923dfa709c/default.conf | |
curl -O https://gist.github.com/tkuchiki/7689614/raw/065c655ae90f45c05b3b681da7f049ead5a77fad/nginx.init | |
curl -O https://gist.github.com/tkuchiki/7689614/raw/ae0de888b9e65d390ae00143fc37af19004caec0/nginx.logrotate | |
curl -O https://gist.github.com/tkuchiki/7689614/raw/192349dc56043d9a58e49cc14e20479800ca0151/nginx.sysconfig | |
curl -O https://gist.github.com/tkuchiki/7689614/raw/06d8f07a409183d8a47a7b2d4ded6a3e09a9b908/ssl.conf | |
QA_RPATHS=$[ 0x0001 ] rpmbuild -ba $NGX_SPEC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Welcome to nginx!</title> | |
<style> | |
body { | |
width: 35em; | |
margin: 0 auto; | |
font-family: Tahoma, Verdana, Arial, sans-serif; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Welcome to nginx!</h1> | |
<p>If you see this page, the nginx web server is successfully installed and | |
working. Further configuration is required.</p> | |
<p>For online documentation and support please refer to | |
<a href="http://nginx.org/">nginx.org</a>.<br/> | |
Commercial support is available at | |
<a href="http://nginx.com/">nginx.com</a>.</p> | |
<p><em>Thank you for using nginx.</em></p> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user nginx; | |
worker_processes 1; | |
error_log /var/log/nginx/error.log warn; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include /etc/nginx/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 /var/log/nginx/access.log main; | |
sendfile on; | |
#tcp_nopush on; | |
keepalive_timeout 65; | |
#gzip on; | |
include /etc/nginx/conf.d/*.conf; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# nginx Startup script for nginx | |
# | |
# chkconfig: - 85 15 | |
# processname: nginx | |
# config: /etc/nginx/nginx.conf | |
# config: /etc/sysconfig/nginx | |
# pidfile: /var/run/nginx.pid | |
# description: nginx is an HTTP and reverse proxy server | |
# | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $local_fs $remote_fs $network | |
# Required-Stop: $local_fs $remote_fs $network | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: start and stop nginx | |
### END INIT INFO | |
# Source function library. | |
. /etc/rc.d/init.d/functions | |
if [ -f /etc/sysconfig/nginx ]; then | |
. /etc/sysconfig/nginx | |
fi | |
prog=nginx | |
nginx=${NGINX-/usr/sbin/nginx} | |
conffile=${CONFFILE-/etc/nginx/nginx.conf} | |
lockfile=${LOCKFILE-/var/lock/subsys/nginx} | |
pidfile=${PIDFILE-/var/run/nginx.pid} | |
SLEEPMSEC=100000 | |
RETVAL=0 | |
start() { | |
echo -n $"Starting $prog: " | |
daemon --pidfile=${pidfile} ${nginx} -c ${conffile} | |
RETVAL=$? | |
echo | |
[ $RETVAL = 0 ] && touch ${lockfile} | |
return $RETVAL | |
} | |
stop() { | |
echo -n $"Stopping $prog: " | |
killproc -p ${pidfile} ${prog} | |
RETVAL=$? | |
echo | |
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} | |
} | |
reload() { | |
echo -n $"Reloading $prog: " | |
killproc -p ${pidfile} ${prog} -HUP | |
RETVAL=$? | |
echo | |
} | |
upgrade() { | |
oldbinpidfile=${pidfile}.oldbin | |
configtest -q || return 6 | |
echo -n $"Staring new master $prog: " | |
killproc -p ${pidfile} ${prog} -USR2 | |
RETVAL=$? | |
echo | |
/bin/usleep $SLEEPMSEC | |
if [ -f ${oldbinpidfile} -a -f ${pidfile} ]; then | |
echo -n $"Graceful shutdown of old $prog: " | |
killproc -p ${oldbinpidfile} ${prog} -QUIT | |
RETVAL=$? | |
echo | |
else | |
echo $"Upgrade failed!" | |
return 1 | |
fi | |
} | |
configtest() { | |
if [ "$#" -ne 0 ] ; then | |
case "$1" in | |
-q) | |
FLAG=$1 | |
;; | |
*) | |
;; | |
esac | |
shift | |
fi | |
${nginx} -t -c ${conffile} $FLAG | |
RETVAL=$? | |
return $RETVAL | |
} | |
rh_status() { | |
status -p ${pidfile} ${nginx} | |
} | |
# See how we were called. | |
case "$1" in | |
start) | |
rh_status >/dev/null 2>&1 && exit 0 | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
rh_status | |
RETVAL=$? | |
;; | |
restart) | |
configtest -q || exit $RETVAL | |
stop | |
start | |
;; | |
upgrade) | |
upgrade | |
;; | |
condrestart|try-restart) | |
if rh_status >/dev/null 2>&1; then | |
stop | |
start | |
fi | |
;; | |
force-reload|reload) | |
reload | |
;; | |
configtest) | |
configtest | |
;; | |
*) | |
echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|upgrade|reload|status|help|configtest}" | |
RETVAL=2 | |
esac | |
exit $RETVAL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/var/log/nginx/*.log { | |
daily | |
missingok | |
rotate 52 | |
compress | |
delaycompress | |
notifempty | |
create 640 nginx adm | |
sharedscripts | |
postrotate | |
[ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid` | |
endscript | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%global nginx_user nginx | |
%global nginx_group %{nginx_user} | |
%global nginx_home %{_localstatedir}/lib/nginx | |
%global nginx_tmp %{_localstatedir}/tmp/nginx | |
%global nginx_logdir %{_localstatedir}/log/nginx | |
%global nginx_cache %{_localstatedir}/cache/nginx | |
%global nginx_confdir %{_sysconfdir}/nginx | |
%global nginx_datadir %{_datadir}/nginx | |
%global nginx_module %{nginx_datadir}/modules | |
%global nginx_webroot %{nginx_datadir}/html | |
%global luajit_lib __LUAJIT_LIB__ | |
Name: nginx | |
Version: __VERSION__ | |
Release: 5%{?dist} | |
Summary: A high performance web server and reverse proxy server | |
Group: System Environment/Daemons | |
# BSD License (two clause) | |
# http://www.freebsd.org/copyright/freebsd-license.html | |
License: BSD | |
URL: http://nginx.org/ | |
Source0: http://nginx.org/download/nginx-%{version}.tar.gz | |
Source1: nginx.init | |
Source2: nginx.logrotate | |
Source3: nginx.conf | |
Source4: default.conf | |
Source5: ssl.conf | |
Source6: nginx.sysconfig | |
Source100: index.html | |
Source101: 50x.html | |
BuildRequires: GeoIP-devel | |
BuildRequires: gd-devel | |
BuildRequires: libxslt-devel | |
BuildRequires: openssl-devel | |
BuildRequires: pcre-devel | |
BuildRequires: perl-devel | |
BuildRequires: perl(ExtUtils::Embed) | |
BuildRequires: perl(Test::Nginx) | |
BuildRequires: zlib-devel | |
BuildRequires: LuaJIT >= 2.0.0 | |
Requires: GeoIP | |
Requires: gd | |
Requires: openssl | |
Requires: pcre | |
Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) | |
Requires(pre): shadow-utils | |
Requires(post): chkconfig | |
Requires(preun): chkconfig, initscripts | |
Requires(postun): initscripts | |
Provides: webserver | |
%undefine __check_files %{nil} | |
%description | |
Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and | |
IMAP protocols, with a strong focus on high concurrency, performance and low | |
memory usage. | |
%prep | |
%setup -q | |
mkdir -p %{nginx_module} | |
cp -a %{_sourcedir}/lua-nginx-module %{nginx_module} | |
%build | |
# nginx does not utilize a standard configure script. It has its own | |
# and the standard configure options cause the nginx configure script | |
# to error out. This is is also the reason for the DESTDIR environment | |
# variable. | |
export DESTDIR=%{buildroot} | |
./configure \ | |
--prefix=%{nginx_confdir} \ | |
--sbin-path=%{_sbindir}/nginx \ | |
--conf-path=%{nginx_confdir}/nginx.conf \ | |
--http-log-path=%{nginx_logdir}/access.log \ | |
--error-log-path=%{nginx_logdir}/error.log \ | |
--pid-path=%{_localstatedir}/run/nginx.pid \ | |
--lock-path=%{_localstatedir}/lock/subsys/nginx \ | |
--http-client-body-temp-path=%{nginx_tmp}/client_body \ | |
--http-proxy-temp-path=%{nginx_tmp}/proxy \ | |
--http-fastcgi-temp-path=%{nginx_cache}/fastcgi_temp \ | |
--http-uwsgi-temp-path=%{nginx_cache}/uwsgi_temp \ | |
--http-scgi-temp-path=%{nginx_cache}/scgi_temp \ | |
--user=%{nginx_user} \ | |
--group=%{nginx_group} \ | |
--with-file-aio \ | |
--with-ipv6 \ | |
--with-http_ssl_module \ | |
--with-http_realip_module \ | |
--with-http_addition_module \ | |
--with-http_xslt_module \ | |
--with-http_image_filter_module \ | |
--with-http_geoip_module \ | |
--with-http_sub_module \ | |
--with-http_dav_module \ | |
--with-http_flv_module \ | |
--with-http_mp4_module \ | |
--with-http_gzip_static_module \ | |
--with-http_random_index_module \ | |
--with-http_secure_link_module \ | |
--with-http_degradation_module \ | |
--with-http_stub_status_module \ | |
--with-http_perl_module \ | |
--with-mail \ | |
--with-mail_ssl_module \ | |
--with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' \ | |
--with-ld-opt="-Wl,-rpath,%{luajit_lib}" \ | |
--add-module=%{nginx_module}/lua-nginx-module | |
make %{?_smp_mflags} | |
%install | |
rm -rf %{buildroot} | |
make install DESTDIR=%{buildroot} INSTALLDIRS=vendor | |
install -p -d -m 0755 %{buildroot}%{nginx_module} | |
cp -a %{_sourcedir}/lua-nginx-module %{buildroot}%{nginx_module}/lua-nginx-module | |
find %{buildroot} -type f -name .packlist -exec rm -f '{}' \; | |
find %{buildroot} -type f -name perllocal.pod -exec rm -f '{}' \; | |
find %{buildroot} -type f -empty -exec rm -f '{}' \; | |
find %{buildroot} -type f -iname '*.so' -exec chmod 0755 '{}' \; | |
install -p -D -m 0755 %{SOURCE1} \ | |
%{buildroot}%{_initrddir}/nginx | |
install -p -D -m 0644 %{SOURCE2} \ | |
%{buildroot}%{_sysconfdir}/logrotate.d/nginx | |
install -p -D -m 0644 %{SOURCE6} \ | |
%{buildroot}%{_sysconfdir}/sysconfig/nginx | |
install -p -d -m 0755 %{buildroot}%{nginx_confdir}/conf.d | |
install -p -d -m 0755 %{buildroot}%{nginx_tmp}/{client,proxy} | |
install -p -d -m 0700 %{buildroot}%{nginx_cache}/{fastcgi,scgi,uwsgi}_temp | |
install -p -d -m 0700 %{buildroot}%{nginx_home} | |
install -p -d -m 0700 %{buildroot}%{nginx_logdir} | |
install -p -d -m 0755 %{buildroot}%{nginx_webroot} | |
install -p -d -m 0755 %{buildroot}%{nginx_module}/lua-nginx-module | |
install -p -m 0644 %{SOURCE3} \ | |
%{buildroot}%{nginx_confdir} | |
install -p -m 0644 %{SOURCE4} %{SOURCE5} \ | |
%{buildroot}%{nginx_confdir}/conf.d | |
install -p -m 0644 %{SOURCE100} \ | |
%{buildroot}%{nginx_webroot} | |
install -p -m 0644 %{SOURCE101} \ | |
%{buildroot}%{nginx_webroot} | |
install -p -D -m 0644 %{_builddir}/nginx-%{version}/man/nginx.8 \ | |
%{buildroot}%{_mandir}/man8/nginx.8 | |
rm -rf %{nginx_datadir} | |
%pre | |
getent group %{nginx_group} > /dev/null || groupadd -r %{nginx_group} | |
getent passwd %{nginx_user} > /dev/null || \ | |
useradd -r -d %{nginx_home} -g %{nginx_group} \ | |
-s /sbin/nologin -c "Nginx web server" %{nginx_user} | |
exit 0 | |
%post | |
if [ $1 -eq 1 ]; then | |
/sbin/chkconfig --add %{name} | |
fi | |
if [ $1 -eq 2 ]; then | |
# Make sure these directories are not world readable. | |
chmod 700 %{nginx_home} | |
fi | |
rm -rf %{nginx_confdir}/html | |
%preun | |
if [ $1 -eq 0 ]; then | |
/sbin/service %{name} stop >/dev/null 2>&1 | |
/sbin/chkconfig --del %{name} | |
fi | |
%postun | |
if [ $1 -eq 2 ]; then | |
/sbin/service %{name} upgrade || : | |
fi | |
%files | |
%doc LICENSE CHANGES README | |
%{nginx_datadir}/ | |
%{_sbindir}/nginx | |
%{_mandir}/man3/nginx.3pm* | |
%{_mandir}/man8/nginx.8* | |
%{_initrddir}/nginx | |
%{nginx_confdir}/html/index.html | |
%{nginx_confdir}/html/50x.html | |
%dir %{nginx_confdir} | |
%dir %{nginx_confdir}/conf.d | |
%config(noreplace) %{nginx_confdir}/fastcgi.conf | |
%config(noreplace) %{nginx_confdir}/fastcgi.conf.default | |
%config(noreplace) %{nginx_confdir}/fastcgi_params | |
%config(noreplace) %{nginx_confdir}/fastcgi_params.default | |
%config(noreplace) %{nginx_confdir}/koi-utf | |
%config(noreplace) %{nginx_confdir}/koi-win | |
%config(noreplace) %{nginx_confdir}/mime.types | |
%config(noreplace) %{nginx_confdir}/mime.types.default | |
%config(noreplace) %{nginx_confdir}/nginx.conf | |
%config(noreplace) %{nginx_confdir}/nginx.conf.default | |
%config(noreplace) %{nginx_confdir}/scgi_params | |
%config(noreplace) %{nginx_confdir}/scgi_params.default | |
%config(noreplace) %{nginx_confdir}/uwsgi_params | |
%config(noreplace) %{nginx_confdir}/uwsgi_params.default | |
%config(noreplace) %{nginx_confdir}/win-utf | |
%config(noreplace) %{nginx_confdir}/conf.d/*.conf | |
%config(noreplace) %{_sysconfdir}/logrotate.d/nginx | |
%config(noreplace) %{_sysconfdir}/sysconfig/nginx | |
%dir %{perl_vendorarch}/auto/nginx | |
%{perl_vendorarch}/nginx.pm | |
%{perl_vendorarch}/auto/nginx/nginx.so | |
%attr(700,%{nginx_user},%{nginx_group}) %dir %{nginx_home} | |
%attr(755,%{nginx_user},%{nginx_group}) %dir %{nginx_tmp}/client | |
%attr(755,%{nginx_user},%{nginx_group}) %dir %{nginx_tmp}/proxy | |
%attr(700,%{nginx_user},%{nginx_group}) %dir %{nginx_cache}/fastcgi_temp | |
%attr(700,%{nginx_user},%{nginx_group}) %dir %{nginx_cache}/scgi_temp | |
%attr(700,%{nginx_user},%{nginx_group}) %dir %{nginx_cache}/uwsgi_temp | |
%attr(700,%{nginx_user},%{nginx_group}) %dir %{nginx_logdir} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Configuration file for the nginx service. | |
NGINX=/usr/sbin/nginx | |
CONFFILE=/etc/nginx/nginx.conf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HTTPS server | |
# | |
#server { | |
# listen 443 ssl; | |
# server_name localhost; | |
# ssl_certificate /etc/nginx/cert.pem; | |
# ssl_certificate_key /etc/nginx/cert.key; | |
# ssl_session_cache shared:SSL:1m; | |
# ssl_session_timeout 5m; | |
# ssl_ciphers HIGH:!aNULL:!MD5; | |
# ssl_prefer_server_ciphers on; | |
# location / { | |
# root /usr/share/nginx/html; | |
# index index.html index.htm; | |
# } | |
#} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment