R
Railway•8mo ago
gloppitygoo

How to set up a basic wordpress website?

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.....
92 Replies
Percy
Percy•8mo ago
Project ID: N/A
gloppitygoo
gloppitygooOP•8mo ago
N/A 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
Brody•8mo 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
gridonyx•8mo 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
Brody•8mo ago
please tell me where I'm wrong grid
gridonyx
gridonyx•8mo ago
You can add a volume mapped to /var/www/html on the wordpress service
gridonyx
gridonyx•8mo ago
No description
Brody
Brody•8mo ago
what if they want to pull the changes made to their wordpress site back down locally?
gridonyx
gridonyx•8mo ago
like theme stuff and site media? you can just use a wordpress backup plugin i think the built in import/export tool in wordpress might cover that too, but i'd have to double check that one
gridonyx
gridonyx•8mo ago
here's what is in my github repo for it as well
No description
Brody
Brody•8mo ago
gotcha, would my approach also work?
gridonyx
gridonyx•8mo ago
yeah your steps are definitely correct, just the addition of adding the volume to the wordpress service on railway so the data persists if by "push wordpress to repo" do you mean the entire wordpress.zip file contents? because dockerfile in the repo would prob be easier, then just pull the docker image
Brody
Brody•8mo ago
right but that then makes it so they they have to use round-about ways to get data back off of the service wordpress install + dockerfile
gridonyx
gridonyx•8mo ago
hmm, i guess it depends on what they'll be wanting to do with the service data for mine, i just take regular backups using the built-in export tool
gloppitygoo
gloppitygooOP•8mo 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
Brody•8mo 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.
gloppitygoo
gloppitygooOP•8mo ago
Im going to try your steps now @Brody thank you
gridonyx
gridonyx•8mo 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 for my usecase this works, relatively low traffic site for my landscaping company brody's way is definitely the way to go if you have a local environment
gloppitygoo
gloppitygooOP•8mo 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
Brody•8mo 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
gridonyx•8mo ago
only one that pulls the wordpress docker image, but it can probably be tweaked easily:
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 WP_REDIS_HOST
ARG WP_REDIS_PORT
ARG WP_REDIS_USER
ARG WP_REDIS_PASSWORD

ARG PORT

ENV WORDPRESS_DB_HOST=$MYSQLHOST:$MYSQLPORT
ENV WORDPRESS_DB_NAME=$MYSQLDATABASE
ENV WORDPRESS_DB_USER=$MYSQLUSER
ENV WORDPRESS_DB_PASSWORD=$MYSQLPASSWORD
ENV WORDPRESS_TABLE_PREFIX="RW_"

ENV WP_REDIS_HOST=$WP_REDIS_HOST
ENV WP_REDIS_PORT=$WP_REDIS_PORT
ENV WP_REDIS_PASSWORD=${WP_REDIS_USER},$WP_REDIS_PASSWORD

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"]
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 WP_REDIS_HOST
ARG WP_REDIS_PORT
ARG WP_REDIS_USER
ARG WP_REDIS_PASSWORD

ARG PORT

ENV WORDPRESS_DB_HOST=$MYSQLHOST:$MYSQLPORT
ENV WORDPRESS_DB_NAME=$MYSQLDATABASE
ENV WORDPRESS_DB_USER=$MYSQLUSER
ENV WORDPRESS_DB_PASSWORD=$MYSQLPASSWORD
ENV WORDPRESS_TABLE_PREFIX="RW_"

ENV WP_REDIS_HOST=$WP_REDIS_HOST
ENV WP_REDIS_PORT=$WP_REDIS_PORT
ENV WP_REDIS_PASSWORD=${WP_REDIS_USER},$WP_REDIS_PASSWORD

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
Brody•8mo ago
you don't need any of those ARG or ENV lines btw
gridonyx
gridonyx•8mo ago
huh, i'll remove them and see what happens then
Brody
Brody•8mo ago
well you'd need to properly setup your service variables, but they aren't needed in the dockerfile you aren't using any environment variables during build so you don't need to reference anything
gridonyx
gridonyx•8mo ago
yeah i've got them all setup in railway on the service as well so it should be fine then
Brody
Brody•8mo ago
you are re-mapping variables there, you'd need to now do that in the service variables instead
gridonyx
gridonyx•8mo ago
going trial by fire on this one, captain :peepoCool:
gloppitygoo
gloppitygooOP•8mo 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
Brody•8mo ago
Unfortunately you would need to learn a bit about Dockerfiles to deploy wordpress to railway in the way i described
gloppitygoo
gloppitygooOP•8mo ago
I shall do that, but which step in 1-10 involves the docker file?
Brody
Brody•8mo ago
step 2 Your repo would need to have a Dockerfile at the root of the repo
gloppitygoo
gloppitygooOP•8mo ago
thank you!
gridonyx
gridonyx•8mo ago
i'm willing to do a proof of concept on brody's method as well, just gotta finish up some work things that way if you run into any issues trying this out yourself, i can be of some assistance
Brody
Brody•8mo ago
thanks grid, i understand it at a high level but i havent deployed wordpress to railway myself bonus points if you do it with frankenphp
gridonyx
gridonyx•8mo ago
i'll definitely take a stab at it the redis config definitely is not liking the env change lol
Brody
Brody•8mo ago
use keydb 🙂
gridonyx
gridonyx•8mo ago
i'm using your dragonfly template right now actually lmao, is keydb better?
gridonyx
gridonyx•8mo ago
:PepeLaugh:
No description
Brody
Brody•8mo ago
dragonlyfly is better, it uses more base resources 🙂
gridonyx
gridonyx•8mo ago
so in the dockerfile it had
ARG WP_REDIS_USER
ARG WP_REDIS_PASSWORD

ENV WP_REDIS_PASSWORD=${WP_REDIS_USER},$WP_REDIS_PASSWORD
ARG WP_REDIS_USER
ARG WP_REDIS_PASSWORD

ENV WP_REDIS_PASSWORD=${WP_REDIS_USER},$WP_REDIS_PASSWORD
on the service variables it was originally set as
WP_REDIS_PASSWORD=${{Dragonfly.DRAGONFLY_PASSWORD}}
WP_REDIS_USER=${{Dragonfly.DRAGONFLY_USER}}
WP_REDIS_PASSWORD=${{Dragonfly.DRAGONFLY_PASSWORD}}
WP_REDIS_USER=${{Dragonfly.DRAGONFLY_USER}}
Brody
Brody•8mo ago
wouldnt you want this then?
WP_REDIS_PASSWORD=${{Dragonfly.DRAGONFLY_USER}},${{Dragonfly.DRAGONFLY_PASSWORD}}
WP_REDIS_PASSWORD=${{Dragonfly.DRAGONFLY_USER}},${{Dragonfly.DRAGONFLY_PASSWORD}}
gridonyx
gridonyx•8mo ago
now i tried it as both
WP_REDIS_PASSWORD=${{Dragonfly.DRAGONFLY_USER}},${{Dragonfly.DRAGONFLY_PASSWORD}}
WP_REDIS_PASSWORD=${{Dragonfly.DRAGONFLY_USER}},${{Dragonfly.DRAGONFLY_PASSWORD}}
and
WP_REDIS_PASSWORD=['${{Dragonfly.DRAGONFLY_USER}}','${{Dragonfly.DRAGONFLY_PASSWORD}}']
WP_REDIS_PASSWORD=['${{Dragonfly.DRAGONFLY_USER}}','${{Dragonfly.DRAGONFLY_PASSWORD}}']
and neither of those work
Brody
Brody•8mo ago
does it render properly?
gridonyx
gridonyx•8mo ago
yeah, checked both and they both looked good and from the redis wordpress plugin docs:
gridonyx
gridonyx•8mo ago
No description
gridonyx
gridonyx•8mo ago
(the only ones necessary in my case are host, password, and port)
Brody
Brody•8mo ago
where you always using dragonfly?
gridonyx
gridonyx•8mo ago
not for the first handful of months, just added it in like january
Brody
Brody•8mo ago
did you always use the private network with dragonfly?
gridonyx
gridonyx•8mo 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
Brody•8mo ago
have you reloaded the plugin?
gridonyx
gridonyx•8mo ago
dragonfly? i have not
Brody
Brody•8mo ago
no the redis plugin
gridonyx
gridonyx•8mo ago
oh, no i can't access anything on the site haha but it just pulls from the env vars in wp-config.php
gridonyx
gridonyx•8mo ago
No description
Brody
Brody•8mo ago
dragonfly doesnt do user name auth, can you try -
WP_REDIS_PASSWORD=${{Dragonfly.DRAGONFLY_PASSWORD}}
WP_REDIS_PASSWORD=${{Dragonfly.DRAGONFLY_PASSWORD}}
gridonyx
gridonyx•8mo ago
same error unfortunately it was working with the user name auth when the dockerfile was doing the remapping which is strange 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 the filebrowser has shone a light on the issue wp-config.php from the repo isn't the one getting used, for whatever reason
gridonyx
gridonyx•8mo ago
wp-config.php on the volume has
No description
gridonyx
gridonyx•8mo ago
:HACKERMANS: we're in
No description
Brody
Brody•8mo ago
very odd
gridonyx
gridonyx•8mo ago
guess i can remove wp-config.php from my repo then since it's not doing a damn thing lmao now i can't access wp-admin :kekw:
Brody
Brody•8mo ago
😦 put it all back, dont listen to me
gridonyx
gridonyx•8mo ago
nah this is funny as hell lmao i'm going to figure this out to be fair, i could access wp-admin before i removed wp-config.php from the repo and the dockerfile lets see if it magically works when i bring them back it did not :PepeLaugh: i think i've found something...
gridonyx
gridonyx•8mo ago
well this is new
No description
gridonyx
gridonyx•8mo ago
it's trying to go to install.php for some reason
Brody
Brody•8mo ago
this broken broken now
gridonyx
gridonyx•8mo ago
it's like it's not reading the database properly because looking inside the options table, the rewrite for the admin page is there
gridonyx
gridonyx•8mo ago
No description
Brody
Brody•8mo ago
are you using the correct variable names?
gridonyx
gridonyx•8mo ago
yeah, just double checked those i'd also be getting a 500 status on the main page though if it wasn't able to connect mariadb logs are angry a bit
gridonyx
gridonyx•8mo ago
No description
gridonyx
gridonyx•8mo ago
looks completely fine in dbgate though
Brody
Brody•8mo ago
I've heard that before 😉
gridonyx
gridonyx•8mo ago
whatever do you mean :PepeLaugh:
Brody
Brody•8mo ago
quadruple check them
gridonyx
gridonyx•8mo ago
all checks out to me
No description
No description
Brody
Brody•8mo ago
it does look fine there
gridonyx
gridonyx•8mo ago
i'm going to try public networking for mariadb instead and see what happens meh, no luck still very strange :Hmmge:
Brody
Brody•8mo ago
what did you break so badly
gridonyx
gridonyx•8mo ago
who would have thought deleting wp-config.php that wasn't even getting used from the repo would cause such an issue 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
gridonyx•8mo ago
okay so it isn't that lol
No description
gridonyx
gridonyx•8mo ago
hey, at least the frontend works still :kekw:
Brody
Brody•8mo ago
lol
gridonyx
gridonyx•8mo ago
i've had an epiphany on something, stay tuned it is working now
Brody
Brody•8mo ago
do tell
gridonyx
gridonyx•8mo ago
it was the object cache all along
Brody
Brody•8mo ago
what was the fix?
gridonyx
gridonyx•8mo ago
wiped volume on dragonfly and redeployed it and purged cloudflare cache
Brody
Brody•8mo ago
lmao that sure is a fix
gridonyx
gridonyx•8mo ago
i was talking to my wife and had to stop mid conversation and run off exact words "i will be back in 5 minutes or less, i've had an epiphany on something" it has been 18 minutes instead, but i took a break while deploys were happening to make her coffee so we're all clear :peepocool:
Brody
Brody•8mo ago
pog
gridonyx
gridonyx•8mo ago
now time to switch mariadb back to private networking lol
Want results from more Discord servers?
Add your server