localhost/blog

http://localhost/blog

Develop and test blog applications locally at localhost/blog before deploying to production. Test themes, plugins, content, and functionality in a safe local environment.

→ Open localhost/blog

Blog Platforms for Local Development

Platform Type Best For
WordPress PHP/MySQL Full-featured CMS
Ghost Node.js Modern publishing
Jekyll Static GitHub Pages blogs
Hugo Static Fast static sites
Custom PHP PHP/MySQL Learning/custom needs

Install WordPress Blog Locally

  1. Download WordPress from wordpress.org
  2. Extract to C:\xampp\htdocs\blog\
  3. Create database "blog_db" in phpMyAdmin
  4. Visit http://localhost/blog
  5. Follow installation wizard
  6. Configure database: localhost, root, (blank password)
  7. Set site title, admin credentials
  8. Complete installation

WordPress Configuration

// wp-config.php define( 'DB_NAME', 'blog_db' ); define( 'DB_USER', 'root' ); define( 'DB_PASSWORD', '' ); define( 'DB_HOST', 'localhost' ); // Change WordPress URL if needed define( 'WP_HOME', 'http://localhost/blog' ); define( 'WP_SITEURL', 'http://localhost/blog' ); // Enable debugging define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true );

Create Custom PHP Blog

<?php // blog/index.php $conn = new PDO('mysql:host=localhost;dbname=blog_db', 'root', ''); // Get all posts $stmt = $conn->query('SELECT * FROM posts ORDER BY created_at DESC'); $posts = $stmt->fetchAll(PDO::FETCH_ASSOC); ?> <!DOCTYPE html> <html> <head> <title>My Blog</title> <link rel="stylesheet" href="style.css"> </head> <body> <header> <h1>My Blog</h1> </header> <main> <?php foreach ($posts as $post): ?> <article> <h2><a href="post.php?id=<?= $post['id'] ?>"><?= htmlspecialchars($post['title']) ?></a></h2> <p class="meta">Posted on <?= date('F j, Y', strtotime($post['created_at'])) ?></p> <p><?= nl2br(htmlspecialchars(substr($post['content'], 0, 200))) ?>...</p> <a href="post.php?id=<?= $post['id'] ?>">Read more</a> </article> <?php endforeach; ?> </main> </body> </html> // blog/post.php <?php $conn = new PDO('mysql:host=localhost;dbname=blog_db', 'root', ''); $id = intval($_GET['id']); $stmt = $conn->prepare('SELECT * FROM posts WHERE id = ?'); $stmt->execute([$id]); $post = $stmt->fetch(PDO::FETCH_ASSOC); ?> <!DOCTYPE html> <html> <head> <title><?= htmlspecialchars($post['title']) ?></title> </head> <body> <article> <h1><?= htmlspecialchars($post['title']) ?></h1> <p class="meta">Posted on <?= date('F j, Y', strtotime($post['created_at'])) ?></p> <div><?= nl2br(htmlspecialchars($post['content'])) ?></div> </article> <a href="index.php">Back to blog</a> </body> </html> // Database structure CREATE TABLE posts ( id INT PRIMARY KEY AUTO_INCREMENT, title VARCHAR(255) NOT NULL, content TEXT NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP );

Fix "localhost/blog Not Found"

# Verify blog directory exists # Windows dir C:\xampp\htdocs\blog # Linux ls -la /var/www/html/blog # Create if missing mkdir C:\xampp\htdocs\blog # Add index file echo "<?php echo 'Blog is working!'; ?>" > C:\xampp\htdocs\blog\index.php # Check Apache is running # XAMPP Control Panel: Apache should be green # Verify URL # Should be: http://localhost/blog (not http://localhost:blog)

Related URLs and Resources