Vagrant builds LNMP Environment
Vagrant builds LNMP Environment
Install Vagrant and Virtualbox.
mkdir Ubuntu_lnmp
vagrant init ubuntu/trusty64
Open vagrantfile to open these two configurations
config.vm.network "private_network", ip:“192.168.10.10"
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
# vb.gui = true
# Customize the amount of memory on the VM:
vb.memory = "1024"
end
The connection username and password for vagrant up waiting to install vagrant ssh are both vagrant
Vagrant Environment
sudo apt-get update
Install nginx
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.
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
Install Git Version Control
sudo apt-get git
Install PHP and related modules
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
sudo pecl install xdebug -y
sudo php5enmod json
sudo php5enmod mcrypt
Delete/usr/share/nginx/html
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
cgi.fix_pathinfo =1
display_errors =On
date.timezone = PRC
/etc/nginx/sites-available/default
Modify
server {
...
// Locate the index
index index.php index.html index.htm
...
location ~ \.php {
# fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
set $path_info "";
set $real_script_name $fastcgi_script_name;
if($fastcgi_script_name ~"^(.+?\.php)(/.+)$"){
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
}
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
sudo vi /etc/nginx/nginx.conf
Change user www-data to user vagrant;
Modify php-fpm Configuration
sudo vi /etc/php5/fpm/pool.d/www.conf
Find the following configuration item to modify
user = vagrant
group= vagrant
; Listen =/var/run/php5-fpm.sock comment out
listen =127.0.0.1:9000
listen.owner = vagrant
listen.group= vagrant
My pm. Configuration
pm.max_children =1000
pm.start_servers =25
pm.min_spare_servers =25
pm.max_spare_servers =50
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
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: