How to set up a basic wordpress website?
getgizmo
TRIALOP

2 years ago

I do see there is a template for Wordpress + Mysql, but does this mean that Railway it will create a github repo for me? Will I be able to view it on Github? Im guessing I wont be able to so now im looking into the manual method where it uses my own github repo

Would these be the steps?

  1. Create github repo

  2. Push wordpress to the repo

  3. Make a new railway project, mysql provisional

  4. Get mysql info and update my wordpress' wp-config.php to have that new mysql info

  5. Make a staging branch

  6. Make a new Railway project that deploys from my github repo, and choose my wordpress repo

Im assuming this is wrong…..

127 Replies

getgizmo
TRIALOP

2 years ago

N/A


getgizmo
TRIALOP

2 years ago

Ok wow, just being curious, I did use the wordpress template and it created the site super fast and I can see how it generates the variables, so now I understand more about the templates…..but I am confused as where this project was even deployed? What repo? Do I have access to it? Does it have CI/CD so I can push updates and make branches eg. staging? this is where I feel anxious as I have to do it manually in order to know all of this stuff but seems 10x harder


brody
EMPLOYEE

2 years ago

The template uses a docker image instead of a repo, this is great for getting a basic wordpress site up and running, but it provides no real access to the file structure of wordpress and anything you mentioned in your second message.

So, the steps you gave in your first message are extremely close to the correct steps, let me expand on some and get you the optimal flow.

  1. Create github repo

  2. Push wordpress to the repo

  3. Use environment variables in wp-config.php for database configurations

  4. Use environment variables for any other sensitive information

  5. Make a new Railway project

    5.a. Name the project

  6. In the same project, deploy MySQL

  7. Also in the same project, add a blank service

    7.a. Name the service

    7.b. Generate a domain for it

  8. Add your database variables to the blank service

    8.a. Use variable references the same as the template uses

  9. Add any other variables you need

  10. Attach your GitHub repo

    10.a. Staging or main can be switched at any time

I'd like to mention that it is super unlikely that Railway is going to know what to do with the default Wordpress install.

And something else to keep in mind, when Wordpress is running on Railway it should be treated as a static site, meaning you do all your changes locally only and push them to github, since the filesystem is empherial anything you change on Wordpress when it's hosted will not persist between deployments.


gridonyx
HOBBY

2 years ago

Just wanted to drop in and add my two cents as someone running wordpress on railway, i have persistent data for my site and don't do anything locally then push to the repo


brody
EMPLOYEE

2 years ago

please tell me where I'm wrong grid


gridonyx
HOBBY

2 years ago

You can add a volume mapped to /var/www/html on the wordpress service


gridonyx
HOBBY

2 years ago

1223292836879929600


brody
EMPLOYEE

2 years ago

what if they want to pull the changes made to their wordpress site back down locally?


gridonyx
HOBBY

2 years ago

like theme stuff and site media? you can just use a wordpress backup plugin


gridonyx
HOBBY

2 years ago

i think the built in import/export tool in wordpress might cover that too, but i'd have to double check that one


gridonyx
HOBBY

2 years ago

here's what is in my github repo for it as well

1223293198303236400


brody
EMPLOYEE

2 years ago

gotcha, would my approach also work?


gridonyx
HOBBY

2 years ago

yeah your steps are definitely correct, just the addition of adding the volume to the wordpress service on railway so the data persists


gridonyx
HOBBY

2 years ago

if by "push wordpress to repo" do you mean the entire wordpress.zip file contents?


gridonyx
HOBBY

2 years ago

because dockerfile in the repo would prob be easier, then just pull the docker image


brody
EMPLOYEE

2 years ago

right but that then makes it so they they have to use round-about ways to get data back off of the service


brody
EMPLOYEE

2 years ago

wordpress install + dockerfile


gridonyx
HOBBY

2 years ago

hmm, i guess it depends on what they'll be wanting to do with the service data


gridonyx
HOBBY

2 years ago

for mine, i just take regular backups using the built-in export tool


getgizmo
TRIALOP

2 years ago

wow, thanks for the reply. Ok, about the empherial/persistent comment, is this about where for example…I should not install a wordpress plugin via Wordpress dashboard, but via git push?


brody
EMPLOYEE

2 years ago

in my scenario, yes you would install plugins in your local wordpress project then push to github and then railway would deploy those changes.

in grid's scenario you use a volume and you can install plugins live on the deployment, but then getting your local project in sync with what's on railway is a chore in my opinion.


getgizmo
TRIALOP

2 years ago

Im going to try your steps now @Brody thank you


gridonyx
HOBBY

2 years ago

that's the difference then, i don't do a local environment, I throw the site into "under construction" mode and make changes to prod then bring it back live


gridonyx
HOBBY

2 years ago

for my usecase this works, relatively low traffic site for my landscaping company


gridonyx
HOBBY

2 years ago

brody's way is definitely the way to go if you have a local environment


getgizmo
TRIALOP

2 years ago

"I'd like to mention that it is super unlikely that Railway is going to know what to do with the default Wordpress install."

What does this mean?


brody
EMPLOYEE

2 years ago

Railway would not be able to deploy the default wordpress install, you will need to find a wordpress install that comes with a Dockerfile. Grid, do you have one on hand?


gridonyx
HOBBY

2 years ago

only one that pulls the wordpress docker image, but it can probably be tweaked easily:
```dockerfile
FROM wordpress:latest

COPY ./custom-php.ini /usr/local/etc/php/conf.d/

COPY --from=wordpress:latest /usr/src/wordpress/ /var/www/html/

COPY ./wp-config.php /var/www/html/
COPY ./.htaccess /var/www/html/

ARG MYSQLPASSWORD
ARG MYSQLHOST
ARG MYSQLPORT
ARG MYSQLDATABASE
ARG MYSQLUSER

ARG WPREDISHOST
ARG WPREDISPORT
ARG WPREDISUSER
ARG WPREDISPASSWORD

ARG PORT

ENV WORDPRESSDBHOST=$MYSQLHOST:$MYSQLPORT
ENV WORDPRESSDBNAME=$MYSQLDATABASE
ENV WORDPRESSDBUSER=$MYSQLUSER
ENV WORDPRESSDBPASSWORD=$MYSQLPASSWORD
ENV WORDPRESSTABLEPREFIX="RW_"

ENV WPREDISHOST=$WPREDISHOST
ENV WPREDISPORT=$WPREDISPORT
ENV WPREDISPASSWORD=${WPREDISUSER},$WPREDISPASSWORD

ENV PORT=$PORT

RUN echo "ServerName 0.0.0.0" >> /etc/apache2/apache2.conf

RUN echo "DirectoryIndex index.php index.html" >> /etc/apache2/apache2.conf

CMD ["apache2-foreground"]```


brody
EMPLOYEE

2 years ago

you don't need any of those ARG or ENV lines btw


gridonyx
HOBBY

2 years ago

huh, i'll remove them and see what happens then


brody
EMPLOYEE

2 years ago

well you'd need to properly setup your service variables, but they aren't needed in the dockerfile


brody
EMPLOYEE

2 years ago

you aren't using any environment variables during build so you don't need to reference anything


gridonyx
HOBBY

2 years ago

yeah i've got them all setup in railway on the service as well so it should be fine then


brody
EMPLOYEE

2 years ago

you are re-mapping variables there, you'd need to now do that in the service variables instead


gridonyx
HOBBY

2 years ago

going trial by fire on this one, captain <:peepoCool:526260885929328640>


getgizmo
TRIALOP

2 years ago

sorry, I am slow and not used to PaaS, im only familiar with VPS and I tried vercel before which worked but I cant do wordpress there. I dont understand this docker part being part of my setup. I understand how its used for the templates, like I mentioned in my post and how it can spin up a site quickly, but in my manual way, how do I work this docker file into my steps?


brody
EMPLOYEE

2 years ago

Unfortunately you would need to learn a bit about Dockerfiles to deploy wordpress to railway in the way i described


getgizmo
TRIALOP

2 years ago

I shall do that, but which step in 1-10 involves the docker file?


brody
EMPLOYEE

2 years ago

step 2

Your repo would need to have a Dockerfile at the root of the repo


getgizmo
TRIALOP

2 years ago

thank you!


gridonyx
HOBBY

2 years ago

i'm willing to do a proof of concept on brody's method as well, just gotta finish up some work things


gridonyx
HOBBY

2 years ago

that way if you run into any issues trying this out yourself, i can be of some assistance


brody
EMPLOYEE

2 years ago

thanks grid, i understand it at a high level but i havent deployed wordpress to railway myself


brody
EMPLOYEE

2 years ago

bonus points if you do it with frankenphp


gridonyx
HOBBY

2 years ago

i'll definitely take a stab at it


gridonyx
HOBBY

2 years ago

the redis config definitely is not liking the env change lol


brody
EMPLOYEE

2 years ago

use keydb 🙂


gridonyx
HOBBY

2 years ago

i'm using your dragonfly template right now actually lmao, is keydb better?


gridonyx
HOBBY

2 years ago

<:PepeLaugh:580592928703905792>

1223307558773723100


brody
EMPLOYEE

2 years ago

dragonlyfly is better, it uses more base resources 🙂


gridonyx
HOBBY

2 years ago

so in the dockerfile it had
```dockerfile
ARG WPREDISUSER
ARG WPREDISPASSWORD

ENV WPREDISPASSWORD=${WPREDISUSER},$WPREDISPASSWORD```


gridonyx
HOBBY

2 years ago

on the service variables it was originally set as
WP_REDIS_PASSWORD=${{Dragonfly.DRAGONFLY_PASSWORD}} WP_REDIS_USER=${{Dragonfly.DRAGONFLY_USER}}


brody
EMPLOYEE

2 years ago

wouldnt you want this then?

WP_REDIS_PASSWORD=${{Dragonfly.DRAGONFLY_USER}},${{Dragonfly.DRAGONFLY_PASSWORD}}

gridonyx
HOBBY

2 years ago

now i tried it as both WP_REDIS_PASSWORD=${{Dragonfly.DRAGONFLY_USER}},${{Dragonfly.DRAGONFLY_PASSWORD}} and WP_REDIS_PASSWORD=['${{Dragonfly.DRAGONFLY_USER}}','${{Dragonfly.DRAGONFLY_PASSWORD}}'] and neither of those work


brody
EMPLOYEE

2 years ago

does it render properly?


gridonyx
HOBBY

2 years ago

yeah, checked both and they both looked good


gridonyx
HOBBY

2 years ago

and from the redis wordpress plugin docs:


gridonyx
HOBBY

2 years ago

1223309236717617200


gridonyx
HOBBY

2 years ago

(the only ones necessary in my case are host, password, and port)


brody
EMPLOYEE

2 years ago

where you always using dragonfly?


gridonyx
HOBBY

2 years ago

not for the first handful of months, just added it in like january


brody
EMPLOYEE

2 years ago

did you always use the private network with dragonfly?


gridonyx
HOBBY

2 years ago

not originally, used the public networking before but after making the env changes just now public wasn't working either, so i changed it to private


brody
EMPLOYEE

2 years ago

have you reloaded the plugin?


gridonyx
HOBBY

2 years ago

dragonfly? i have not


brody
EMPLOYEE

2 years ago

no the redis plugin


gridonyx
HOBBY

2 years ago

oh, no i can't access anything on the site haha


gridonyx
HOBBY

2 years ago

but it just pulls from the env vars in wp-config.php


gridonyx
HOBBY

2 years ago

1223311475129712600


brody
EMPLOYEE

2 years ago

dragonfly doesnt do user name auth, can you try -

WP_REDIS_PASSWORD=${{Dragonfly.DRAGONFLY_PASSWORD}}

gridonyx
HOBBY

2 years ago

same error unfortunately


gridonyx
HOBBY

2 years ago

it was working with the user name auth when the dockerfile was doing the remapping which is strange


gridonyx
HOBBY

2 years ago

i'm going to hook up the file browser and delete the /wp-content/object-cache.php file from the volume and see what happens


gridonyx
HOBBY

2 years ago

the filebrowser has shone a light on the issue


gridonyx
HOBBY

2 years ago

wp-config.php from the repo isn't the one getting used, for whatever reason


gridonyx
HOBBY

2 years ago

wp-config.php on the volume has

1223314250341286000


gridonyx
HOBBY

2 years ago

we're in

1223314861853769700


brody
EMPLOYEE

2 years ago

very odd


gridonyx
HOBBY

2 years ago

guess i can remove wp-config.php from my repo then since it's not doing a damn thing lmao


gridonyx
HOBBY

2 years ago

now i can't access wp-admin <:kekw:788259314607325204>


brody
EMPLOYEE

2 years ago

😦


brody
EMPLOYEE

2 years ago

put it all back, dont listen to me


gridonyx
HOBBY

2 years ago

nah this is funny as hell lmao


gridonyx
HOBBY

2 years ago

i'm going to figure this out


gridonyx
HOBBY

2 years ago

to be fair, i could access wp-admin before i removed wp-config.php from the repo and the dockerfile


gridonyx
HOBBY

2 years ago

lets see if it magically works when i bring them back


gridonyx
HOBBY

2 years ago

it did not


gridonyx
HOBBY

2 years ago

i think i've found something…


gridonyx
HOBBY

2 years ago

well this is new

1223318236511207700


gridonyx
HOBBY

2 years ago

it's trying to go to install.php for some reason


brody
EMPLOYEE

2 years ago

this broken broken now


gridonyx
HOBBY

2 years ago

it's like it's not reading the database properly


gridonyx
HOBBY

2 years ago

because looking inside the options table, the rewrite for the admin page is there


gridonyx
HOBBY

2 years ago

1223320477364256800


brody
EMPLOYEE

2 years ago

are you using the correct variable names?


gridonyx
HOBBY

2 years ago

yeah, just double checked those


gridonyx
HOBBY

2 years ago

i'd also be getting a 500 status on the main page though if it wasn't able to connect


gridonyx
HOBBY

2 years ago

mariadb logs are angry a bit


gridonyx
HOBBY

2 years ago

1223321211745075200


gridonyx
HOBBY

2 years ago

looks completely fine in dbgate though


brody
EMPLOYEE

2 years ago

I've heard that before 😉


gridonyx
HOBBY

2 years ago

whatever do you mean <:PepeLaugh:580592928703905792>


brody
EMPLOYEE

2 years ago

quadruple check them


gridonyx
HOBBY

2 years ago

all checks out to me

1223322338578141400
1223322338897039400


brody
EMPLOYEE

2 years ago

it does look fine there


gridonyx
HOBBY

2 years ago

i'm going to try public networking for mariadb instead and see what happens


gridonyx
HOBBY

2 years ago

meh, no luck still


gridonyx
HOBBY

2 years ago

very strange <:Hmmge:916388031970308166>


brody
EMPLOYEE

2 years ago

what did you break so badly


gridonyx
HOBBY

2 years ago

who would have thought deleting wp-config.php that wasn't even getting used from the repo would cause such an issue


gridonyx
HOBBY

2 years ago

time to link the filebrowser back up and compare the current wp-config.php to the one that was there before removing wp-config.php from the repo and see if there is some difference


gridonyx
HOBBY

2 years ago

okay so it isn't that lol

1223325417679618000


gridonyx
HOBBY

2 years ago

hey, at least the frontend works still <:kekw:788259314607325204>


brody
EMPLOYEE

2 years ago

lol


gridonyx
HOBBY

2 years ago

i've had an epiphany on something, stay tuned


gridonyx
HOBBY

2 years ago

it is working now


brody
EMPLOYEE

2 years ago

do tell


gridonyx
HOBBY

2 years ago

it was the object cache all along


brody
EMPLOYEE

2 years ago

what was the fix?


gridonyx
HOBBY

2 years ago

wiped volume on dragonfly and redeployed it and purged cloudflare cache


brody
EMPLOYEE

2 years ago

lmao that sure is a fix


gridonyx
HOBBY

2 years ago

i was talking to my wife and had to stop mid conversation and run off


gridonyx
HOBBY

2 years ago

exact words "i will be back in 5 minutes or less, i've had an epiphany on something"


gridonyx
HOBBY

2 years ago

it has been 18 minutes instead, but i took a break while deploys were happening to make her coffee so we're all clear


gridonyx
HOBBY

2 years ago

<:peepocool:616741504542703646>


brody
EMPLOYEE

2 years ago

pog


gridonyx
HOBBY

2 years ago

now time to switch mariadb back to private networking lol


Loading...