Multiple domains pointing to a single installation of WordPress

My blog, this site, actually has three URLs coming to it. http://marcovescio.com http://vesc.io/ http://marco.vesc.io/ These are the three URLs that I choose to use in various places to link back here. Of course, it could be infinitely more. I could link Any-Sub-Domain-I-Want.marcovescio.com if I really needed to. But back to my three URLs: I don’t want three different blogs. I want them all to come back to this one WordPress installation. At least for now… Additionally, I’d like navigation to stay on the domain that each user entered the site on: Usually because I’ve pointed them to that particular link for a particular purpose. Or they followed it from my resume, business card, or other source. Configure DNS The three URLs are actually only two domains: marcovescio.com and vesc.io Each domain has a wildcard subdomain A record in their DNS (the subdomain is a *) Configure Virtual Host The server is listening for all subdomains of each domain # NGINX Listen All Subdomains server_name .vesc.io; 12 # NGINX Listen All Subdomainsserver_name .vesc.io; Configuring WordPress At this point, you can enter my site from any subdomain and that page will initially display. But what happens when you click a link? Well, it uses the WordPress Address (URL) and Site Address (URL) options you’ve configured in Settings -> General. We can get around this by blanking out both options — but this must be done from wp-config.php Add the following lines to wp-config.php: define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']); define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']); 12 define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']);define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']); Final Notes Don’t forget to clear your...

WordPress Blank Page (PHP error)

A wordpress blank page (or white page of death) is the result of something going very wrong in PHP. The vast majority of the time, it is a plugin. You can disable all plugins and login by ‘hiding’ your plugins folder. I typically do this by renaming it: mv plugins plugins.old 1 mv plugins plugins.old rename the plugins folder and login to wp-admin. If you want to disable all the plugins click on “plugins” after you’re logged in. Then you can move the folder back. Other common reasons you can get the blank page: PHP Short Tags. Change short_open_tag to On in php.ini (or php-fpm pool, or wp-config.php ). If you’re seeing errors such as “unexpected end to file” for your theme or plugin, it is very likely because a short open tag is being used but not configured so it is unable to parse. Your theme. Try temporarily removing it or going back to a default WordPress theme Not enough memory assigned to PHP. Crank up your php memory_limit...

Protected: WordPress Server Setup

Install Repositories We’ll need to add a few repositories to get all the software versions we need. EPEL has no installs required directly, but is my favourite and default install. REMI will be used for PHP and PHP-FPM Percona is a drop-in replacement for MySQL 5.6 NGINX will be installed from the official repo.   EPEL CentOS and Red Hat 6.x wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm -Uvh epel-release-6*.rpm 12 wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpmrpm -Uvh epel-release-6*.rpm CentOS and Red Hat 7.x wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm rpm -Uvh epel-release-7*.rpm 12 wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpmrpm -Uvh epel-release-7*.rpm REMI We’ll be using PHP 5.6 from the REMI Repository. CentOS and Red Hat 6.x wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm rpm -Uvh remi-release-6*.rpm 12 wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm rpm -Uvh remi-release-6*.rpm CentOS and Red Hat 7.x wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm rpm -Uvh remi-release-7*.rpm 12 wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm rpm -Uvh remi-release-7*.rpm NGINX Create a file named /etc/yum.repos.d/nginx.repo and paste the configuration below: [nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1 12345 [nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/$releasever/$basearch/gpgcheck=0enabled=1 Percona yum install http://www.percona.com/downloads/percona-release/percona-release-0.0-1.x86_64.rpm 1 yum install http://www.percona.com/downloads/percona-release/percona-release-0.0-1.x86_64.rpm Prepare Server Disable SELinux + REBOOT SERVER yum install -y yum-cron chkconfig yum-cron on service yum-cron start 123 yum install -y yum-cronchkconfig yum-cron onservice yum-cron start service ntpd start   Setup User   useradd marco passwd marco mkdir -p /home/marco/php/{session,wsdlcache} chown -R marco:marco /home/marco/ chmod O+x /home/marco/ 12345 useradd marcopasswd marcomkdir -p /home/marco/php/{session,wsdlcache}chown -R marco:marco /home/marco/chmod O+x /home/marco/   Install Software Database – Percona 5.6 Install yum install Percona-Server-server-56 Percona-Server-client-56 1 yum install Percona-Server-server-56 Percona-Server-client-56  Configure service mysql start chkconfig mysql on mysql_secure_installation 123 service mysql startchkconfig mysql onmysql_secure_installation systemctl enable mysql systemctl start mysql mysql_secure_installation 123 systemctl enable mysqlsystemctl start mysqlmysql_secure_installation I also like to enter the username and password for the root...

Revisiting old posts

At the beginning of 2014 (like.. last week) I decided to re-launch my personal site. I thought this would be a simple process but as I look at old posts, I realize how quick technology changes and it angers me. Also, how awful some of my previous posts were written up. “Who cares? It is what it is! Move on with your life!” “Just import all your old posts. Update them as you can. It’s fine.” “NO! These are awful. You really need to go through them one by one and totally redo everything to be perfect or it will just nag you incessantly. I WILL nag you incessantly.” So I finally stopped arguing with myself — it was weird and upsetting those around me — and decided I was going to go through each one at different levels of re-writing. Some I’m just fixing some formatting and they’re going up… Others, oh man.. so much has changed!? How did I ever think I knew what I was talking about?! How did I not realize the futility of attempting to be cutting edge and make a post about it on the...

Install and Run Linux Malware Detect (maldetect, maldet)

Linux System Administration – Basics Series! Linux Malware Detect (or just Maldetect / Maldet) is a great anti-malware tool that any Linux SysAdmin should be aware of. Works great with ClamAV installed as it utilizes the ClamAV engine. Official project page here: https://www.rfxn.com/projects/linux-malware-detect/ Download & Install Maldetect wget http://www.rfxn.com/downloads/maldetect-current.tar.gz tar -xzf maldetect-current.tar.gz cd maldetect-* sh ./install.sh or sudo sh ./install.sh 1234 wget http://www.rfxn.com/downloads/maldetect-current.tar.gztar -xzf maldetect-current.tar.gzcd maldetect-*sh ./install.sh or sudo sh ./install.sh  Update Maldetect The following commands will update the actual program and the malware definitions. maldet --update-ver maldet --update 12 maldet --update-vermaldet --update Run Maldetect Personally, I would run this in a screen session so you can go on your merry way and come back to it later. screen maldet -a /path/to/files 12 screenmaldet -a /path/to/files When scan is complete you can view the report by entering the command listed at the end of the scan: maldet(9753): {scan} scan completed on /home/admin/: files 5, malware hits 0, cleaned hits 0 maldet(9753): {scan} scan report saved 'maldet --report 040511-2342.9753' 1 maldet(9753): {scan} scan completed on /home/admin/: files 5, malware hits 0, cleaned hits 0 maldet(9753): {scan} scan report saved 'maldet --report 040511-2342.9753' maldet --report 040511-2342.9753 1 maldet --report 040511-2342.9753 or you can view the report file directly. they are located in cat /usr/local/maldet/sess/040511-2342.9753 1 cat /usr/local/maldet/sess/040511-2342.9753 You can quarantine the files easily. maldet -q 040511-0442.3282 1 maldet -q 040511-0442.3282...

Admin + Apache + NGiNX accessible when using DSO php handler.

So you want your WordPress or Jooma or (insert other CMS with web dashboard here) to work but you also want to upload things via FTP and it keeps messing up permissions? Most likely you’re (a) not on a shared host nor (b) using something like cPanel with suPHP as your PHP handler. In fact, you’re most likely running your own setup with the default DSO php handler. Now you could just give everything 777 permissions (stand by for a post on why this isn’t as bad as people have lead you to believe but I still recommend against it!) or you could do the smart thing and make a group! I’m going to show you how I typically work around this problem for my clients and myself, with a group! Remove ACLs that could interfere setfacl -Rb /home/admin/sites/ 1 setfacl -Rb /home/admin/sites/ I find a lot of weird things on servers where people have been “playing” around with permissions that work. You can ignore this if you have never used setfacl before. This will clear whats there. -R being recursive and -b being to wipe Change directories and files to be group readable / writable Another common issue I find is that by the time I’ve been asked to help, my client has given up and made everything 777 but then got freaked out when they heard 777 is WORLD WRITABLE (AHHHH!! OMG!! Okay thats true but the ‘world’ ends at the server level). I always set folders and files back to 775 and 664. 775 and 664 vs 755 and 644 because we’re giving “group” some elevated permissions...

New site!

It’s January 2nd. I wanted a change. So I rebooted my personal site. Feels good. Clean. Empty. Modern. Maybe I should import the old content. yawn. Another day.

Zoe’s cupcake cookies

I LOVE Zoe’s cupcake cookies — they’re perfect for any party but especially winter holiday’s (as are all cookies..) — but I keep forgetting the damn recipe! So here it is. Where I can find it. Maybe I should post all my favourite recipe’s here and stop going crazy each time I need to make them, trying to remember how to do it. Zoe’s cupcake cookies Prep time: 40 mins Cook time: 10 mins Total time: 50 mins Ingredients 1 package of yellow cake mix 1/2 stick of butter 1 package of cream cheese 1 egg 1 tsp vanilla Instructions Mix all ingredients until well blended Refridgerate for 30 minutes Bake at 325 for 8-10 minutes 3.2.1271...