2

I intend to learn and develop a website using WordPress and PHP. I read from the web that as a start, these two are sufficient for a typical website with database storage and retrieval/query functionality.

Is there a way to test, and develop the website without purchasing a domain, but have access to all WordPress plugins and themes so that I can practice how to program it and test as a user to the website that it works as designed?

Only till I have fully tested the website, then I will purchase a domain to host the website.

I read from the webpage, it mentioned the XAMPP application can meet this requirement. Is this true? I am completely new to website development.

1
  • Assuming you are on Windows, just use the hosts file and add some fake domains to it like 127.0.0.1[tab]site1.dev[enter]127.0.0.1[tab]site2.dev. This way you have actual dev domains and don't have to work with any relative paths or directories.
    – CodeAngry
    Commented Mar 7, 2021 at 2:33

5 Answers 5

4

This is quite doable. XAMPP should work fine for this. The biggest gotchas will be converting any code that does not use relative addressing to work with a domain and HTTPS.

You can likely get closer to your goal by using the hosts file on your computer to create a domain name (but only have it work on computers with a modified hosts file)

WordPress is a good tool for web design as its got lots of users and plugins (and uses a MySQL database for its back end) but if the goal is to create a website that directly uses a MySQL database WordPress is not a great fit as it largely abstracts the database a way. (I would not write my own CMS or accounting system with it for example.)

6
  • thank you davidgo for the reply, I will use XAMPP to design , develop and test my 1st website then, and I will find out more about "use relative addressing to work with a domain and https" and try to use "relative addressing" as much as I could in the coding. Commented Mar 6, 2021 at 5:47
  • @raymondraymond1 Relative addressing means specifying URL's in the form "/this/is/my_url.php" rather then "http: //example.com/this/is/my/url". In the latter case the web browser will know its relative to the site, in the latter case it specifies the URL. This is important here because you want things to "just work" when you change the URL. It also will help with getting your site https ready as you won't need to find all the instances of http and change them to https (although Wordpress has ways to help with this)
    – davidgo
    Commented Mar 6, 2021 at 7:44
  • Thank you davidgo, I got it, don't specify domain name in url make it relative to default domain Commented Mar 6, 2021 at 8:05
  • 1
    @raymondraymond1 Im not sure. Were it wordpress specific maybe wordpress.stackexchange - but if its php+mysql no idea. I believe this is a forum for webmasters - ie people more interested in running websites, doing seo and weirdly handling email - ie its aimed at professionals.
    – davidgo
    Commented Mar 6, 2021 at 8:32
  • 2
    I think this question is fine here. General methods for developing a website in a staging environment are certainly part of webmastering. Commented Mar 6, 2021 at 9:08
2

Absolutely. For doing everything on your computer (or locally), I recommend Local by Flywheel. While the other answers (XAMPP, Docker) work great, I think Local by Flywheel greatly simplifies the process of setting up a local environment much better. It sets up a WordPress site with a domain name that can only be accessed thru the computer it is installed in.

Some web hosts will also set up sites for you using their own domain names so you don't need to use your own. Kinsta and Cloudways (from my experience) do this and am sure there's more. You'd have to pay them for hosting tho.

1
  • Many thanks to forlogos, I am overwhelmed by so many possible solutions (never thought that there could be more than one solution), I will have to slowly digest each and every solution suggested, try it out, and choose the easiest solution to start on, since my objective is just to develop and test my 1st website before porting it to an actual domain name host. Thank you everyone. Commented Mar 6, 2021 at 16:19
2

It is quite trivial do do so. The simplest way is just to pretend you have a domain by adding it to your internal network. If you only develop on one computer, then just change the hosts (/etc/hosts on Unix) file to point a name to your local computer's IP address (Done this dozens of time, it is that simple!)

Then you just develop normally using the name you placed in the hosts file. Eventually, you will have to migrate the resulting site to the final domain because WordPress stores most links as absolute. There are processes to do this but mostly it involves search-and-replace of the domain name used during development for the official domain name when you have one. So, it is best have a name that won't be confused for other content in the WP database, not something like test but more like coolundecidedname.

There are only a few cases when I found this not to work for automated installation of plugins but you save it in the right place after you download it yourself.

1

You can also use WordPress in Docker for a quick local setup, or to use on a container-based environment, like Netlify who are free for small projects. Here is a feature about using WordPress on Netlify: https://www.netlify.com/with/wordpress/

Using a docker-compose.yml based on the quickstart instructions, you can install and connect two local servers, an Apache webserver with PHP and WordPress, and a MySQL database server, all by running docker-compose up.

Then you can use your local WordPress setup in your browser on http://localhost.

If you want to test older WordPress versions, you can change image: 'wordpress:latest' and replace latest with one of the docker images available on docker hub, like image: 'wordpress:4.8-php7.0-apache'.

The following example is a local docker-compose setup I used to develop a WordPress plugin, so I have added another docker volume for my plugin folder.

 
version: '3.3'
services:
  db:
    container_name: 'local-wordpress-db'
    image: 'mysql:5.7'
    volumes:
      - './data/mysql:/var/lib/mysql'
    ports:
      - '18766:3306'
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress_db
      MYSQL_USER: wordpress_user
      MYSQL_PASSWORD: wordpress_password
  wordpress:
    container_name: 'local-wordpress'
    depends_on:
      - db
    image: 'wordpress:latest'
    # image: 'wordpress:4.8-php7.0-apache'
    ports:
      - '80:80'
    environment:
      WORDPRESS_DB_HOST: 'db:3306'
      WORDPRESS_DB_USER: wordpress_user
      WORDPRESS_DB_PASSWORD: wordpress_password
      WORDPRESS_DB_NAME: wordpress_db
    volumes:
      - "./wordpress:/var/www/html"
      - "./my-plugin-name:/var/www/html/wp-content/plugins"
2
  • Thanks Ingo Steinke for the solution, just want to check with you, WordPress in Docker for a quick "local setup", does it mean, it is creating an environment using my laptop to mimic existence of a host, such that I can test my wordpress programs by creating transactions as a user from my laptop to a host also at my laptop and get the response from the host to the user ? (and that I can use any of WordPress plugins and themes without restriction). Commented Mar 6, 2021 at 15:24
  • Yes, the local docker environment will run a localhost where you can use Wordpress in your browser and access it via localhost (usually on a specific port). I will add my own docker-compose file and try to find out on which official template it might have been based. Commented Mar 6, 2021 at 15:49
0

The simple answer is yes, you can build anything locally and then deploy it when you are ready. As you are new I would suggest having a look at Laragon rather than XAMPP. It is very easy to use and in my view a better set of options and interface than XAMPP.

With Laragon you instantly install WordPress, as many installs as you like and assign it any .test domain and access it in your browser like yoursite.test

1
  • Thanks Holo, I will also try out Laragon, too much for me to digest, thanks, thanks Commented Mar 7, 2021 at 4:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.