How to create DO server to host Wordpress and Laravel both and optimize it fully?

I am new to server management and till now I used a free service which installs server with one click for me and also installs wordpress in it. Now I have two problems. They are retiring their free plan and even though I can still use their free plan till I disconnect my server, I want to learn How to optimize DO server for best performance. Second Issue - I want to host Laravel apps as demo for my written tutorials which I will write in my portfolio wordpress blog and also host laravel apps as portfolio projects. But I don’t know how to install laravel as Wordpress is currently installed.

After researching, I got to know that installing composer and creating laravel project in subfolder let’s say should work. But I created my project in localhost and there I had to start the server everytime using “php artisan serve” to run the project. But in live servers how these works I don’t know.

Any tutorial links or help will be appreciated.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


When you’re running php artisan serve, Laravel is using PHP’s built-in web server to serve your site. It’s not a production web server and only meant for local development, which would be why you need to start it each time you close out your terminal.

It’s not meant to be persistent like, for example, NGINX or Apache, and you definitely don’t want rely on that on a production server.

What I would recommend is setting up a LEMP Stack. That’d consist of Linux (Ubuntu), NGINX, PHP, and MariaDB (or MySQL). Ubuntu has existing repositories for each, though there are also multiple alternative repositories, including those maintained by the developers themselves (which is why I use when/where possible).

That said, I actually just released an initial release of some of the installers I use to handle setting up NGINX and PHP (PHP-FPM) which ease the process. The NGINX installer I use compiles NGINX from source and includes multiple configuration examples (including one for PHP) which can be used as a basis for your overall configuration.

You can find that here:

To use the installers, all you need to do is clone the repository to your server using git. Since most don’t have it installed by default, you’ll probably need to run:

apt-get -y install git

Then change over to a directory of your choice for the clone. I generally use /opt, so that’s what I’ll use for this example.

cd /opt
git clone
cd installers

Now you’ll see a few directories – for the purpose of this, we’re only going to focus on nginx and php (you don’t need NodeJS for PHP or Laravel).

So let’s start with NGINX.

cd nginx
chmod +x

That’s all you need to do to install NGINX. That auto-installer will handle a source compile for you and you won’t have to configure anything until it completes (it’ll take a little while – between 15-30 minutes). Even then, the only thing you need to configure is your server blocks for your website. The configuration is already optimized and ready to rock.

Now to install PHP and PHP-FPM (used by NGINX), you can change over to the php directory and choose your preferred PHP version. I normally stick with 7.1, so that’s what I’ll use here.

cd php/7.1
chmod +x

The correct repository will be added and the most common PHP packages will be installed, which should be all you need for your application unless you need very specific packages.

You can check your PHP version by running:

php -v

Inside of the nginx directory, there’s an examples directory and within that, a php directory. That’s the server block configuration file you want to work with, so let’s copy that over and rename it to your domain.

cp examples/php/php.conf /etc/nginx/sites/yourdomain.ext.conf

Replace yourdomain.ext with your actual domain. Now we just need to tweak that file to be specific to your domain instead of general.

nano /etc/nginx/sites/yourdomain.ext.conf


server_name _;

Replace that with

server_name yourdomain.ext www.yourdomain.ext;

Now find:

root /home/nginx/htdocs/public;

And set the path to the path where you want to store your public files, i.e. where index.php will be. For example:

root /home/yourdomain.ext/htdocs/public

Close and save the file. We just need to make one more change and that’d be to this file:


We need to modify the listen directive so that it matches our NGINX configuration. By default, PHP uses sockets but our NGINX configuration uses TCP (preferred), so we need to fix that.

nano /etc/php/7.1/fpm/pool.d/www.conf


listen = /run/php/php7.1-fpm.sock

Change that to:

listen =

Close and save. Now we need to restart both NGINX and PHP-FPM.

service php7.1-fpm restart
systemctl restart nginx

From there, the only other thing you need to do is install MariaDB/MySQL if needed for your app and then start creating databases, database users, etc so that you can connect. We can do that next (and I’ll have an installer for it uploaded soon to simplify things), but let’s make sure we get the above up and running for you first :-).