Surely every developer, sooner or later, is faced with the problem of the test environment. It is not very convenient to keep the PC turned on 24x7, and even fill it up with software for experiments to the eyeballs. On the other hand, finding hosting on your own, not expensive either, is not an easy task. What to do? There is a solution - deploy the sandbox at home. As I was convinced about this in more detail below, it is not expensive, it is convenient and very fascinating.![]() | ![]() |
sudo apt-cache search < , > for installation we perform sudo apt-get install < > x11vnc -storepasswd <pass> <file> @/usr/bin/x11vnc -dontdisconnect -display :0 -notruecolor -noxfixes -shared -forever -rfbport 5900 -bg -o /var/log/x11vnc.log -rfbauth /home/ice/.vnc/passwd autologin-user=ice autologin-user-timeout=0 lshw lshw-gtk sensors shows information about MPs from available sensors. /usr/sbin/sensors-detect hddtemp /dev/sda prompts to what temperature the hard drive has heated up. #!/bin/bash echo '################## TIME ##################' date echo '################# UP TIME ################' uptime echo '################# MB TEMP ################' sensors echo '################ HDD TEMP ################' sudo hddtemp /dev/sda echo echo visudo ice ALL=NOPASSWD: /home/ice/scripts/monitoring/temp.sh and now cron: sudo crontab -e -u ice */10 * * * * sudo /home/ice/scripts/monitoring/temp.sh >> /home/ice/scripts/monitoring/temp.log 2>&1 grep CRON /var/log/syslog And one more thing - so that the logs do not accumulate, I set up their rotation. To do this, install Logrotate sudo apt-get install logrotate /home/ice/scripts/monitoring/temp.log { # daily # missingok # rotate 30 # 30 compress # delaycompress # (.. *.log.1 , *.log.2 ) notifempty # create 640 ice ice # } smbpasswd -a ice sudo apt-get update sudo apt-get upgrade sudo apt-get install apache2 apache2-doc php5 libapache2-mod-php5 php-pear sudo apt-get install mysql-server mysql-client php5-mysql sudo apt-get install php5-curl php5-gd php5-imagick php5-ldap php5-imap php5-memcache php5-common php5-mysql php5-ps php5-tidy imagemagick php5-xcache php5-xdebug php5-xmlrpc php5-xsl But immediately after the installation, I suffered a failure - php files did not want to be processed by apache in any way. In order to fix this, I made the following manipulations: /etc/apache2$ sudo gedit apache2.con # AddHandler application/x-httpd-php .php .php4 .php3 .html AddType application/x-httpd-php .html sudo apt-get install python g++ make checkinstall mkdir ~/src && cd $_ wget -N http://nodejs.org/dist/node-latest.tar.gz tar xzvf node-latest.tar.gz && cd node-v* # "v" ./configure checkinstall sudo dpkg -i node_* sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 echo 'deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list sudo apt-get update sudo apt-get install mongodb-10gen ... and run sudo /etc/init.d/mongodb start usermod -a -G gitolite www-data in order that apach and gitolite make friends. <VirtualHost *:81> ServerAdmin webmaster@localhost ServerName git-web.loc SetEnv GITWEB_CONFIG /etc/gitweb.conf DocumentRoot /home/git/repositories Alias /static/gitweb.css /usr/share/gitweb/static/gitweb.css Alias /static/git-logo.png /usr/share/gitweb/static/git-logo.png Alias /static/git-favicon.png /usr/share/gitweb/static/git-favicon.png Alias /static/gitweb.js /usr/share/gitweb/static/gitweb.js Alias /git /home/git/repositories ScriptAlias /gitweb.cgi /usr/lib/cgi-bin/gitweb.cgi DirectoryIndex gitweb.cgi <Directory /home/git/repositories/> Allow from All Options +ExecCGI AllowOverride All AuthType Basic AuthName "Private Repository" AuthUserFile /home/ice/stuff/keys/.htpasswd-gitweb Require valid-user AddHandler cgi-script .cgi DirectoryIndex gitweb.cgi RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^.* /gitweb.cgi/$0 [L,PT] </Directory> SetEnv GIT_PROJECT_ROOT /home/git/repositories SetEnv GIT_HTTP_EXPORT_ALL ErrorLog ${APACHE_LOG_DIR}/git_web_error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/git_web_access.log combined </VirtualHost> Basic authorization to taste, you can disable. sudo apt-get remove openjdk* su - # java echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886 apt-get update # Oracle software license echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections # Oracle JDK7 apt-get install oracle-java7-installer # root exit # java java -version <network-listener name="http-listener-1" port="8081" protocol="http-listener-1" thread-pool="http-thread-pool" transport="tcp"</network-listener> apt-get install build-essential libapache2-mod-passenger ruby rdoc ruby-dev libopenssl-ruby rubygems gem install fastthread gem install rails --version 3.0.4 And also do not forget to add rails in $ PATH:PATH=".../var/lib/gems/VERSION/bin" # aptitude install libmagickcode-dev aptitude install libmagickwand-dev aptitude install ruby1.9.1-dev aptitude install libmysqlclient-dev # redmine cd /opt wget http://files.rubyforge.vm.bytemark.co.uk/redmine/redmine-2.3.1.tar.gz tar -zxvf redmine-2.3.1.tar.gz cd /var/www ln -s /redmine-2.3.1/public redmine chown -R www-data:www-data /opt/redmine-2.3.1 CREATE DATABASE redmine_default CHARACTER SET utf8; CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'my-password'; GRANT ALL PRIVILEGES ON redmine_default.* TO 'redmine'@'localhost'; cd /redmine-2.3.1/config cp database.yml.example database.yml vi database.yml and fill it up production: adapter: mysql2 database: redmine_default host: localhost username: redmine password: my-password encoding: utf8 cd /redmine-2.3.1/config cp configuration.yml.example configuration.yml vi configuration.yml and we are adjusted (the benefit in a config is full of comments). gem install bundler bundle install --without development test postgresql sqlite rake generate_secret_token bundle install and prepare the database: RAILS_ENV=production rake db:migrate RAILS_ENV=production rake redmine:load_default_data sudo apt-get install mono-common mono-xsp4 sudo apt-get update sudo apt-get install php5-cli php5-xdebug php-pear ant git php -r 'echo "Xdebug loaded? "; echo (extension_loaded("xdebug")) ? "yes" : "no"; echo chr(10);' wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add - sudo bash -c "echo 'deb http://pkg.jenkins-ci.org/debian binary/' > /etc/apt/sources.list.d/jenkins.list" sudo apt-get update sudo apt-get install jenkins wget http://localhost:8080/jnlpJars/jenkins-cli.jar java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin checkstyle java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin cloverphp java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin dry java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin htmlpublisher java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin jdepend java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin plot java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin pmd java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin violations java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin xunit java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin git java -jar jenkins-cli.jar -s http://localhost:8080 safe-restart sudo pear upgrade PEAR sudo pear channel-discover pear.pdepend.org sudo pear channel-discover pear.phpmd.org sudo pear channel-discover pear.phpunit.de sudo pear channel-discover components.ez.no sudo pear channel-discover pear.symfony-project.com sudo pear install pdepend/PHP_Depend sudo pear install phpmd/PHP_PMD sudo pear install phpunit/phpcpd sudo pear install phpunit/phploc sudo pear install PHPDocumentor sudo pear install PHP_CodeSniffer sudo pear install --alldeps phpunit/PHP_CodeBrowser sudo pear install --alldeps phpunit/PHPUnit cd /var/lib/jenkins/jobs/ sudo git clone git://github.com/sebastianbergmann/php-jenkins-template.git php-template sudo chown -R jenkins:nogroup php-template/ sudo /etc/init.d/jenkins stop sudo /etc/init.d/jenkins start - create a new task from the template, link it to the repository (you may have to add a plugin under your version control system) and rejoice. #!/bin/bash # start=`date +%s` echo '[FULL BACK UP Start]' DATE_NOW=`date +%F` echo '[FULL BACK UP Dump Creation]' # sudo remastersys backup install-$DATE_NOW.iso echo '[FULL BACK UP Dump Saving]' # sudo cp /home/remastersys/remastersys/install-$DATE_NOW.iso /home/backups/system-iso/install-$DATE_NOW.iso sudo cp /home/remastersys/remastersys/install-$DATE_NOW.iso.md5 /home/backups/system-iso/install-$DATE_NOW.iso.md5 echo '[FULL BACK UP Clean up]' # tmp sudo remastersys clean echo '[FULL BACK UP End]' end=`date +%s` runtime=$((end-start)) echo 'Backup time =' $runtime 'sec(s)' #!/bin/bash start=`date +%s` echo '[BACK UP Start]' DATE_PREF=`date +%F` echo '[BACK UP Config]' # BACKUP_MYSQL_DIR=/home/backups/mysql/$DATE_PREF BACKUP_WWW_DIR=/home/backups/www/$DATE_PREF BACKUP_GIT_DIR=/home/backups/git/$DATE_PREF echo '[BACK UP Clean up]' # find /home/backups/mysql/ -mtime +7 -print -mindepth 1 -delete >/dev/null 2>&1 find /home/backups/www/ -mtime +7 -print -mindepth 1 -delete >/dev/null 2>&1 find /home/backups/git/ -mtime +7 -print -mindepth 1 -delete >/dev/null 2>&1 echo '[BACK UP Not Clened Items]' ls /home/backups/mysql/ ls /home/backups/www/ ls /home/backups/git/ echo '[BACK UP Back Up Hosts]' # tar cpzf $BACKUP_WWW_DIR\-www.tgz /home/www/ >/dev/null 2>&1 echo '[BACK UP Back Up Repositories]' # tar cpzf $BACKUP_GIT_DIR\-git.tgz /home/git/ >/dev/null 2>&1 echo '[BACK UP Back Up MySQL]' # mysqldump -q -u root -p<password> -h localhost tt_rss | gzip -c > $BACKUP_MYSQL_DIR\-tt_rss.sql.gz mysqldump -q -u root -p<password> -h localhost test | gzip -c > $BACKUP_MYSQL_DIR\-test.sql.gz mysqldump -q -u root -p<password> -h localhost redmine | gzip -c > $BACKUP_MYSQL_DIR\-redmine.sql.gz mysqldump -q -u root -p<password> -h localhost phpmyadmin | gzip -c > $BACKUP_MYSQL_DIR\-phpmyadmin.sql.gz mysqldump -q -u root -p<password> --skip-lock-tables -h localhost performance_schema | gzip -c > $BACKUP_MYSQL_DIR\-performance_schema.sql.gz mysqldump -q -u root -p<password> --skip-lock-tables -h localhost information_schema | gzip -c > $BACKUP_MYSQL_DIR\-information_schema.sql.gz mysqldump -q -u root -p<password> --events -h localhost mysql | gzip -c > $BACKUP_MYSQL_DIR\-mysql.sql.gz echo '[BACK UP New Items]' ls /home/backups/mysql/ | grep $DATE_PREF ls /home/backups/www/ | grep $DATE_PREF ls /home/backups/git/ | grep $DATE_PREF echo '[BACK UP End]' end=`date +%s` runtime=$((end-start)) echo 'Backup time =' $runtime 'sec(s)' echo '=========================================================' Source: https://habr.com/ru/post/205120/
All Articles