Vagrant builds LNMP Environment

Source: Internet
Author: User
Tags mcrypt

Vagrant builds LNMP Environment

Vagrant builds LNMP Environment

Install Vagrant and Virtualbox.

  1. mkdir Ubuntu_lnmp
  2. vagrant init ubuntu/trusty64

Open vagrantfile to open these two configurations

  1. config.vm.network "private_network", ip:“192.168.10.10"
  2. config.vm.provider "virtualbox" do |vb|
  3. # Display the VirtualBox GUI when booting the machine
  4. # vb.gui = true
  5. # Customize the amount of memory on the VM:
  6. vb.memory = "1024"
  7. end

The connection username and password for vagrant up waiting to install vagrant ssh are both vagrant

Vagrant Environment

  1. sudo apt-get update

Install nginx

  1. sudo apt-get install nginx

Set the password for installing Mysql. You can connect to Mysql through SSH during remote connection. The ssh username and password are both vagrant.

  1. sudo apt-get install mysql-server mysql-client libmysqlclient-dev

Install Git Version Control

  1. sudo apt-get git

Install PHP and related modules

  1. sudo apt-get install php5-fpm php5-mysql php5-cli php5-gd php5-memcache php5-memcached php5-json php5-mcrypt php5-curl php-pear build-essential php5-dev -y
  2. sudo pecl install xdebug -y
  3. sudo php5enmod json
  4. sudo php5enmod mcrypt

Delete/usr/share/nginx/html

  1. sudo ln -s /vagrant /usr/share/nginx/html

Note: The/vagrant directory here is actually the ubuntu_lnmp directory you created earlier. You can modify the/vagrant directory of the ubuntu_lnmp Virtual Machine locally.

Modify/etc/php5/fpm/php. ini

  1. cgi.fix_pathinfo =1
  2. display_errors =On
  3. date.timezone = PRC
  4. /etc/nginx/sites-available/default

Modify

  1. server {
  2. ...
  3. // Locate the index
  4. index index.php index.html index.htm
  5. ...
  6. location ~ \.php {
  7. # fastcgi_split_path_info ^(.+\.php)(/.+)$;
  8. # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
  9. #
  10. # # With php5-cgi alone:
  11. fastcgi_pass 127.0.0.1:9000;
  12. # # With php5-fpm:
  13. # fastcgi_pass unix:/var/run/php5-fpm.sock;
  14. fastcgi_index index.php;
  15. include fastcgi_params;
  16. set $path_info "";
  17. set $real_script_name $fastcgi_script_name;
  18. if($fastcgi_script_name ~"^(.+?\.php)(/.+)$"){
  19. set $real_script_name $1;
  20. set $path_info $2;
  21. }
  22. fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
  23. fastcgi_param SCRIPT_NAME $real_script_name;
  24. fastcgi_param PATH_INFO $path_info;
  25. }
  26. }

This is to support php phpinfo. It is not very difficult to understand. The fastcgi_param configuration item name will appear in $ _ SERVER [configuration item name ].

Modify nginx User Name

  1. sudo vi /etc/nginx/nginx.conf

Change user www-data to user vagrant;

Modify php-fpm Configuration

  1. sudo vi /etc/php5/fpm/pool.d/www.conf

Find the following configuration item to modify

  1. user = vagrant
  2. group= vagrant
  3. ; Listen =/var/run/php5-fpm.sock comment out
  4. listen =127.0.0.1:9000
  5. listen.owner = vagrant
  6. listen.group= vagrant

My pm. Configuration

  1. pm.max_children =1000
  2. pm.start_servers =25
  3. pm.min_spare_servers =25
  4. pm.max_spare_servers =50
  5. pm.max_requests =1000

To prevent the php. ini of cli and fpm from being different, you can delete the php. ini file of cli and then ln the previous

  1. sudo cp /etc/php5/fpm/php.ini /etc/php5/cli/php.ini

In this way, you can modify a configuration file to synchronize the files on both sides.

You may also like the following LNMP (Linux + Nginx + MySQL + PHP) articles:

Ubuntu 14.04 LTS install LNMP Nginx \ PHP5 (PHP-FPM) \ MySQL

Install the LAMP \ Vsftpd \ Webmin \ phpMyAdmin service and settings in Ubuntu 13.04

Build and install the LNMP production environment in CentOS 6.4

Practical Production Environment-LNMP architecture compilation and installation + SSL encryption implementation

LNMP full-featured compilation and installation for CentOS 6.3 notes

Install LNMP in CentOS 6.3 (PHP 5.4, MyySQL5.6)

Nginx startup failure occurs during LNMP deployment.

Ubuntu install Nginx php5-fpm MySQL (LNMP environment setup)

Install LNMP on CentOS7 (Linux + Nginx + MySQL + PHP)

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.