mscifo / pressless

[NO LONGER MAINTAINED] A tool that migrates an existing Wordpress site into a fully functioning Serverless site, powered by AWS (Cloudfront, API Gateway, Lambda, S3).
MIT License
80 stars 14 forks source link

Setup Instructions #1

Open djraval opened 6 years ago

djraval commented 6 years ago

I have been trying to setup Pressless on a standard wordpress installation, but couldn't run "setup" command.

Instructions say I need 3 arguments:

  1. Domain - which i preassume should be in a standard format (www.example.com)
  2. Website_Bucket - Going through the code, it also accepts a domain name? So I would create a public S3 bucket and give its root address?
  3. ACM Certificate - This also expects a domain name, but I have no idea how can i get that. Tried giving it its arn instead but didn't work.

here is the command I tried to run: pressless setup djraval.tk s3-ap-southeast-1.amazonaws.com/djraval-static/ -c arn:aws:acm:ap-southeast-1:201826946936:certificate/148e2860-a96e-41ea-bf8f-86064a536f3b

Do guide me over this.

mscifo commented 6 years ago

Hi djraval,

  1. The first argument is the domain you intend to run Pressless on. This will end up being a CNAME record to the AWS API Gateway which executes the Lambda function containing your Wordpress site.

  2. The second argument is the domain that you want to be considered public. You will end up CNAMEing that to S3.

  3. The ACM certificate parameter is the name of the ACM certificate. I see you passed the ARN, but you need to specify the name you gave the certificate when creating/importing it in ACM.

So lets say your existing Wordpress site is hosted on www.myblog.com. This is the setup command you would want to run: pressless setup pressless.myblog.com www.myblog.com -c myblog.com-certname. You also need to pass in option -d mysq://username:password@host:port/database to the previous setup command in order to tell Wordpress where your database is.

pressless.myblog.com could really be any subdomain or other domain you own. After setup, deploy and updating your DNS records, you would be able to visit https://pressless.myblog.com/wp-admin/ to install/login. After that, you can then visit http://www.myblog.com, which is an S3 website bucket. If the initial index.html doesn't yet exist, you'll be redirected to https://pressless.myblog.com (APIG/Lambda), which will get the Wordpress output and store it in S3, and then redirect you to back http://www.myblog.com, which now has the index.html file in S3.

nickbreen commented 6 years ago

I also assumed that the certificate ARN was required, however, I still cannot get it to work by using the 'Name' of the certificate for several reasons/steps.

  1. Created certificate with CloudFormation, no Name tag specified, tried using ARN.
  2. Updated certificate with Name: pressless: error: Pressless: pressless is not a valid certificate name.
  3. Updated certificate with Name: example.com-pressless: error:
    (node:26373) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Error: Could not find the certificate example.com-pressless.
    Pressless:  Error: Error: 'wp.example.com' was not created in API Gateway.
    Error: Error: Could not find the certificate example.com-pressless.
    at createDomainName.catch (/usr/lib/node_modules/pressless/node_modules/serverless-domain-manager/index.js:59:15)
    at process._tickDomainCallback (internal/process/next_tick.js:135:7)

My current hunch is that the issue is that I've created the certificate in ap-southeast-2 and it needs to be in us-east-1. Yep: the certificate must be in us-east-1.

Note: Edge-optimized endpoints require that the certificate be located in us-east-1 to be used with the CloudFront distribution. -- https://www.npmjs.com/package/serverless-domain-manager

ghost commented 6 years ago

How to get started with pressless i cannot figure out anything I have setup IAM installed aws cli but when i run npm install -g pressless nothing works what should i do and how should i start please help me.

marcfielding1 commented 6 years ago

Yeah, I have to say the readme is rubbish lol - I am however very interested in this so I'll install/check it out and do a PR for it.

ghost commented 6 years ago

Sorry for the delay, have yet installed WordPress through pressless

minusreality commented 5 years ago

Create a free public certificate in the region us-east-1 using the AWS service ACM.

YES THE REGION MUST BE "us-east-1" This is due to limitations within API Gateway.

After doing this if you try to run "pressless setup ..." you may get the error:

Pressless: Checking size of "wp-content/uploads"...
Pressless: Size of "wp-content/uploads" is 0.012288 MB
Pressless: Setting up...
/usr/local/lib/node_modules/pressless/bin/pressless:130
PRESSLESS_DB_SSL=${dsn.get('driver').indexOf('+ssl')?'true':'false'}
                       ^

TypeError: Cannot read property 'get' of undefined
    at Command.<anonymous> (/usr/local/lib/node_modules/pressless/bin/pressless:130:24)
    at Command.listener (/usr/local/lib/node_modules/pressless/node_modules/commander/index.js:315:8)
    at Command.emit (events.js:182:13)
    at Command.EventEmitter.emit (domain.js:442:20)
    at Command.parseArgs (/usr/local/lib/node_modules/pressless/node_modules/commander/index.js:654:12)
    at Command.parse (/usr/local/lib/node_modules/pressless/node_modules/commander/index.js:474:21)
    at /usr/local/lib/node_modules/pressless/bin/pressless:910:13
    at /usr/local/lib/node_modules/pressless/node_modules/asciify/index.js:50:3
    at /usr/local/lib/node_modules/pressless/node_modules/asciify/lib/figlet-js/figlet.js:92:4
    at Object._parseFont (/usr/local/lib/node_modules/pressless/node_modules/asciify/lib/figlet-js/figlet.js:44:3)

This is because specifying your DB is actually required even if you also specified it within wp-config.php. The fact that this is required was not immediately obvious. After this I received the following error:

Also note that when the "-c" option calls for the "name" of your certificate, it is referring to the name as listed in AWS ACM. So the name might be "*.yourdomain.com".

Here is an example of a working command:

pressless setup tester.minus-reality.com wordpress.minus-reality.com -c *.minus-reality.com -d mysql://sqluser:sqlpass@dbhostname:3306/dbname