LNMP environment Installation (1)-linux (CentOS) system installation

Source: Internet
Author: User
Tags website server

This is the first of its own in 51cto, mainly as a web developer to explain how to quickly build a Linux development environment way!

I. Overview

As a web development engineer, local environment building is a basic skill, relatively speaking, under window to build such environments have many ready-to-inherit development packages, can achieve rapid environmental construction, such as: Wampserver, XAMPP, Appserv and so on. But the online version we run is usually a server with a Linux operating system, so Linux is a good place to deploy and debug on-line code.


Next, I will build the LNMP website server architecture based on Linux! LNMP stands for: Linux system nginx+mysql+php this site server architecture.

Linux is a class of UNIX computer operating system, is currently the most popular free operating system. The representative versions are: Debian, CentOS, Ubuntu, Fedora, Gentoo, etc.

Nginx is a high-performance HTTP and reverse proxy server, also a IMAP/POP3/SMTP proxy server.

MySQL is a small relational database system.

PHP is a scripting language for embedded HTML documents that are executed on the server side.


In the following chapters, we will cover the installation of Linux (CentOS) operating systems under virtual machines, the installation and PHP upgrades for nginx+mysql+php with the integrated development package LNMP, nginx+php installation and configuration, MySQL installation and configuration, Nginx Virtual host configuration, PHP extension memcached, Redis installation and so on.


Second, the program is marked

The goal of this section is to implement the installation of a Linux (CentOS) operating system on your own computer by taking a virtual machine. Here you will find a portfolio of artifacts: Vagrant+virtualbox, which can be easily deployed across platforms for file sharing.


Iii. Use of tools

1. System Environment:

Window7

2. Virtual Machine Software:

Virtualbox = https://www.virtualbox.org/()

Vagrant = http://www.vagrantup.com/()

3. Linux System files:

Centos65-x86_64-20140116.box = http://www.vagrantbox.es/(, there are many system files, choose the one that suits you)


Four, the Operation procedure

1. Download and install

Download the VirtualBox, vagrant installation package and CentOS system files separately according to the address provided in the three.

Windows under the installation of VirtualBox, Vagrant Software, Windows under the installation is very simple, here do not introduce more!

Operation complete, restart the system to complete the installation!

2. Create a working directory

Select the working directory and copy the Centos65-x86_64-20140116.box system files to the file directory

Example: E:\tool\centos

3. Setting up the environment

Cmd=> into the DOS command line interface, switch directory E:\tool\centos, command operation steps:

1). E:\tool\centos>vagrant box Add base   centos65-x86_64-20140116.box

The above command means: vagrant is the command of Vagrant, box is the parameter, add for adding a box environment, Dev for you to create the box environment name, Centos65-x86_64-20140116.box for you to download the box environment image, This can be the path to save the box locally, or you can download the box URL, if it is a URL, vagrant will automatically start the download.

2). e:\tool\centos>vagrant Init

Initializes the configuration file Vagrantfile for the corresponding system environment. Here are some of the major configuration items:

① Network Configuration

A, port mapping, map the port in the virtual machine to the corresponding port of the host, and configure it in Vagrantfile:

Config.vm.network:forwarded_port, guest:80, host:8080guest:80 represents the 80 port in the virtual machine, and host:8080 represents the 8080 port that is mapped to the host.

B, only locally accessible virtual machines, using Private_network, virtual machine set IP, configured in Vagrantfile:

Config.vm.network:p rivate_network, IP: "192.168.33.10"

Virtual machine IP 192.168.33.10, more than one virtual machine need to visit each other, should be set in the same network segment, such as 192.168.33.11.

C, the virtual machine as a current LAN computer, by the local area network for DHCP or manual assignment, in the Vagrantfile configuration:

Config.vm.network:p ublic_network or config.vm.network:p ublic_network, IP: "192.168.33.10"

② Directory Mapping:

Through the directory mapping, the development work can be completed locally, the virtual machine is only run in the background, the local directory map to the corresponding directory of the virtual machine, without the need for FTP and other complex

Tools to upload the work. By default, the current working directory is mapped to the/vagrant directory of the virtual machine, and the files in the current directory can be directly

Access under/vagrant.

Of course, you can also manually add a working directory mapping in the configuration file.

Config.vm.synced_folder ". /.. /www/","/home/wwwroot/vagrant "

.. /.. /www/is a local directory,/home/wwwroot/vagrant/the directory in the virtual machine, and this directory is created after installing Nginx next.

③ Startup scripts

About setting up the startup script, here is not more introduction, you can look at this line

A. Set the start command

Config.vm.provision "Shell", inline <<-shell
echo "Welcome to Centos"
SHELL

B. Set the startup script

Config.vm.provision:shell,:p ath = "boot.sh"

Integrated above, the main configuration is complete


3). E:\tool\centos>vagrant Up

Execute the above command to start the virtual machine.

To remove the startup virtual machine, the Operation Virtual Machine command also has the following:

Vagrant Halt (Turn off the virtual machine-the corresponding is the shutdown)

Vagrant Suspend (Pause virtual machine-just pause, virtual machine memory and other information will be saved locally as a state file and can continue to be used after a recovery operation)
Vagrant Resume (restores the virtual machine-corresponds to the previous pause)
vagrant destroy (Deleting a virtual machine, deleting the configuration in the current virtual machine that is done except for Vagrantfile is not retained)


V. Problem solving

There is a problem, unable to start normally, open the VirtualBox GUI to view the boot information.

Configure in Vagrantfile:

Config.vm.provider "VirtualBox" do |vb|
# Display The VirtualBox GUI when booting
Vb.gui = True
#
# # Customize The amount of memory on the VM:
# vb.memory = "1024"
End


Issue One: Start prompt vt-x/amd-v hardware acceleration is not available in your system. Your 64-bit virtual machine will not be able to detect a 64-bit processor to boot.

Workaround: Restart the computer, enter the bios=>securit=>virtualization=>enabled to start the computer support virtualization technology!


Integrated above steps, can realize Virtualbox+vagrant+centos system installation work!


LNMP environment Installation (1)-linux (CentOS) system installation

Related Article

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.