Jump to content

Has anyone installed Processwire on Amazon EC2?


modifiedcontent
 Share

Recommended Posts

Has anyone successfully installed Processwire on an Amazon EC2 instance/virtual server?

Which configuration works; Amazon Linux or one of the other flavors?

How do you get file permissions and the database working?

Which lines in .htaccess cause problems on Amazon AWS? 

What are the pitfalls to watch out for?

Why can't I get it working...?

The first problem I run into is an error message that the installer doesn't have write access and that I should manually rename the 'site-myprofile' folder to 'site'. Attempt to chmod all the files and folders to 777 don't seem to have any effect on that and some files do get written fine.

But I keep ending up with inaccessable pages and fatal server errors. I am not asking you to solve my problem. I am curious what other people's experiences are with this. Can it be done or am I wasting my time?

 

Link to comment
Share on other sites

I'd imagine ProcessWire should run on any Linux derivate available to EC2, but may I ask, why you want specifically EC2? DigitalOcean or Linode do charge similarly and are way easier to setup than aws (with all it's enterpricy setup tools and permission hierarchies and stuff). I always feel people preemtively reach for EC2 even though they don't need all the things which make aws great over other services in the first place.

  • Like 4
Link to comment
Share on other sites

Thanks for the responses.

Ivan Gretsky, I tried Bitnami's demo. It installs basic profile PW. I couldn't FTP into their Amazon instance. I want to be able to install a custom exported PW profile. And Bitnami probably isn't free, is it?

BitPoet, I have done chown'ing the htdocs folder etc., I think. I am able to FTP my files to the folder. My latest attempt was on a Ubuntu instance. That fixed a lot of small issues I had with Amazon Linux, including the site-profile renaming issue. The PW install process now looks completely normal and healthy. I can see the database get created in PHPMyAdmin.

But then after "successful install", when I try to go to the site and admin, I get unparsed code, fatal server errors and page not found etc.

Laravel looks interesting, but again, not free. I have a client who insists on using Amazon EC2, because he has some kind of promo credit. He is clueless about the technical implications. He wants me to make the site static html or "host it on Shopify" if I can't get it to work.

LostKobrakai, I don't want to host on Amazon EC2. Any regular shared web hosting would do fine for this purpose. But my client thinks "cloud" - waving fingers... - is magic and that using Amazon AWS makes him a tech visionary.

What makes installing Processwire on Amazon EC2 so hard? Why would I need other services like Bitnami or Laravel to make it work?

Is Nginx an Apache alternative? I thought you could install Nginx on Apache? Or is it one or the other? I came across Nginx installing LAMP on Ubuntu on Amazon EC2. Confused if I should install it or not.

Quote

I'd imagine ProcessWire should run on any Linux derivate available to EC2

So far in my experience it doesn't. Has anyone done it? On a regular Amazon EC2 instance, without any third party helpers or weird work-arounds?

Link to comment
Share on other sites

Apache and Nginx are both individual webservers, but only apache is supported officially by processwire. 

EC2 is from a plain server pov not different to other virtual server providers, but aws does have a lot of privacy / access rulings around all it's services, which is (or at least can be) super complicated for simple setups. That's why I think one should only use aws if one does need aws. I'm not sure how much knowledge you have about setting up your own servers, but if you're not quite comfortable with it I'd suggest you not doing it for any production work. 

If a simple shared hosting would be enough I'd charge the client a good amount extra for the hoops of setting up a virtual server in the first place. It's not only the time spent, but also the responsibility coming with setting up anything on your own. 

If you still want to roll with it I'd suggest you the tutorials over at digital ocean (initial setup / lamp setup) and using ubuntu. Ubuntu is the most used system out there and the digital ocean tutorials are quite well written and not really dedicated to their service per se. 

And just a suggestion about your "cloud loving" client. You might take a look a PaaS like heroku, which is as cloudy (in terms of scalablity/on-demand hosting) as aws, but a lot simpler to setup. 

  • Like 3
Link to comment
Share on other sites

Quote

aws does have a lot of privacy / access rulings around all it's services, which is (or at least can be) super complicated for simple setups

I suspect access rules and file permissions etc. is what is messing up the PW install, but what exactly? How to fix it? Has anyone done it?

There is a bunch of stuff in the .htaccess file that may or may not cause server errors on cloud hosting. I tried commenting lines out and in, but there could be endless combinations of possible changes.

Quote

And just a suggestion about your "cloud loving" client ...

He has some kind of credit on Amazon AWS that he doesn't want to let "go to waste". If I can't make it work on Amazon EC2, he wants me to make a static html site or "host it on Shopify", because "that is a CMS as well". He refuses to consider any other type of hosting.

I am kinda stuck in this job at the moment...

Link to comment
Share on other sites

1 hour ago, modifiedcontent said:

I suspect access rules and file permissions etc. is what is messing up the PW install, but what exactly? How to fix it? Has anyone done it?

There is a bunch of stuff in the .htaccess file that may or may not cause server errors on cloud hosting. I tried commenting lines out and in, but there could be endless combinations of possible changes.

If you can reach your server at it's certainly not what I'm talking about. Also there are only a few rules in .htaccess, which you should consider when debugging issues with pages not reachable. Everything else in there is either not to be touched or only for specific features like for example https redirects or www. redirects. The 95% trouble maker in the .htaccess is the RewriteBase, because it's different depending on the actual apache setup on the server and if you're using subdirectories or not.

2 hours ago, modifiedcontent said:

, when I try to go to the site and admin, I get unparsed code, fatal server errors and page not found etc.

Could you be more specific? Those 3 issues would be caused by different issues in your setup.

  • Like 1
Link to comment
Share on other sites

@ Sérgio, I am not going to host Wordpress - cough, spit. I have seen those tutorials. I know how to install a LAMP server on Amazon EC2, to the point where I can go through the installation procedure of any PHP script without problems, including Processwire.

But the result is fatal server errors and pages that can't be found. So my question was very specific; has anyone successfully installed Processwire on AWS?

@ LostKobrakai, you'd 'imagine ProcessWire should run on any Linux derivate available to EC2'. Have you done it? Do you know anyone who has?

I will try one more time in an ultra basic/clean Ubuntu on AWS instance and report back with more details on the errors.

Edit:

OK, after a seemingly flawless installation procedure on Ubuntu/Amazon EC2 - 'Use The Site!' - on View Site I see this in the browser:

Spoiler

compile(\ProcessWire\wire("config")->paths->root . 'site/templates/_head.php',array('includes'=>true,'namespace'=>true,'modules'=>true,'skipIfNamespace'=>true))); ?> compile(\ProcessWire\wire("config")->paths->root . 'site/templates/_nav.php',array('includes'=>true,'namespace'=>true,'modules'=>true,'skipIfNamespace'=>true))); ?>
{$page->body}
" ?>
compile(\ProcessWire\wire("config")->paths->root . 'site/templates/_footer.php',array('includes'=>true,'namespace'=>true,'modules'=>true,'skipIfNamespace'=>true))); ?>

 

Login to Admin gives me a 404 Not Found; 'The requested URL /admin/ was not found on this server'.

When I try the homepage again after restarting Apache, I get this 500 error:

Spoiler

The websitename.com page isn’t working

websitename.com is currently unable to handle this request.
HTTP ERROR 500

 

Any ideas what would cause this?

 

Link to comment
Share on other sites

21 hours ago, modifiedcontent said:

But the result is fatal server errors and pages that can't be found. So my question was very specific; has anyone successfully installed Processwire on AWS?

Yes. And the setup is :

  • Ubuntu 16.04
  • Apache 2.4.18
  • MySQL 10.0.29-MariaDB
  • PHP-7
  • ProcessWire 3.0.52

 

21 hours ago, modifiedcontent said:

Login to Admin gives me a 404 Not Found; 'The requested URL /admin/ was not found on this server'.

add this directive to your VirtualHost in /etc/apache2/sites-available/000-default.conf :

<Directory /var/www/>
     Options Indexes FollowSymLinks
     AllowOverride All
     Require all granted
</Directory>

 

  • Like 2
Link to comment
Share on other sites

Great. Thank you flydev! This at least gives me stuff to try, knowing that it is possible.

After adding that FollowSymLinks section to 000-default.conf, both /admin and the PW homepage give HTTP Error 500. That is kind of progress from the 'not found' I got from /admin earlier.

Using /var/www/html or /var/www/html/ instead of /var/www/ made no difference. Also doing sudo service apache2 restart after these changes doesn't fix the problem.

Should 000-default.conf look like this?

Spoiler

<VirtualHost *:80>
	# The ServerName directive sets the request scheme, hostname and port that
	# the server uses to identify itself. This is used when creating
	# redirection URLs. In the context of virtual hosts, the ServerName
	# specifies what hostname must appear in the request's Host: header to
	# match this virtual host. For the default virtual host (this file) this
	# value is not decisive as it is used as a last resort host regardless.
	# However, you must set it for any further virtual host explicitly.
	#ServerName www.example.com

	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html
	
    <Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
	</Directory>

	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
	# error, crit, alert, emerg.
	# It is also possible to configure the loglevel for particular
	# modules, e.g.
	#LogLevel info ssl:warn

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
	
	# For most configuration files from conf-available/, which are
	# enabled or disabled at a global level, it is possible to
	# include a line for only one particular virtual host. For example the
	# following line enables the CGI configuration for this host only
	# after it has been globally disabled with "a2disconf".
	#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

 

I guess I now have to reinstall the whole thing following your exact setup. :-/

Or is there anything else I could try? Are there error logs anywhere with more clues about the HTTP 500 errors?

MariaDB is an alternative for InnoDB? How would I change/update that, via phpmyadmin or putty? The errors don't look db related though.

Edit:

I only now noticed that the install files were still on the server. I have manually deleted them, but that still hasn't fixed the 500 errors.

What does that mean, that the install files were not automatically removed and the installer did not give any alerts about it? What does the server require to remove the install files? What is missing in my setup?

Edit2:

If I replace Processwire's index.php with a test index.php with some plain text, the browser has no problem displaying it; no server errors.

So there is something in Processwire's index.php that my Ubuntu/AWS installation can't handle. What could that be? PHP is installed. The install process gave no alerts for missing scripts etc.

Edit3:

Trying to remove PW to reinstall, I had to change permissions on three folders/files in /site/assets to be able to delete them. Their ownership was set to a www group, not the default ubuntu user.

I have seen two different instructions to set permissions:

sudo chown -R ubuntu:ubuntu /var/www/html
sudo chmod -R 755 /var/www/html

Or

sudo adduser ubuntu www-data
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R g+rw /var/www/html

Which one should I use? I think I used both, "just to make sure"... For my next attempt I'll try just the first one and for /var/www/, along with that section in 000-default.conf

 

Link to comment
Share on other sites

Try to empty the database and remove the content of /var/www/html then upload a new copy of ProcessWire.

After that give permission to apache:

chown -R www-data:www-data /var/www/html

Now try to reinstall ProcessWire.

If it doesn't work then reinstall the whole thing ;)

 

Sorry for the short answer i am on mobile.

 

 

  • Like 1
Link to comment
Share on other sites

Thank you again flydev!

I now get into processwire's  /admin for the first time on Amazon. After a successful login it shows the following:

Quote
  • Warning: your server locale is undefined and may cause issues. Please add this to /site/config.php file (adjust “en_US.UTF-8” as needed): setlocale(LC_ALL,'en_US.UTF-8');

After adding that the admin area works fine, but the homepage still gives this:

Spoiler

compile(\ProcessWire\wire("config")->paths->root . 'site/templates/_head.php',array('includes'=>true,'namespace'=>true,'modules'=>true,'skipIfNamespace'=>true))); ?> compile(\ProcessWire\wire("config")->paths->root . 'site/templates/_nav.php',array('includes'=>true,'namespace'=>true,'modules'=>true,'skipIfNamespace'=>true))); ?>

{$page->body}

 

" ?>
 

compile(\ProcessWire\wire("config")->paths->root . 'site/templates/_head.php',array('includes'=>true,'namespace'=>true,'modules'=>true,'skipIfNamespace'=>true))); ?> compile(\ProcessWire\wire("config")->paths->root . 'site/templates/_nav.php',array('includes'=>true,'namespace'=>true,'modules'=>true,'skipIfNamespace'=>true))); ?>
{$page->body}
" ?>
compile(\ProcessWire\wire("config")->paths->root . 'site/templates/_footer.php',array('includes'=>true,'namespace'=>true,'modules'=>true,'skipIfNamespace'=>true))); ?>

 

I also had to chown back and forth between ubuntu and www-data to be able to edit files through FTP. Default user ubuntu is supposedly a member of the www-data group, but is still denied editing permission of folders/files owned by www-data.

So PW admin area works great and all front-end pages spit out unparsed crap:

Spoiler

compile(\ProcessWire\wire("config")->paths->root . 'site/templates/_head.php',array('includes'=>true,'namespace'=>true,'modules'=>true,'skipIfNamespace'=>true))); ?> compile(\ProcessWire\wire("config")->paths->root . 'site/templates/_nav.php',array('includes'=>true,'namespace'=>true,'modules'=>true,'skipIfNamespace'=>true))); ?>
children as $child) { echo "
{$child->title}

"; echo "
{$child->headline}

"; echo "
{$child->body}

"; echo "
{$child->video}

"; } ?>
compile(\ProcessWire\wire("config")->paths->root . 'site/templates/_footer.php',array('includes'=>true,'namespace'=>true,'modules'=>true,'skipIfNamespace'=>true))); ?>

 

But no more 500 server errors.

Edit:

After doing this:

sudo chown -R www-data:www-data /var/www
 
Homepage says:
 
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Error has been logged.
 
Admin area is equally effed. Attempt to repair with chown ... /var/www/html or /var/www/html/ have no effect. PW /admin is back to 404 Not Found. Homepage and other pages have 500 internal server errors.
 
Link to comment
Share on other sites

Thanks for the response matjazp.

Nothing interesting in /var/log/apache2/error.log. Only this repeated many times:

Spoiler

[Sun Feb 12 20:47:48.117383 2017] [mpm_prefork:notice] [pid 15493] AH00169: caught SIGTERM, shutting down
[Sun Feb 12 20:47:49.151209 2017] [mpm_prefork:notice] [pid 15761] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Sun Feb 12 20:47:49.151253 2017] [core:notice] [pid 15761] AH00094: Command line: '/usr/sbin/apache2'

 

But that is just me restarting apache2 after changes.

The four step permission settings on that link look interesting. I'll try that.

Reinstalling now. Will report back...

Edit:

After reinstalling from scratch, ended up at the same point: normally working PW /admin, but unparsed crap on the front end.

The four step permission settings were no good, only seemed to make things worse.

Here is the list of commands I have so far:

sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install apache2
sudo apt-get install lamp-server^
sudo apt-get install php7.0-zip
sudo a2enmod rewrite
sudo apt-get install phpmyadmin
sudo ln -s /usr/share/phpmyadmin /var/www/html/
sudo adduser ubuntu www-data
sudo chown ubuntu:www-data -R /var/www
sudo chmod 2775 -R /var/www
sudo find /var/www -type d -exec chmod 2775 {} +
sudo find /var/www -type f -exec chmod 0664 {} +
sudo service apache2 restart
 
I think this sorts out the permission/access issues, but that still hasn't fixed my unparsed front-end pages. What would cause that?

 

Link to comment
Share on other sites

I am trying to install an exported custom profile that I have installed on regular web hosting without problems. I will try another install from scratch with a freshly downloaded Processwire with standard blank profile now.

I had also used 3.0.52 dev. Using 3.0.42 master now. Will report back...

Edit:

Reinstalled, strictly following the list of commands from my previous post, with fresh Processwire + standard blank profile. Everything looked good and normal. Homepage now shows OK - just the word Home - but 'requested URL /admin/ was not found on this server'. WTF?!

  • Like 1
Link to comment
Share on other sites

It works with that directive added. Thanks flydev!

So the formula to install Processwire on Ubuntu on Amazon EC2:

sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install apache2
sudo apt-get install lamp-server^
sudo apt-get install php7.0-zip
sudo a2enmod rewrite
sudo apt-get install phpmyadmin
sudo ln -s /usr/share/phpmyadmin /var/www/html/
sudo adduser ubuntu www-data
sudo chown ubuntu:www-data -R /var/www
sudo chmod 2775 -R /var/www
sudo find /var/www -type d -exec chmod 2775 {} +
sudo find /var/www -type f -exec chmod 0664 {} +
sudo service apache2 restart

Then add this directive to your VirtualHost in /etc/apache2/sites-available/000-default.conf :

<Directory /var/www/>
     Options Indexes FollowSymLinks
     AllowOverride All
     Require all granted
</Directory>

And then it should all work. :)

...still have to see it working with my custom exported profile, but that is my problem. (Edit: that was caused by syntax errors in my custom templates, unsupported use of short_tags.)

 

  • Like 4
Link to comment
Share on other sites

  • 2 months later...

@LostKobrakai I was intrigued by your comment:

On 2/11/2017 at 6:42 AM, LostKobrakai said:

And just a suggestion about your "cloud loving" client. You might take a look a PaaS like heroku, which is as cloudy (in terms of scalablity/on-demand hosting) as aws, but a lot simpler to setup. 

and have been tinkering with PW + git + heroku without having fully RTFM on heroku...

I was weirded-out by my PW install almost working but eventually realized it was due to Heroku’s ephemeral filesystem":

Quote

AWS S3, or similar storage services, are important when architecting applications for scale and are a perfect complement to Heroku’s ephemeral filesystem. #

Actually, to give myself a bit of credit, I think heroku ought really to have written the above more 'honestly'; something like:

> AWS S3, or similar storage services, are important when architecting applications that need any files to persist or for scale and are a perfect complement to Heroku’s ephemeral filesystem. 

Anyway, it looks, ATM, like I need to follow this Amazon-shaped rabbit hole...

Off to do that plus asked their support people if it looks like I am doing the right thing there.

I wonder, if this proves a little complex, might it be as easy/hard to simply emulate a minimal set of the steps PW's own sites have followed and forget heroku  and just go Amazon for all aspects of trying to replace a traditional hosting env' (which is what I am researching)?

  • Like 2
Link to comment
Share on other sites

I'd recommend heroku only if you're using EC2 with multiple instances and not as plain replacement for a single VPS elsewhere (which really has no great benefit to be run on amazon or not). If that's the case one does need to implement some kind of shared filesystem solution, anyways. Same with session storage.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...