Nginx multi-site configuration

Source: Internet
Author: User

Nginx multi-site configuration

Recently I have added several sites to the Laravel application, but some of them have been deleted, which makes my obsessive-compulsive disorder very uncomfortable, I did not record the problem after I solved it last time, so it took a lot of time today. So I wrote my first post specially. This post is based on the correct installation of Laravel. If there is anything wrong, I still hope to correct it.

Configure site

According to the official documentation, there are two ways to add a site:

  • 1. In/Homestead/src/stubs/Homestead.yamlAdd a site to the file:
sites:    - map: homestead.app      to: /home/vagrant/Code/Laravel/public

Then run the following command in the Homestead directory:

vagrant provision

However, as mentioned in the official document, this operation is destructive.provisionCommand, the existing database will be destroyed and re-created.

  • 2. SSH enters the Homestead environment, use the serve command file to add a site, and execute the following command:
serve domain.app /home/vagrant/Code/path/to/public

After adding a site in any of the above ways, we should move the new site to the local/etc/hostsFile:

# homestead config192.168.10.10 homestead.app

Now, the site is added!

Modify or delete a site

(Here, 1 and 2 correspond to the methods 1 and 2 of the added sites respectively)

  • 1. In/Homestead/src/stubs/Homestead.yamlModify or delete the site in the file, and then execute the following in the Homestead directory:
vagrant provision
  • 2. You will find thatserveThe site added by the command does not appear inHomestead.yamlFile, according
    /Homestead/scripts/serve.shFile, you can seeserveThe command will create an nginx site, make some links, and then restart nginx and php-fpm:
echo "$block" > "/etc/nginx/sites-available/$1"ln -fs "/etc/nginx/sites-available/$1" "/etc/nginx/sites-enabled/$1"service nginx restartservice php5-fpm restart

After SSH enters the Homestead environment, run the following command:

cd /etc/nginx/sites-availablels

Now we can see all the sites! Then, you can run the following command to delete the site:

sudo rm homestead.app

Alternatively, run the following command to edit the file and modify the site:

sudo vi homestead.app

The above is what we learned today. After reading it, let's leave your valuable comments ~

For more Nginx tutorials, see the following:

Deployment of Nginx + MySQL + PHP in CentOS 6.2

Build a WEB server using Nginx

Build a Web server based on Linux6.3 + Nginx1.2 + PHP5 + MySQL5.5

Performance Tuning for Nginx in CentOS 6.3

Configure Nginx to load the ngx_pagespeed module in CentOS 6.3

Install and configure Nginx + Pcre + php-fpm in CentOS 6.4

Nginx installation and configuration instructions

Nginx log filtering using ngx_log_if does not record specific logs

Nginx details: click here
Nginx: click here

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.