AWS EC2: How To Set Up Apache Virtual Hosts on CentOS 7

AWS EC2: How To Set Up Apache Virtual Hosts on CentOS 7

Are you looking for a way to host multiple sites on your AWS EC2 instance? Well it is possible, after all it is still apache that is running on the server. Below is a quick step i used to have two of my applications running on my AWS EC2 micro server.

Before you Start!

Before you begin with this guide, there are a few steps that need to be completed first. link

You will need access to a CentOS 7 server with a non-root user that has sudo privileges.

You will also need to have Apache installed in order to configure virtual hosts for it. If you haven’t already done so, you can use yum to install Apache through CentOS’s default software repositories:

sudo yum -y install httpd
sudo systemctl enable httpd.service

After these steps are complete, log in as your non-root user account through SSH and continue with the tutorial.

Note: The example configuration in this guide will make one virtual host for website1.com and another forwebsite2.com. We will be using these 2 throughout the guide, but you should substitute your own domains or values while following along or after you test that it works with this example.

Step 1: Create your new website directory

sudo mkdir -p /var/www/website1.com/public_html
sudo mkdir -p /var/www/website12.com/public_html

Step 2: Grant permissions to the logged in User

sudo chown -R $USER:$USER /var/www/website1.com/public_html
sudo chown -R $USER:$USER /var/www/website12.com/public_html
sudo chmod -R 755 /var/www

Step 3: Create pages inside your Virtual Host

vi /var/www/website1.com/public_html/index.html

Create test html content (this is just a test)

<html>
<h1>Success! The website1.com virtual host is working!</h1>
</html>

Repeat Create Step 3 for all your new Virtual Hosts

Step 4: Create New Virtual Host Config Files

sudo mkdir /etc/httpd/sites-available
sudo mkdir /etc/httpd/sites-enabled

Open /etc/httpd/conf/httpd.conf and add below to the end of the file

IncludeOptional sites-enabled/*.conf

Create the First Virtual Host File

sudo vi /etc/httpd/sites-available/website1.com.conf

<VirtualHost *:80>
    ServerName www.website1.com
    ServerAlias website1.com
    DocumentRoot /var/www/website1.com/public_html
    ErrorLog /var/www/website1.com/error.log
    CustomLog /var/www/website1.com/requests.log combined
</VirtualHost>

Copy First Virtual Host and Customize for Additional Domains

Step 5: Enable the New Virtual Host Files

Now that we have created our virtual host files, we need to enable them so that Apache knows to serve them to visitors

sudo ln -s /etc/httpd/sites-available/website1.com.conf /etc/httpd/sites-enabled/website1.com.conf

Repeat same for all new virtual domains

When you are finished, restart Apache to make these changes take effect:

sudo apachectl restart

Check your domain now: www.website1.com, you should be good.

Note: If you have .htaccess in your applications, you can eithier use your rewrite/mod rules within each virtual host config or you can check your

/etc/httpd/conf/httpd.conf

Update AllowOverride None to AllowOverride All

 

If it works, let me know …cheers

Psycopg2 requirements install fail: Error: pg_config executable not found (Ubuntu 18.04)

Installing some requirements for my Python App and i kept getting the error from pycopg with error below.

Collecting psycopg2==2.4.5 (from -r requirements.txt (line 13))
Using cached https://files.pythonhosted.org/packages/36/77/894a5dd9f3f55cfc85682d3e6473ee5103d8d418b95baf4019fad3ffa026/psycopg2-2.4.5.tar.gz
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/psycopg2.egg-info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing manifest file ‘pip-egg-info/psycopg2.egg-info/SOURCES.txt’
Error: pg_config executable not found.

Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:

python setup.py build_ext –pg-config /path/to/pg_config build …

or with the pg_config option in ‘setup.cfg’.


Anyway – stackoverflow to the rescue https://stackoverflow.com/questions/11618898/pg-config-executable-not-found

All i had to do was install libpq-dev

sudo apt-get install libpq-dev

I then reinstalled my requirements and whoola! i was good to go

PS: On Fedora, sudo apt-get install postgresql-devel should do the trick

The Future Of Computing And Microchips – NJIT

In the last five decades, the world has witnessed unprecedented advances in computer technology leading to the incorporation of processors in a wide range of appliances including vehicles, electronics, kitchen appliances, and even clothing. In addition, modern smartphones and tablets contain powerful processors that support computationally heavy/complex tasks such as image/video editing. In spite of this, companies including Intel and AMD are investing heavily in research with the aim of producing even smaller microprocessors in the near future.

To learn more, checkout the infographic below created by New Jersey Institute of Technology Online Master of Science in Computer Science degree program.

The Future of Computing and Microchips

NJIT Online

[Updated] Firefox opens every new tab with yahoo search

So i was successful in chasuing yahoo search away and somehow, it resurfaced and this time it was really annoying. I found solace however in this post that said ..

“I’m sorry this happened. There was a bit of a mistake in our 34 release that caused some users who switched back to google to get yahoo again when we updated to 35. We are aware of this and are working on making sure it doesn’t happen again, so please feel free to switch back to google (or whatever search engine you’d like) and continue to update in the future, this shouldn’t happen again in future releases. ”

So the temporary fix now will be  … Bookmark and use this;

Download the Mozilla Search Reset {web link}

This add-on is very simple: on installation, it backs up and then resets your search preferences and home page to their default values, and then uninstalls itself. This affects the search bar, URL bar searches, and the home page.

Hope this works okay for you?

Firefox opens every new tab with yahoo search – really annoying

Tell me you were as frustrated as i was when you open a new tab in Firefox and yahoo search always has to pop up denying you initial access to type your own url. Worst still, you don’t know how on earth this came to be as you have set your General ->Home Page to something else… welcome to the club.

Some people agree it is caused by one or more ad-dons on your browser but which one? or was it after a particular update with yahoo updates/3rd party filter not disabled? Either way you want it out …i get it

Lets go for the killer once and for all… all i did was refresh Firefox to baby new and all was well.

firefox_refresh1. Type about:support in your browser

2. Look for Refresh Firefox and slam the button.

Wait for it to clean itself and return to something you once knew.

NOTE: After my Refresh, I realized most of my addons were flush or plugins deactivated so you just have to re-configure your fresh Firefox to your taste.

 

Reset my admin password (Pydio former ajaxexplorer)

So, i had my Pydio installed and running and somehow i forgot my admin password and just like that the gate is locked. Its  my system right so i was able to login to the db and see the ajxp_users table to see what the user and password format looks like. turns out that my version uses the sha256 (sha256:1000:[long string]:[another long string]) password format…question remains how do i reset this password?

checking through google, some pydio answers says setting the password using the md5 default works….e.g like

UPDATE ajxp_users
SET password = MD5('1234567')
WHERE login ='<admin user>'

but i was doubtful since i could see my password using the sha256?

Here is what i had to do eventually, I thot to myself if i could get a pydio password that i could use to update the db and get a default login and reset later, wouldnt that make sense? and yes it did.

UPDATE ajxp_users SET password = ‘sha256:1000:eIHmmGwo6yhWHijOPDQ+e0+bWEN67br3:OfzGuTwUlBrAyuU5dkltqWRqaOVIPy5G’ WHERE ajxp_users.login = ‘<admin user>’;

yeps … thats the encoded pydio password for P@ssw0rd

After this, i was able to login and reset my pydio password and im allowed to get through the gate.

The new Firefox Preference UI Design..isn’t it cool?

Firefox 38.0.1 tools tabs now on side of window and after i did my upgrade, i was like “It’s about time”. Firefox’s Preferences, until now, have required navigation through a cumbersome floating window but now its a blended web fit into the browser design. I must say pretty surprise and yeps, damn nice..Ive always been a Firefox fan!

But hey for those who don’t really like fast change, here is a way to roll back. You can toggle browser.preferences.inContent to false on the about:config page to restore the standalone Options/Preferences window that you had in previous Firefox versions.

You can open the about:config page via the location/address bar. You can accept the warning and click “I’ll be careful” to continue.

firefox

Funny though, From reviews, some people think its not a good idea, Like its a plan for “One design for all devices” approach by Firefox and maybe Preference will be removed eventually or stripped down.

This is a long awaited design as its been announced way earlier, and the way i see it. The introduction of the Customizer, and the increased UI/UX just helps put Firefox out there for techy and non-tech users.

Whats your take?

your Domain “www”, should it be A Record or CNAME

It’s no news by now that you know that your domain which is e.g domain.com is always attached with the “www” as this has become a standard way for people to access the url via the browser.

For newbies to DNS, All of a sudden, you discover there is a difference the day your domain is working and your www.domain.com doesnt work and then the quest for understanding and fix starts.

So lets talk about what makes all this happen in the DNS realm. DNS which stands for Domain Name System is like the Internet’s library of IPs.

A, CNAME, ALIAS and URL records are all possible solutions to point a host name (name hereafter) to your site. However, they have some small differences that affect how the client will reach your site.

Here’s the main differences: Continue reading “your Domain “www”, should it be A Record or CNAME”

WHM 11.48.0 (build 8) Upgrade + cphulk Add IP List error

So, my VPS did an auto upgrade and my CpHULK went on vacation? Ok not on a vacation to Asia but i had problems viewing the my Whitelist, Blacklist and even adding new IPs.

After a little troubleshooting, i realized that while the cphulk had upgraded itself in the WHM, it doesnt seem like the database has been updated.

That being said, I also noticed that mysql was down somehow/somewhere during the upgrade.

Anyways, to fix your cphulk issues after the WHM 11.48 Upgrade
Continue reading “WHM 11.48.0 (build 8) Upgrade + cphulk Add IP List error”