Skip to content

Instantly share code, notes, and snippets.

@meglio
Last active August 29, 2015 14:15
Show Gist options
  • Save meglio/4be0d87a54223ac24bfe to your computer and use it in GitHub Desktop.
Save meglio/4be0d87a54223ac24bfe to your computer and use it in GitHub Desktop.
Blank Server
# Add locale to the list of generated locales
echo ru_RU.UTF-8 UTF-8 >> /var/lib/locales/supported.d/local
# Regenerate list (it will invoke locale-gen...)
dpkg-reconfigure locales
# Set default passwords for mysql
# TODO: Setting blank password does not work (?)
debconf-set-selections <<< 'mysql-server mysql-server/root_password password'
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password'
# Install mysql server
apt-get update && apt-get -y install mysql-server
mysql_install_db
printf '\nn\ny\ny\ny\ny\n' | mysql_secure_installation
# Load timezones info into database
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql
# Set MySQL default timezone to Etc/UTC
sed -i -r "s_^\[mysqld\]\$_\0\ndefault-time-zone='Etc/UTC'_" /etc/mysql/my.cnf
service mysql restart
# Install nginx
apt-get -y install software-properties-common
printf '\n' | add-apt-repository ppa:nginx/stable
apt-get update && apt-get -y install nginx
sed -i -r 's:# (server_names_hash_bucket_size 64;):\1:' /etc/nginx/nginx.conf
# Install PHP5.5
printf '\n' | add-apt-repository ppa:ondrej/php5
apt-get update && apt-get -y install php5-fpm
# Configure php-fpm
sed -i -r 's|^;cgi.fix_pathinfo=1$|cgi.fix_pathinfo=0|' /etc/php5/fpm/php.ini | grep 'fix_pathinfo'
service php5-fpm restart
apt-get -y install php5-cli
# Set default timezone in PHP
sed -i -r 's_^;date.timezone = $_date.timezone = UTC_' /etc/php5/cli/php.ini
sed -i -r 's_^;date.timezone =$_date.timezone = UTC_' /etc/php5/fpm/php.ini
# More php extensions
apt-get -y install php5-mysql php5-mcrypt php5-curl php5-gd php5-intl
# Max upload file size
sed -i -r 's:^upload_max_filesize = [0-9]M$:upload_max_filesize = 8M:' /etc/php5/fpm/php.ini
sed -i -r 's:^post_max_size = [0-9]M$:post_max_size = 9M:' /etc/php5/fpm/php.ini
sed -i -r 's:http\s*\{:\0\n\tclient_max_body_size 9m;:' /etc/nginx/nginx.conf
# Yaml
apt-get -y install libyaml-dev
apt-get -y install php-pear
apt-get -y install php5-dev
printf '\n' | pecl install -f yaml
echo "extension=yaml.so" > /etc/php5/cli/conf.d/51-yaml.ini
echo "extension=yaml.so" > /etc/php5/fpm/conf.d/51-yaml.ini
# Redis
printf '\n' | add-apt-repository ppa:chris-lea/redis-server
apt-get update && apt-get -y install redis-server
apt-get -y install php5-redis
echo 'session.save_handler = redis' >> /etc/php5/fpm/conf.d/20-redis.ini
echo 'session.save_path = "tcp://127.0.0.1:6379"' >> /etc/php5/fpm/conf.d/20-redis.ini
# Igbinary
pecl install igbinary
echo -e "extension=igbinary.so\nsession.serialize_handler=igbinary" >> /etc/php5/cli/conf.d/21-igbinary.ini
echo -e "extension=igbinary.so\nsession.serialize_handler=igbinary" >> /etc/php5/fpm/conf.d/21-igbinary.ini
apt-get -y install ntp
# Remove default nginx website
rm -rf /etc/nginx/sites-enabled/default
service php5-fpm restart
service nginx restart
wget -O /etc/nginx/sites-available/example-wp-nginx https://gist.githubusercontent.com/meglio/4b0d15fb1b5bd2b1a727/raw/0e1e18ce64f610df318c4bec396d25382b1a7559/wp-nginx
wget -O /etc/nginx/sites-available/example-nginx-website https://gist.githubusercontent.com/meglio/4870ce6bc93f3a33528f/raw/81602c51df522972473c965559873aa755cd78b8/example-nginx-website
mkdir /etc/nginx/global
wget -O /etc/nginx/global/wp-single https://gist.githubusercontent.com/meglio/7912ab03383754d81ba3/raw/2cf7d83077946a39feffcf329f3b3d217a827abb/wp-single
wget -O /etc/nginx/global/wp-restrictions https://gist.githubusercontent.com/meglio/db3d3121cb203a021d1c/raw/d966a296123af1ebfed4e06075edfe4455bc57fd/wp-restrictions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment