Created
September 29, 2015 10:16
-
-
Save doole/a78420e3f03304b8a120 to your computer and use it in GitHub Desktop.
FreeBSD-10.2-RELEASE server setup (nginx, MariaDB, MongoDB, PostgreSQL, PHP)
This file contains 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 | |
# =============================================== | |
# FreeBSD-10.2 server setup | |
# =============================================== | |
# Update | |
freebsd-update fetch | |
freebsd-update install | |
# Install Vim | |
pkg install vim-light | |
# Install ZSH | |
pkg install zsh | |
chsh -s /usr/local/bin/zsh | |
# Install nginx | |
pkg install nginx | |
mv /usr/local/etc/nginx/nginx.conf{,.original} | |
cat > /usr/local/etc/nginx/nginx.conf <<EOF | |
user www; | |
worker_processes 2; | |
error_log /var/log/nginx/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; | |
server { | |
listen 80; | |
server_name localhost; | |
#charset koi8-r; | |
access_log /var/log/nginx/server.access.log main; | |
root /usr/local/www/nginx; | |
index index.php index.html index.htm; | |
location / { | |
try_files $uri $uri/ =404; | |
} | |
#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/local/www/nginx-dist; | |
} | |
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 | |
# | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/var/run/php-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $request_filename; | |
include fastcgi_params; | |
} | |
# deny access to .htaccess files, if Apache's document root | |
# concurs with nginx's one | |
# | |
#location ~ /\.ht { | |
# deny all; | |
#} | |
} | |
} | |
EOF | |
mkdir -p /var/log/nginx/ | |
touch /var/log/nginx/{error,access}.log | |
cd /usr/local/www/ | |
rm -rf nginx/ | |
cp -r nginx-dist/ nginx/ | |
# Enable nginx on startup | |
sysrc nginx_enable=yes | |
service nginx start | |
# Install MariaDB | |
pkg install mariadb100-server mariadb100-client | |
cp /usr/loca/share/mysql/my-medium.cnf /usr/local/etc/my.cnf | |
# Enable MariaDB on startup | |
sysrc mysql_enable=yes | |
service mysql-server start | |
# MariaDB setup | |
mysql_secure_installation | |
# Install MongoDB | |
pkg install mongodb | |
# MongoDB setup | |
cat > /etc/rc.conf <<EOL | |
mongod_config="/usr/local/etc/mongodb.conf" | |
mongod_dbpath="/var/db/mongodb" | |
EOL | |
cat > /usr/local/etc/mongodb.conf <<EOL | |
master = true | |
nohttpinterface = true | |
EOL | |
# Enable MongoDB on startup | |
sysrc mongod_enable=yes | |
service mongod start | |
# Install PostgreSQL | |
pkg install postgresql93-server postgresql93-client postgresql93-contrib | |
# Enable PostgreSQL on startup | |
sysrc postgresql_enable=yes | |
# PostgreSQL setup | |
/usr/local/etc/rc.d/postgresql initdb | |
cd /usr/local/pgsql/data | |
sed -i '' 's/^#listen_addresses/listen_addresses/' postgresql.conf | |
service postgresql start | |
# Install PHP5 | |
pkg install php56 php56-extensions php56-bz2 php56-curl php56-gd php56-mysqli php56-pdo php56-pdo_mysql php56-pgsql php56-pdo_pgsql php56-zip | |
cd /usr/local/etc/ | |
sed -i '' 's/^;listen\ =\ 127\.0\.0\.1:9000/listen\ =\ \/var\/run\/php-fpm\.sock/' php-fpm.conf | |
sed -i '' 's/^;listen.owner/listen.owner/' php-fpm.conf | |
sed -i '' 's/^;listen.group/listen.group/' php-fpm.conf | |
sed -i '' 's/^;listen.mode/listen.mode/' php-fpm.conf | |
cp php.ini-production php.ini | |
sed -i '' 's/^;cgi\.fix_pathinfo=1/cgi\.fix_pathinfo=0/' php.ini | |
sed -i '' 's/^;date\.timezone\ =/date\.timezone\ =\ \"Europe\/Berlin\"/' php.ini | |
# Enable PHP-FPM on startup | |
sysrc php_fpm_enable=yes | |
service php-fpm start | |
cat > /usr/local/www/nginx/info.php <<EOF | |
<?php phpinfo(); ?> | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment