Skip to content

Commit 49caf5f

Browse files
committed
initial commit
0 parents  commit 49caf5f

File tree

5 files changed

+259
-0
lines changed

5 files changed

+259
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.swp
2+
.DS_Store

Dockerfile

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
FROM ubuntu
2+
MAINTAINER Eugene Ware <[email protected]>
3+
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
4+
RUN apt-get update
5+
RUN apt-get -y upgrade
6+
7+
# Keep upstart from complaining
8+
RUN dpkg-divert --local --rename --add /sbin/initctl
9+
RUN ln -s /bin/true /sbin/initctl
10+
11+
# Basic Requirements
12+
RUN apt-get -y install mysql-server mysql-client nginx php5-fpm php5-mysql php-apc pwgen python-setuptools curl git unzip
13+
14+
# Wordpress Requirements
15+
RUN apt-get -y install php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
16+
17+
# mysql config
18+
RUN sed -i -e"s/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/my.cnf
19+
20+
# nginx config
21+
RUN sed -i -e"s/keepalive_timeout\s*65/keepalive_timeout 2/" /etc/nginx/nginx.conf
22+
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
23+
24+
# php-fpm config
25+
RUN sed -i -e "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php5/fpm/php.ini
26+
RUN sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php5/fpm/php-fpm.conf
27+
RUN find /etc/php5/cli/conf.d/ -name "*.ini" -exec sed -i -re 's/^(\s*)#(.*)/\1;\2/g' {} \;
28+
29+
# nginx site conf
30+
ADD ./nginx-site.conf /etc/nginx/sites-available/default
31+
32+
# Supervisor Config
33+
RUN /usr/bin/easy_install supervisor
34+
ADD ./supervisord.conf /etc/supervisord.conf
35+
36+
# Install Wordpress
37+
ADD http://wordpress.org/latest.tar.gz /wordpress.tar.gz
38+
RUN tar xvzf /wordpress.tar.gz -C /usr/share/nginx
39+
RUN mv /usr/share/nginx/www/5* /usr/share/nginx/wordpress
40+
RUN rm -rf /usr/share/nginx/www
41+
RUN mv /usr/share/nginx/wordpress /usr/share/nginx/www
42+
RUN chown -R www-data:www-data /usr/share/nginx/www
43+
ADD ./install_wordpress.sh /install_wordpress.sh
44+
RUN chmod 755 /install_wordpress.sh
45+
RUN /install_wordpress.sh
46+
47+
# Install plugins
48+
# RUN curl https://raw.github.com/wp-cli/wp-cli.github.com/master/installer.sh | INSTALL_DIR=/usr/local bash
49+
# RUN wp --path=/usr/share/nginx/www plugin install nginx-helper
50+
# RUN wp --path=/usr/share/nginx/www plugin activate nginx-helper
51+
# RUN wp --path=/usr/share/nginx/www rewrite structure /%postname%/
52+
RUN curl -O `curl -i -s http://wordpress.org/plugins/nginx-helper/ | egrep -o "http://downloads.wordpress.org/plugin/[^']+"`
53+
RUN unzip nginx-helper.1.7.2.zip -d /usr/share/nginx/www/wp-content/plugins
54+
RUN chown -R www-data:www-data /usr/share/nginx/www/wp-content/plugins/nginx-helper
55+
56+
# private expose
57+
EXPOSE 80
58+
59+
CMD ["/usr/local/bin/supervisord", "-n"]

install_wordpress.sh

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
#mysql has to be started this way as it doesn't work to call from /etc/init.d
3+
/usr/bin/mysqld_safe &
4+
sleep 10s
5+
# Here we generate random passwords (thank you pwgen!). The first two are for mysql users, the last batch for random keys in wp-config.php
6+
WORDPRESS_DB="wordpress"
7+
MYSQL_PASSWORD=`pwgen -c -n -1 12`
8+
WORDPRESS_PASSWORD=`pwgen -c -n -1 12`
9+
#This is so the passwords show up in logs.
10+
echo mysql root password: $MYSQL_PASSWORD
11+
echo wordpress password: $WORDPRESS_PASSWORD
12+
echo $MYSQL_PASSWORD > /mysql-root-pw.txt
13+
echo $WORDPRESS_PASSWORD > /wordpress-db-pw.txt
14+
15+
sed -e "s/database_name_here/$WORDPRESS_DB/
16+
s/username_here/$WORDPRESS_DB/
17+
s/password_here/$WORDPRESS_PASSWORD/
18+
/'AUTH_KEY'/s/put your unique phrase here/`pwgen -c -n -1 65`/
19+
/'SECURE_AUTH_KEY'/s/put your unique phrase here/`pwgen -c -n -1 65`/
20+
/'LOGGED_IN_KEY'/s/put your unique phrase here/`pwgen -c -n -1 65`/
21+
/'NONCE_KEY'/s/put your unique phrase here/`pwgen -c -n -1 65`/
22+
/'AUTH_SALT'/s/put your unique phrase here/`pwgen -c -n -1 65`/
23+
/'SECURE_AUTH_SALT'/s/put your unique phrase here/`pwgen -c -n -1 65`/
24+
/'LOGGED_IN_SALT'/s/put your unique phrase here/`pwgen -c -n -1 65`/
25+
/'NONCE_SALT'/s/put your unique phrase here/`pwgen -c -n -1 65`/" /usr/share/nginx/www/wp-config-sample.php > /usr/share/nginx/www/wp-config.php
26+
27+
ACTIVATE_PLUGINS=<<ENDL
28+
$plugins = get_option( 'active_plugins' );
29+
if ( count( $plugins ) === 0 ) {
30+
$wp_rewrite->set_permalink_structure( '/%postname%/' );
31+
$pluginsToActivate = array( 'nginx-helper' );
32+
foreach ($pluginsToActivate as $plugin) {
33+
if ( !in_array( $plugin, $plugins ) ) {
34+
array_push( $plugins, $plugin );
35+
update_option( 'active_plugins', $plugins );
36+
}
37+
}
38+
}
39+
ENDL
40+
41+
echo $ACTIVATE_PLUGINS >> /usr/share/nginx/www/wp-config.php
42+
43+
chown www-data:www-data /usr/share/nginx/www/wp-config.php
44+
mysqladmin -u root password $MYSQL_PASSWORD
45+
mysql -uroot -p$MYSQL_PASSWORD -e "CREATE DATABASE wordpress; GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost' IDENTIFIED BY '$WORDPRESS_PASSWORD'; FLUSH PRIVILEGES;"
46+
killall mysqld

nginx-site.conf

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# You may add here your
2+
# server {
3+
# ...
4+
# }
5+
# statements for each of your virtual hosts to this file
6+
7+
##
8+
# You should look at the following URL's in order to grasp a solid understanding
9+
# of Nginx configuration files in order to fully unleash the power of Nginx.
10+
# http://wiki.nginx.org/Pitfalls
11+
# http://wiki.nginx.org/QuickStart
12+
# http://wiki.nginx.org/Configuration
13+
#
14+
# Generally, you will want to move this file somewhere, and start with a clean
15+
# file but keep this around for reference. Or just disable in sites-enabled.
16+
#
17+
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
18+
##
19+
20+
server {
21+
listen 80; ## listen for ipv4; this line is default and implied
22+
listen [::]:80 default ipv6only=on; ## listen for ipv6
23+
24+
root /usr/share/nginx/www;
25+
index index.php index.html index.htm;
26+
27+
# Make site accessible from http://localhost/
28+
server_name localhost;
29+
30+
location / {
31+
# First attempt to serve request as file, then
32+
# as directory, then fall back to index.html
33+
try_files $uri $uri/ /index.php?q=$uri&$args;
34+
# Uncomment to enable naxsi on this location
35+
# include /etc/nginx/naxsi.rules
36+
}
37+
38+
location /doc/ {
39+
alias /usr/share/doc/;
40+
autoindex on;
41+
allow 127.0.0.1;
42+
allow ::1;
43+
deny all;
44+
}
45+
46+
# Only for nginx-naxsi : process denied requests
47+
#location /RequestDenied {
48+
# For example, return an error code
49+
#return 418;
50+
#}
51+
52+
#error_page 404 /404.html;
53+
54+
# redirect server error pages to the static page /50x.html
55+
#
56+
error_page 500 502 503 504 /50x.html;
57+
location = /50x.html {
58+
root /usr/share/nginx/www;
59+
}
60+
61+
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
62+
#
63+
location ~ \.php$ {
64+
try_files $uri =404;
65+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
66+
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
67+
68+
# With php5-cgi alone:
69+
fastcgi_pass 127.0.0.1:9000;
70+
# With php5-fpm:
71+
# fastcgi_pass unix:/var/run/php5-fpm.sock;
72+
fastcgi_index index.php;
73+
include fastcgi_params;
74+
}
75+
76+
# deny access to .htaccess files, if Apache's document root
77+
# concurs with nginx's one
78+
#
79+
#location ~ /\.ht {
80+
# deny all;
81+
#}
82+
}
83+
84+
85+
# another virtual host using mix of IP-, name-, and port-based configuration
86+
#
87+
#server {
88+
# listen 8000;
89+
# listen somename:8080;
90+
# server_name somename alias another.alias;
91+
# root html;
92+
# index index.html index.htm;
93+
#
94+
# location / {
95+
# try_files $uri $uri/ /index.html;
96+
# }
97+
#}
98+
99+
100+
# HTTPS server
101+
#
102+
#server {
103+
# listen 443;
104+
# server_name localhost;
105+
#
106+
# root html;
107+
# index index.html index.htm;
108+
#
109+
# ssl on;
110+
# ssl_certificate cert.pem;
111+
# ssl_certificate_key cert.key;
112+
#
113+
# ssl_session_timeout 5m;
114+
#
115+
# ssl_protocols SSLv3 TLSv1;
116+
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
117+
# ssl_prefer_server_ciphers on;
118+
#
119+
# location / {
120+
# try_files $uri $uri/ /index.html;
121+
# }
122+
#}

supervisord.conf

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[unix_http_server]
2+
file=/tmp/supervisor.sock ; (the path to the socket file)
3+
4+
[supervisord]
5+
logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
6+
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
7+
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
8+
loglevel=info ; (log level;default info; others: debug,warn,trace)
9+
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
10+
nodaemon=false ; (start in foreground if true;default false)
11+
minfds=1024 ; (min. avail startup file descriptors;default 1024)
12+
minprocs=200 ; (min. avail process descriptors;default 200)
13+
14+
; the below section must remain in the config file for RPC
15+
; (supervisorctl/web interface) to work, additional interfaces may be
16+
; added by defining them in separate rpcinterface: sections
17+
[rpcinterface:supervisor]
18+
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
19+
20+
[supervisorctl]
21+
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
22+
23+
[program:php5-fpm]
24+
command=/usr/sbin/php5-fpm -c /etc/php5/fpm
25+
26+
[program:mysqld]
27+
command=/usr/bin/mysqld_safe
28+
29+
[program:nginx]
30+
command=/usr/sbin/nginx

0 commit comments

Comments
 (0)