Last active
April 16, 2017 00:50
-
-
Save vanilla-thunder/7bcb6c8bc4f146a18da04d5dce3a95da to your computer and use it in GitHub Desktop.
Ubuntu 16.04 VPS Setup: SSH Key auth + ufw + mysql + apache + multiple PHP versions via phpbrew + nodejs via nvm
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
# update before installation | |
apt-get update && apt-get upgrade | |
dpkg-reconfigure tzdata | |
# SSH Key Auth | |
ssh-keygen -o -a 100 -t ed25519 | |
cd ~/.ssh/ && cat id_ed25519.pub >> authorized_keys | |
service ssh restart | |
# firewall | |
ufw allow ssh && ufw allow http && ufw allow https | |
ufw default deny incoming && ufw default allow outgoing | |
ufw enable | |
# mySQL | |
apt-get install -y mysql-server mysql-client && mysql_secure_installation | |
# Apache | |
apt-get install -y apache2 curl | |
a2enmod rewrite && a2enmod proxy && a2enmod ssl | |
service apache2 restart | |
# default php 7 | |
apt-get install -y php curl php-curl libapache2-mod-php php-mysql php-bcmath php-opcache php-apcu php-intl php-curl php-gd php-gettext php-mbstring php-mcrypt php-pear php-soap php-tidy php-xmlrpc php-zip php-bz2 | |
# manual php build: | |
cd /opt | |
wget http://de.php.net/get/php-5.6.30.tar.bz2/from/this/mirror -O php-5.6.30.tar.bz2 | |
tar jxf php-5.6.30.tar.bz2 | |
cd php-5.6.30 | |
make && make install | |
./configure --prefix=/opt/php-5.6.30 --with-config-file-scan-dir=/opt/conf.d/ --enable-bcmath --enable-calendar --enable-exif --enable-ftp --enable-gd-native-ttf --enable-inline-optimization --enable-opcache --enable-mbregex --enable-mbstring --enable-pcntl --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-zip --disable-rpath --with-bz2 --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv --with-jpeg-dir=/usr --with-kerberos --with-libdir=/lib/x86_64-linux-gnu --with-libxml-dir=/usr --with-mcrypt --with-mhash --with-mysql --with-mysqli --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-openssl --with-pcre-regex --with-pdo-mysql --with-png-dir=/usr --with-tidy --with-xmlrpc --with-xpm-dir=/usr/ --with-xsl --with-zlib --with-zlib-dir | |
cp /opt/php-5.6.30/php.ini-production /opt/php-5.6.30/lib/php.ini | |
cp /opt/php-5.6.30/etc/php-fpm.conf.default /opt/php-5.6.30/etc/php-fpm.conf | |
# PHPbrew | |
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew | |
chmod +x phpbrew | |
mv phpbrew /usr/local/bin/phpbrew | |
mkdir -p /opt/phpbrew | |
phpbrew init --root=/opt/phpbrew | |
export PHPBREW_ROOT=/opt/phpbrew | |
export PHPBREW_HOME=/root/.phpbrew | |
### add to ~/.bashrc: ### | |
export PHPBREW_ROOT=/opt/phpbrew | |
export PHPBREW_HOME=/root/.phpbrew | |
source ~/.phpbrew/bashrc | |
### restart ssh session ### | |
apt-get install lcov libbz2-dev libgmp3-dev libmcrypt-dev libreadline-dev libedit-dev libtidy-dev libgd2-dev libxpm-dev libpng-dev libjpeg-dev libcurl4-gnutls-dev | |
# install php via phpbrew | |
phpbrew --debug install 5.6 +everything -sqlite -pgsql -dtrace -gmp | |
### edit php config file: /opt/phpbrew/php/php-5.6.30/etc/php-fpm.conf | |
### replace: "nobody" with "www-data" | |
### change: listen.owner = root | |
### change: listen.group = www-data | |
### change: error_log = /var/log/apache2/php-fpm-5.6.log | |
chown root:www-data /opt/phpbrew/php/php-5.6.30/var/run/php-fpm.sock | |
phpbrew fpm start php-5.6.30 | |
# nvm | |
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash | |
nvm install stable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment