CodeIgniter Forums
CI2 reactor and Amazon EC2 problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: CI2 reactor and Amazon EC2 problem (/thread-40058.html)



CI2 reactor and Amazon EC2 problem - El Forum - 03-28-2011

[eluser]d1a8lo24[/eluser]
Hello everyone, I have a small problem that I hope someone can help.

I have develop a few applications with CI with out any problem using my windows computer as a testing server with WAMP, and I have been able to deploy them in many different share virtual hosting servers from companies like godaddy and others.

I heard of Amazon EC2 but didn't really wanted to tryout since I don't know anything about running a server and even though is cheap to run I still couldn't afford it until now which they are giving free trials for 1 year on micro instances.

Anyway I saw a great tutorial on how to start using Amazon's EC2 so since I had an account for S3 I decided to turn on the feature to use EC2 since it seem very easy to set up.

So I did all the steps require which took me about 1 hour to set up, you have to know I had to do a small crash course on SSH and learning how to connect from my Windows computer and and running commands. Anyway I updated and upgraded the server which I choose an Ubuntu distribution, downloaded and install LAMP and PHPMYADMIN and everything work fine. I was able to get to the server and I was actually able to upload the users guide of CI2 and browse around it with no problem.

So I decided to upload my application and everything work fine it connected to the DB and I was able to see my index page. And here is where the problem starts as soon as I click on a link the server gave me a 404 error page not found.

By the way I do use an htaccess page to remove the index.php from the URL and I have tried many of the variations out there and nothing seems to work to fix this.

I have also tried this known fixes without luck.

Changing the uri_protocol to the different options.
Loading a basic CI2 installation with 1 controller to replicate the link browsing and I still get the same error.

I have also check the configuration of my local server and that of my live servers of the httpd.conf ad php.ini files and I did see some modules not being loaded which I turn them on but I still get the same 404 error.

So if anyone can help or that can guide me I will really appreciated and thanks in advance.


CI2 reactor and Amazon EC2 problem - El Forum - 04-04-2011

[eluser]d1a8lo24[/eluser]
After many days of researching I finally found my solution, one thing is to learn more about Apache if I'm going to be running my own server, second know your server in my case Ubuntu.

Anyway one thing that I figure out was that my mod_rewrite was not working, and I didn't know that Ubuntu and Apache have many places where you can specify what mods can you load and which one of these files have more power over the other.

In my setup there are 3 place where you can specify which mods or configurations can be loaded or set. These are the apache2.conf, httpd.conf and under you sites-enable folder the file that enables a new or default site can also have this configurations.

Well I only knew about the first 2 and after a lot of reading on many forums one guy had the answer and that was to edit under you site-enable folder the site you configure and either add or edit the following.

Code:
<Directory /directory/path>
  AllowOverride all
</Directory>

The AllowOverride all will let Apache read the .htaccess file and apply any configuration. Yep that easy. By the way because Ubuntu and I'm pretty sure that other servers do the same when you install and configure from scratch they have AllowOverride set to none in any of these 3 files.

Do know that if this is set in the sites-enable file changing the configuration in the other 2 will not work you either have to change it in the site-enable file or remove it and set it in either apache2.conf or httpd.conf.

Hope this helps anyone without any experience like me and is having the same problem.


CI2 reactor and Amazon EC2 problem - El Forum - 07-25-2011

[eluser]coldfire82[/eluser]
[quote author="d1a8lo24" date="1301940420"]After many days of researching I finally found my solution, one thing is to learn more about Apache if I'm going to be running my own server, second know your server in my case Ubuntu.

Anyway one thing that I figure out was that my mod_rewrite was not working, and I didn't know that Ubuntu and Apache have many places where you can specify what mods can you load and which one of these files have more power over the other.

In my setup there are 3 place where you can specify which mods or configurations can be loaded or set. These are the apache2.conf, httpd.conf and under you sites-enable folder the file that enables a new or default site can also have this configurations.

Well I only knew about the first 2 and after a lot of reading on many forums one guy had the answer and that was to edit under you site-enable folder the site you configure and either add or edit the following.

Code:
<Directory /directory/path>
  AllowOverride all
</Directory>

The AllowOverride all will let Apache read the .htaccess file and apply any configuration. Yep that easy. By the way because Ubuntu and I'm pretty sure that other servers do the same when you install and configure from scratch they have AllowOverride set to none in any of these 3 files.

Do know that if this is set in the sites-enable file changing the configuration in the other 2 will not work you either have to change it in the site-enable file or remove it and set it in either apache2.conf or httpd.conf.

Hope this helps anyone without any experience like me and is having the same problem.[/quote]

Having the same problem. Working now. Thanks for the help.

There should be a complete guide on "Running CodeIgniter on EC2".


CI2 reactor and Amazon EC2 problem - El Forum - 07-25-2011

[eluser]Mirge[/eluser]
[quote author="coldfire82" date="1311668368"][quote author="d1a8lo24" date="1301940420"]After many days of researching I finally found my solution, one thing is to learn more about Apache if I'm going to be running my own server, second know your server in my case Ubuntu.

Anyway one thing that I figure out was that my mod_rewrite was not working, and I didn't know that Ubuntu and Apache have many places where you can specify what mods can you load and which one of these files have more power over the other.

In my setup there are 3 place where you can specify which mods or configurations can be loaded or set. These are the apache2.conf, httpd.conf and under you sites-enable folder the file that enables a new or default site can also have this configurations.

Well I only knew about the first 2 and after a lot of reading on many forums one guy had the answer and that was to edit under you site-enable folder the site you configure and either add or edit the following.

Code:
<Directory /directory/path>
  AllowOverride all
</Directory>

The AllowOverride all will let Apache read the .htaccess file and apply any configuration. Yep that easy. By the way because Ubuntu and I'm pretty sure that other servers do the same when you install and configure from scratch they have AllowOverride set to none in any of these 3 files.

Do know that if this is set in the sites-enable file changing the configuration in the other 2 will not work you either have to change it in the site-enable file or remove it and set it in either apache2.conf or httpd.conf.

Hope this helps anyone without any experience like me and is having the same problem.[/quote]

Having the same problem. Working now. Thanks for the help.

There should be a complete guide on "Running CodeIgniter on EC2".[/quote]

Write one =)


CI2 reactor and Amazon EC2 problem - El Forum - 07-26-2011

[eluser]coldfire82[/eluser]
[quote author="Mirge" date="1311677006"]
Write one =)[/quote]

Maybe I will. But a quick set of links below will help anyone who wants to setup CI website on EC2.

I have used a free tier EC2 instance and is working fine with CI ver 4.3.2. Below are the exact links I used to make it work from scratch.

Cygwin
A shell client to access unix OS from Windows. I am using winXP (don't hit me a brick Wink). Cygwin is a must have tool.

Getting PHP and MySQL running on Amazon EC2
To setup the whole PHP stuff on EC2. A very good and detailed guide.
http://www.alexkorn.com/blog/2011/03/getting-php-mysql-running-amazon-ec2/
The above guide wants you to create a php sample page in /opt/app/current . I also did the same but later I changed its location to /var/www/html

VIM Commands that will be used to edit httpd.conf file via cygwin
http://www.tuxfiles.org/linuxhelp/vimcheat.html
I only used two
Quote:1) :w //to save file
2) :wq //to save and exit
.

To run the above commands, when you finish editing/inserting stuff in the command version of file, first press ESc and then write the above command.

Installing phpMyAdmin
Then, I followed the complete steps of how to install phpmyadmin. I have not used S3 because I dont need one right now, maybe later. Here is the guide for it, (only follow the one we need here)
http://www.calebogden.com/wordpress-on-linux-in-the-amazon-cloud-with-mac/



Uploading Stuff
Uploading your CI website folder to the /var/www/html directory, I used WinSCP.
http://winscp.net
(Phpmyadmin is also installed at the same home directory)

To use winscp you will need the .ppk file to login as ec2-user, that I created from PuttyGen. The by-default user access is restricted and it only allows the root user to upload/edit files. So, you need to change owner for your directory. Here is the command,
Code:
chown ec2-user /var/www/html
this code will change owner of the directory and assigns the owner as ec2-user (which is our user name). After editing stuff, you can make "root" the owner again.

htaccess
And, now is the last step where I stumbled at htaccess mod rules.

To enable rules in htaccess of your website: goto httpd.conf and add directory tag with the variable "AllowOverride all" in directory of /var/www/html/<yourwebsitefoldername>
it will look like this
Code:
<Directory "/var/www/html/yourwebsitefoldername" >
AllowOverride all
</Directory>

Save and exit.



Thats it.


CI2 reactor and Amazon EC2 problem - El Forum - 07-26-2011

[eluser]Mirge[/eluser]
:cheese: