#TSA_tech # setting up a local version of Wordpress on Tumbleweed in 500 easy steps
For a better development experience I needed to set up Wordpress locally on my Tumbleweed machine, which was somewhat different than the Ubuntu that I brought the site from. It wasn't really 500 steps, but does have some gotchas and require some time to get right.
## Prerequisites
- Have a version of the WordPress site running somewhere on server that you can access. You need a mysqldump of its db and a copy of its complete file structure.
- `mysqldump -h host_if_not_local -P 3360 -uwordpressuser -p X > ~/X.sql`
- the port `-P` is whatever port it as served from, if not local and not default
- You will be prompted for the password of the user, which is the password from the wp-config of the site
- Have Apache, PHP, and MySQL or MariaDB running locally. You can find these in the repo with `sudo zypper search lamp`, which will show you the `lamp_server` pattern that you want. Install that.
## Install the site
1. Locate the base place that you are serving locally. Mine defaulted to `/srv/www/htdocs/`.
2. Source the database into your mysql, replacing X below with the name you want for your database.
1. `cd` to the directory with `thingyoudumped.sql`
2. log into the local db with `sql`. I had to be root to log in with the privileges I needed, so I started with `sudo -i`
3. create the db and create everything you need to fill, and the priveleges Wordpress will need. `CREATE USER 'X'@'localhost' IDENTIFIED BY 'X'; CREATE DATABASE X; GRANT ALL PRIVILEGES ON X.* to 'X';`
- Note the `@'localhost'`. In modern mysql, the old `@'*'` means everything EXCEPT localhost, so you won't work with the star.
4. from the mysql prompt, `/use X` and then run `source thingyoudumped.sql` and watch it bring in all the stuff you need
3. Copy your Wordpress directory, which should be the directory containing wp-config.php, into the served place, such as `/srv/www/htdocs/`.
4. Make sure the following lines are present in your wp-config.php, where X is the name of the actual directory containing the wp-config file:
define('WP_HOME','http://localhost/X');
define('WP_SITEURL','http://localhost/X');
Note the absence of `/` at the end of those http addresses. With a `/` at the end, I spent a while debugging why I was simply being routed to my base localhost directory and not the Wordpress site.
You will also need to make sure that wp-config contains working database credentials for the db you just created in step 2.3, unless you just copied the same credentials as the site had before.
## Making apache happy with .htaccess
In the same folder as your wp-config you should find a .htaccess file for the apache config that WordPress requires to make things work. It should contain something like this. My actual file had a massive section before this for WP-Rocket, but this is what is necessary.
` <IfModule mod_rewrite.c>`
` RewriteEngine On`
` RewriteBase /X/`
` RewriteRule ^index\.php$ - [L]`
` RewriteCond %{REQUEST_FILENAME} !-f`
` RewriteCond %{REQUEST_FILENAME} !-d`
` RewriteRule . /X/index.php [L]`
` </IfModule>`
## configuring apache itself with default.conf
This was the biggest difference from installing locally on Ubuntu. Apache on Tumbleweed uses a different directory structure. It doesn't have the `sites-enabled` or `sites-avalailable` directories, or the `a2ensite` family of helpers. Instead, the single location I need was `/etc/apache2/default-server.conf`, which I needed to adjust to respect the htaccess of our target directory. It had a bunch of other stuff in the file, but the following is the important part for WordPress:
` DocumentRoot "/srv/www/htdocs"`
` <Directory "/srv/www/htdocs">`
` Options All`
` AllowOverride All`
` <IfModule !mod_access_compat.c>`
` Require all granted`
` </IfModule>`
` <IfModule mod_access_compat.c>`
` Order allow,deny`
` Allow from all`
` </IfModule>`
` </Directory>`
` `
` <IfModule mod_userdir.c>`
` UserDir public_html`
` Include /etc/apache2/mod_userdir.conf`
` </IfModule>`
` `
` IncludeOptional /etc/apache2/conf.d/*.conf`
` `
` IncludeOptional /etc/apache2/conf.d/apache2-manual?conf`
` ServerName 127.0.0.1`
``
``
`## Success!`
`After this I was up and running. There might me another step about installing a php accellerator, but I didn't have to do that on this site. It should be available from the repo if you need it.