Are you struggling to manage multiple PHP projects or frameworks running on different PHP versions? You’re not alone! But worry no more — I’ve got the perfect solution for you.
Let me introduce Local by WP Engine, a powerful and free development tool designed primarily for WordPress but versatile enough to support any PHP project or framework. Today, I’ll show you how to use Local to run not just WordPress sites but also raw PHP applications and frameworks like Laravel, all in a step-by-step guide.
Ready to simplify your development process? Let’s dive in!
Download and Install Local
- Visit https://localwp.com to download Local.
- Install it on your machine and open the application.
Create a WordPress Site
- Open Local and click the “+” icon or the “Create a New Site” button to start a new site.
- Enter a name for your site (e.g., “MyWordPressSite”) and click “Continue.”
- Choose an environment: select Preferred for recommended settings or Custom to specify the PHP version, web server type (Apache or Nginx), and MySQL version.
- Set up WordPress admin credentials by entering your admin username, password, and email address. Enable the “Multisite” option if needed.
- Click “Add Site” and wait for Local to create the site, download WordPress core files, and set up the database.
- Once the site is ready, click “Start Site” to run it, and click “Open Site” to view it in your browser. Use “Admin” to access the WordPress dashboard.
Locate the Root Directory
- In the Local application, click the “Site Folder” button for your project.
- Open the
app/public
directory — this is your project’s root directory.
Set Up a Laravel Application
- Delete all files inside the
app/public
directory. - Copy your Laravel project files into this directory.
- Open the
.env
file in your Laravel project and update the database credentials with values from Local's database tab: host, username, password, and port.
Configure the Server
For Apache
- Create a
.htaccess
file in theapp/public
directory. - Add the following code:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /public/$1
#RewriteRule ^ index.php [L]
RewriteRule ^(/)?$ public/index.php [L]
</IfModule>
For Nginx
- Open the
/conf/nginx/site.conf.hbs
file from the project directory. - Replace the
root
directive:
# Old
root "{{root}}";
# New
root "{{root}}/public";
- Restart Local to apply changes.
Start Your Application
- Start the application from Local.
- Visit the project URL to verify everything is working correctly.
Conclusion
With Local, you can easily manage multi-version PHP applications, including raw PHP, Laravel, and more. It’s simple, efficient, and free. Download Local from https://localwp.com and simplify your PHP development today!
Have any questions or tips you’d like to add?
Feel free to drop them in the comments below!
Thanks for taking the time to read my article!
— Sagor
Top comments (1)
If there is a php setup solution that doesn't comply with the php evolution it is Wordpress. It has php 7.4 as a minimum requirement. This version is two years out of date.
So please, don't rely on a developer solution that has backwards requirements.