These are some of my notes and stuff I use to set-up a Linux server if this will help anyone getting started.
/*****
Building Fedora 21
*****/
rpm -ivh
http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpmrpm -ivh
http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpmrpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-*
yum update -y
yum install nano mlocate -y
updatedb
tar -zcvf dir.tar.gz /path/to/dir
tar -zxvf dir.tar.gz
EDITOR=nano
export EDITOR
/*****
SSH
*****/
nano -wS /etc/ssh/sshd_config
#uncomment line #Port 22 and change to Port up to 65000
/*****
Web Server
*****/
yum groupinstall -y "Web Server" "MySQL Database" "PHP Support"
yum install -y php-simplexml php-mysql
apachectl start
chkconfig httpd on
systemctl list-unit-files
ln -s target_path link_path
tail -f -n 222 /var/log/httpd/access_log
tail -f -n 222 /var/log/httpd/error_log
chmod -R 777 /mnt/vol2/cache
nano -wS /etc/httpd/conf/httpd.conf
ErrorDocument 404 /not-found.html
ServerAdmin [email protected]
ServerName nickelbot.com:80
ServerAlias www.nickelbot.com *.nickelbot.com
DocumentRoot /var/www/www.nickelbot.com
ErrorLog logs/www.nickelbot.com-error_log
CustomLog logs/www.nickelbot.com-access_log common
/*****
IP Tables
/etc/sysconfig/iptables-config
*****/
iptables -L
iptables -F
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP
iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 25 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 465 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 110 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 995 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 143 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 993 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 22692 -j ACCEPT
#iptables -A INPUT -p tcp -m tcp --dport 22 -j DROP #make sure to log-in on port up to 65000 port first...then save this
iptables -I INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P INPUT DROP
iptables -L -n
#save & restore
iptables-save > /etc/sysconfig/iptables
iptables-restore < /etc/sysconfig/iptables
#Load on start-up:
nano -wS /etc/rc.d/rc.local
/sbin/iptables-restore < /etc/sysconfig/iptables
/*****
Database
*****/
yum install mysql mysql-devel mysql-server -y
service mysqld start
mysqladmin -u root password blahblahblah
chkconfig mysqld on
#for back up
mysqldump --opt -u root -p wpbitcoinusd > .htdbbackup2.sql
/*****
Github - Get the public and private key from github.com
*****/
yum install github -y
git config --global user.email "
[email protected]"
git config --global user.name "Adam Cox"
nano -wS /root/.ssh/github_rsa
nano -wS /root/.ssh/github_rsa.pub
chmod 400 /root/.ssh/github_rsa
nano -wS ~/.ssh/config
Host github.com
IdentityFile ~/.ssh/github_rsa
git clone
[email protected]:AdamCox9/nickelbot.git
git config --global user.name "AdamCox9"
git config --global user.email "
[email protected]"
git clone
[email protected]:AdamCox9/nickelbot.git
git clone
[email protected]:AdamCox9/nickelbot.git
git submodule init
git submodule update
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,FB00E32A6B7CFFB8DC2EB9BE23459081
-------
-----END RSA PRIVATE KEY-----
#public key:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCpcEw8cW3anzntlsb0Pa3MMTSLeDuCUDHhNilwcMnoJKYoXd8
9LyUrqf8eDzNXTAZSwkjnDKWpa6oR3c04ASkYXhoMhBptLpOjYYW9x4GklYMjRGgMkdc0nIJkZ4OE4R
5QprKSLo9G/ORu3Afm58GfFgi7UmW5wte8GBkG8NTU5OvmS6Po36EQKRGkI+86KhOG5jWSl7bcM2b/oEU0FvikwmZkV/92VHZpA460G/z/0COwmfb1U5tG/LXGxz3aAtBLxtqkak9BmLcFtigZWPmZkHSoyCt9ubCbWKZtXSe0De8WFjpMyjVJyN5d1I50WAqc8UWxJAulcfVMQrycxyu5
[email protected]/*****
Swap
*****/
dd if=/dev/zero of=/swapfile bs=1024 count=2097152
mkswap /swapfile
swapon /swapfile
nano -wS /etc/fstab
/swapfile swap swap defaults 0 0
free
cat /proc/swaps
/*****
HTTPS
*****/
yum install mod_ssl openssl
openssl genrsa -out ca.key 2048
openssl req -new -key ca.key -out ca.csr
openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt
cp ca.crt /etc/pki/tls/certs/
cp ca.key /etc/pki/tls/private/
cp ca.csr /etc/pki/tls/private/
cat /etc/pki/tls/certs/ca.crt
cat /etc/pki/tls/private/ca.key
cat /etc/pki/tls/private/ca.csr
nano -wS /etc/httpd/conf.d/ssl.conf
### overwrite the following parameters ###
SSLCertificateFile /etc/pki/tls/certs/ca.crt
SSLCertificateKeyFile /etc/pki/tls/private/ca.key
### The following parameter does not need to be modified in case of a self-signed certificate. ###
### If you are using a real certificate, you may receive a certificate bundle. The bundle is added using the following parameters ###
SSLCertificateChainFile /etc/pki/tls/certs/example.com.ca-bundle
service httpd restart
nano -wS /etc/httpd/conf/httpd.conf
NameVirtualHost *:80
ServerAdmin [email protected]
DocumentRoot /var/www/html/virtual-web
ServerName virtual-web.example.com
NameVirtualHost *:443
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/ca.crt
SSLCertificateKeyFile /etc/pki/tls/private/ca.key
AllowOverride All
ServerAdmin [email protected]
DocumentRoot /var/www/html/virtual-web
ServerName virtual-web.example.com
#Get certificate from CA and copy it into /etc/pki/tls/certs/ca.crt
service httpd restart
#redirect http to https - put redirect line in virtual host for 80:
nano -wS /etc/httpd/conf/httpd.conf
ServerAdmin [email protected]
DocumentRoot /var/www/html
ServerName bitcoinusd.info
Redirect / https://bitcoinusd.info/
/*****
Redirect
*****/
nano -wS /etc/httpd/conf/httpd.conf
#Redirect www to non-www
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
#Redirect www to non-www
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
/*****
yum -y update
yum groupinstall -y 'development tools'
yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel
yum install python
*****/
/*****
CRON
*****/
crontab -e
* * * * * php /var/www/example.php > /var/www/data.out
minute|hour|day of month|month|day of week
/*****
Use Key to SSH into Server
*****/
#TODO
/*****
Mail server
*****/
#TODO