Bigger, Better, Faster, Stronger?

Were back! and were faster than ever, well over 140% faster to be precise, out with Xampp on windows, in with Ubuntu Webmin!

Wait… Webmin isn’t that taboo? Well, yes, it is but its got loads of features and is really easy to do otherwise time consuming tasks that could take minutes and turn that into a couple of seconds, for example, adding a virtual host to apache2 would require FTP and a bit of nifty .txt editing, but with webmin, its a couple of clicks away, practical in the long run, but it does have it’s drawbacks.

Webmin with Bootstrap 3 theme.

 

Plus webmin is easy to use and quick to configure, so Ill be doing a couple tutorials on that soon enough!

Raspberry Pi – PHP permission File Problems Solved!

I recently installed php, but when I was unable to save files, I was very stuck, and that’s why I’m posting it here, I want to tell anyone who Googles this problem to find this solution.

 

The problem was when I used an fopen and fsave within php, the file would always ‘die’ as in the open or die within php. The solution is below

Firstly I looked for the Environment user in phpinfo() in my case it was
[box type=”shadow”]www-data[/box]
and then I simply typed this
[box type=”shadow”]chmod 777 -R www-data /var/www[/box]
that, in its simplicity is the solution, but I am thankful that I have found the solution!

To create a phpinfo you need to create a file in your root and insert the following code

and save it as phpinfo.php or whatever you choose, I saved it in my root but you can save it wherever you want, then I browsed to the environments section and that gave me the necessary information for me to create the solution.

Why this works

The problem was that php did not have enough permissions to write to the folder. by giving the user www-data full permission i.e. 777 it can now read write and execute without a problem!

here is what php looks like when you do phpinfo

phpinfo() user sample on Raspberry Pi
phpinfo() user sample on Raspberry Pi

you can check a file exits and is editable with this code http://stackoverflow.com/a/13297218

Now you’ve finished you can celebrate! here is a song (this is mainly so i can test embedding :P)

Adding Hosts to Godaddy

GoDaddy is a great Domain Registrar,  I have GoDaddy as my Domain Registrar.

When using domains and Subdomains you may want to have multiple websites on the same server, here is how to add hosts to your GoDaddy account.

 

First Browse to Godaddy and Login, It may be slightly different for you as I live in the UK.

First Click on My Account, then Visit My Account… You should see this page, Expand Domains.

Godaddy Main

On the domain you would like to Add a Host to, Click Launch. You should See this Page….

Godaddy Main 2

Please note some of my sensitive information has been removed…

To add a subdomain Click Host Names (Manage) In there click Add Hostname. The Hostname will be the Subdomain Name, The IP address will be the IP address of the web server(Or Application Server). Then Click Add.

Please note that it can take up to 48 Hours for a DNS Host to update through the Internet.

To Set the Domain Record, Click DNS Zone File, Click Add Record, Select A (Host), Enter the Host that will be the Domain or Subdomain, such as www (By Default this is already configured, so click edit rather than add record.) Then Click Points to, The IP address will be the IP address of the web server(Or Application Server), Then set The Time To Live (TTL), If you are unsure what to do, leave it as default. Then Click Add.

Please note that it can take up to 48 Hours for a DNS Host to update through the Internet.

 

You have now configured a new host!

 

If you want to add another, repeat the process.

Adding Virtual Domains to Apache

Virtual Hosts are great for servers, it allows you to have multiple domains, Subdomains and Users all use the same Web Host (Server) and Is easy to configure.

 

First Please make sure your server is configured to use Virtual Hosts, See Here , Please note this is fundamental

 

Now you have your domain on a Virtual host you can now add others, But you need to add your Host to your DNS zone file from your domain regestrar, See Here

 

 

Now you are ready browse to your Apache installation folder and go to httpd-vhosts.conf

[box type=”shadow”]apacheconfextrahttpd-vhosts.conf[/box]

 

and add the extra hosts you setup in your Domain Registrars DNS Host Names like so,

(be sure to replace ‘dds’ with your subdomain)

Make sure this is at the end of your file, after your root of the domain, make sure you have configured the subdomain folder and the DNS Host names

Be aware that It can take up to 48 hours for Host Records to update through the internet!

How to Configure Apache to use Virtual Hosts

Using Apache is Good, but for one website is limiting its potential you can create multiple websites, domains and sub-domains with Apache, see below.

 

 

First you need to stop your server, you can do this on lunix by entering
[box type=”shadow”] $ sudo /etc/init.d/apache2 stop [/box]

into your terminal, this allows you to make changes to files in your server without breaking it, for windows you need to stop Apache using Xammp, see below.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Now Enable Mod_log_config browse here

[box type=”shadow”]xamppapacheconf[/box]

and in httpd.conf remove the # from this line

[box type=”shadow”]#LoadModule log_config_module modules/mod_log_config.so[/box]

to look like this

[box type=”shadow”]LoadModule log_config_module modules/mod_log_config.so[/box]

 

next using an FTP program or other method, go to your website’s root directory such as

[box type=”shadow”]/home/*/public_html/cgi-bin/[/box]

 

Or for windows

[box type=”shadow”]C:xampphtdocs[/box]

This is the base of your web server, and probably where your Index.html is located, create two folders, Domains and Subdomains, this is where your domains will be stored. See below

Domains, Subdomains

 

 

 

 

 

 

 

In Domains, Place the dome of your website, replacing dots with hyphens like so

Domains, if

 

 

 

(Also add any other websites that you plan to host on the server)

Then copy the data that was in your root of the server into the domain folder on the server like this

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

then paste  into your domain folder like this

 

Paste

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

So your Server should now have the ‘root’ of the server in

[box type=”shadow”]WEBROOTDomainsinfinityflame-co-ukindex.html[/box]

or subsequent folders in Linux.

now you need to redirect traffic from your website to the correct folder, this is done with virtual Hosts’s, and is also how you add sub domains see below

browse to your Apache installation folder and go to httpd-vhosts.conf

[box type=”shadow”]apacheconfextrahttpd-vhosts.conf[/box]

 

and at the bottom add the following code replaceing my domain, with yours.

now test the website, start Apache and browse to your domain, you should see your site as you did before, you have now configured your website to use Virtual Hosts

now you need to add other domains and subdomains, See Here

Xampp and Apache

I recently played around with Apache and fond it incredibly educational.

I used Apache for multiple websites and sub-domains, and its a great web server. and I like Xampp’s user Interface, allowing me to edit, configure and Error check my site.

Xampp Control Panel
Xampp’s user interface, server side

 

Don’t get me wrong though, there are some downfalls when putting it through its paces using Owncloud I discovered that php supported was only allowing 2GB uploads, because it is 32Bit, I later discovered that Xampp is only 32Bit for Windows. This was a major disappointment for me, but I still found workarounds.

Apache is great and easy to use with Xampp, I recommend that anyone wanting to get into web servers and general Web hosting try it out first. I hosted it on my Windows Server, But using a server is completely unnecessary, I was also able to run it on my Laptop.

 

For a test Environment or to start out on Web Servers, I recommend Xampp. Its a trade up over usability and performance on Windows.