LAMP Web Server quickly built into the door

Source: Internet
Author: User
Tags apache php php language ranges phpmyadmin

Objective...

LAMP for Linux + Apache + MySQL + PHP This Web site server combination of the simple, the representative of

    1. Operating system
    2. HTTP Server
    3. Information repository
    4. Web Backend language

LAMP can be said to be very widely used in the site of the establishment of the environment, but also have to be combined to other similar functions but different product combinations, such as the conversion of Linux to FreeBSD or Windows Famp, WAMP, the Apache to the NGINX lnmp And so on, where the Linux distribution (branch) and debian/ubuntu the most hot, this article is not an exception to use Ubuntu/debian as an example, but basically based on Debian and Ubuntu gnu/linux di Stributions are available.

According to W3techs's system, Linux occupies a high percentage of the Web server's operating system 36.2% (68% of Unix, 53.2% of Linux), and Debian/ubuntu occupies 32 of Linux. 6%/31.1%:

The Aapache Web Server domain is more than 55% surprising city occupancy:

Information please refer to W3techs:

    • Web Servers:
      • Http://w3techs.com/technologies/overview/web_server/all
    • Operating Systems
      • Http://w3techs.com/technologies/overview/operating_system/all
      • Http://w3techs.com/technologies/details/os-linux/all/all
      • Http://w3techs.com/technologies/details/os-unix/all/all

The main reason for writing this is that the former

Push the pit to recommend a lot of people to use WordPress writing blog, notebook, WordPress has now has a high of 26% of the web, the average of every four sites there is a use of WordPress frame, it is conceivable that WordPress, whether in the community, the convenience of the ecosystem has been the phase When mature, consider to self-frame WordPress will be more than direct use wordpress.com

Now, the service is more resilient, it's more powerful and can learn technology at the same time, but it's always the biggest obstacle to the fear of having a problem, so writing this LAMP's easy-to-install pen for the entrance is a great way to use the same Web site platform that uses PHP language.

According to W3techs's system, WordPress occupies a higher percentage of the web market than 26%, and in the Content-Management System (CMS) Management Web site, the market occupancy rate is higher than 60% (59.2%):

W3techs:

    • Http://w3techs.com/technologies/overview/content_management/all

Although the current version of PHP is 7.0, it is not long since PHP 7 was launched, and has not been recorded in the Debian/ubuntu's official suite repository for the stable release version (but the Ubuntu xenial Xerus 16.04 LTS will be launched Have!) , the current market mainstream use of PHP version 5.x, in the context of dependency, ease of use and maintenance of the premise, in addition to the new version of the system integration into the package, probably only the PPA installed this path, PHP 7.0 because it is not a heavy, and not necessary, and the actual old PHP Program is also not compatible, the section on PHP 7.0 may open another simple talk, this is the easiest to get the PHP 5.x as the main.

Then the text begins.

This article assumes that you have a basic Unix operation to install the Ubuntu 14.04 Server version, and if it is not installed, you can refer to this article:

Step by step, install the Ubuntu 14.04 Server on VirtualBox virtual machine installation record

In the context of Ubuntu/debian (Linux), the fastest and easiest way to set up a LAMP is to concentrate on the following line (if you want to ignore the long story, this is actually the following line):

Shell

$ sudo apt-get install apache2 libapache2-mod-php5 php5 php5-mysql Php5-json mysql-server
$ sudoapt-get Installapache2libapache2-mod-php5php5php5-mysqlphp5-jsonmysql-server

In the process will be required to set the password of the library, enter the two to confirm the general only need to wait for the completion of the run is OK, it is not difficult, if you are afraid of the longer instructions, under Ubuntu based Linux can try to use Tasksel to install Lamp-server, as There is no lamp-server this option under Debian, although there is web-server to choose, but it does not contain the installation of MySQL library, it is recommended to complete the installation directly with Apt-get, do not need to specifically use Tasksel.

In fact, prior to mentioning the Tasksel, in the form of various versions of the change (Lubuntu, Kubuntu, etc.) and commonly used in the package, so that users can quickly install, switch to the required functions, interested in the words can turn this:

Convert your Ubuntu/debian between different versions, like Desktop to Server

One of the things in Ubuntu is Lamp-server, which can be installed quickly through the following commands, and will also set the repository password in the process:

Shell

$ sudo tasksel install Lamp-server
$ sudotaskselinstalllamp-server

After it is executed, it will be installed to begin the preparation of the kit's graphics:

Information Library Password:

Confirm the Information library password:

Installation Kit:

Because there are not many packages to use, the simplest racks are done here, and then, following the basic verification work, you will be able to verify that you have successfully installed and initiated the service.

The installation is over, and then you start the experience/experience

1. Confirm Apache

Through curl This command sends an HTTP request to the machine (127.0.0.1) and uses the-i-parameters to get only the return header:

Shell

$ curl-i 127.0.0.1
$ curl-i 127.0.0.1

Ubuntu 14.04.4 LTS:

Shell

$ curl-i 127.0.0.1http/1.1 Okdate:thu, 17:11:41 gmtserver:apache/2.4.7 (Ubuntu) Last-modified:thu, F EB 15:33:31 Gmtetag: "2cf6-52c99e79eb044" Accept-ranges:bytescontent-length:11510vary: Accept-encodingcontent-type:text/html
$ curl-i 127.0.0.1http/1.1 Okdate:thu, 17:11:41 gmtserver:apache/2.4.7 (Ubuntu) Last-modified:thu, F EB 15:33:31 Gmtetag: "2cf6-52c99e79eb044" Accept-ranges:bytescontent-length:11510vary: Accept-encodingcontent-type:text/html

Debian 8.3:

Shell

$ curl-i 127.0.0.1http/1.1 Okdate:fri, 11:57:22 gmtserver:apache/2.4.10 (Debian) Last-modified:fri, 26 Feb 11:43:55 gmtetag: "2b60-52caad05f4514" Accept-ranges:bytescontent-length:11104vary: Accept-encodingcontent-type:text/html
$ curl-i 127.0.0.1http/1.1 Okdate:fri, 11:57:22 gmtserver:apache/2.4.10 (Debian) Last-modified:fri, 26 Feb 11:43:55 gmtetag: "2b60-52caad05f4514" Accept-ranges:bytescontent-length:11104vary: Accept-encodingcontent-type:text/html

You can see that the message of http/1.1 OK is successful! For an HTTP code representative, you can refer to Wikipedia: List of HTTP status codes

At the same time, we can also open the Web screen through the browser, if it is on the machine to open the http://localhost/, HTTP://127.0.0.1/or http://0.0.0.0/, if not the server in the machine, please enter the IP Location or domain name (virtual machine will need to set the connection port to send/port redirect ), success should see the following screen (Apache2 Ubuntu/debian Default Page), if you are not using Ubuntu /Debian, the picture may not be the same, but Datong small, usually have It works! Word, to this side to confirm that Apache has the normal operation:

The above Apache2 Ubuntu/debian Default Page also has some information about the setup files, the file structure, and so on, so the novice can read them! After confirming that Apache is able to operate independently, the next to be sure is whether the Apache PHP module works properly.

2. Make sure that Apache works with PHP normally, by writing a simple PHP-style file that copies the files from the file file as a copy of PHP and sending the request to Apache to confirm that the program is functioning properly.

Just above the Apache2 Ubuntu/debian Default Page mentioned that the preset Web server file root record (document root) for/var/www/html, in this example of the environment, this file is the audience of the program and the group will be Root, so when editing and archiving do not forget to use sudo to elevate the rights, the next thing to do is to put the following PHP code under/var/www/html:

Php

      
      

Shell

$ Echo '
        
$ Echo '
        

And then just like to make sure Apache is working as expected from the browser, but remember to add the corresponding file name at the end of the web address, such as http://localhost/phptest.php

Success should be seen in this way:

3. confirm the normal operation of the information warehouse

The information library is relatively simple, execute the following command, enter the password, press the key to confirm whether the login can be successful:

Shell

$ mysql-u Root-p
$ mysql-u Root-p

Log in to the successful screen:

When you are sure you can press Ctrl + D or enter Exit to leave (with quit!) )

4. Finally, make sure that the Web server through PHP can normally access the repository , we are through the well-known library tool phpmyadmin to test, download page: https://www.phpmyadmin.net/download s/, as of now the latest stable version for 4.5.5, this side of the download phpmyadmin-4.5.5-all-languages.tar.xz this file

Download and then unzip the file to the/var/www/html/listed above:

Shell

$ sudo tar-xvf phpmyadmin-4.5.5-all-languages.tar.xz-c/var/www/html/
$ sudotar-xvfphpmyadmin-4.5.5-all-languages.tar.xz-c/var/www/html/

Then, you access the location of the response from the browser, for example: http://localhost/phpMyAdmin-4.5.5-all-languages/

I didn't expect to get the wrong message when I opened it:

If you see this, it means that the module has not been initiated, or is not installed, for example, the JSON module is missing, but the front either with Apt-get or Tasksel two methods, we have installed to the Php5-json kit, so the reason should be that the kit has not been used. There is a handy tool under Debian/ubuntu called Php5enmod (which is installed after the Php5-common kit), and we can then use this command to activate the JSON module of PHP by using the following: The package dependencies are installed.

Shell

$ sudo php5enmod json
$ sudophp5enmodjson

Re-activate Apache after activation

Shell

$ sudo service apache2 restart
$ sudoserviceapache2restart

The reason this is not to re-activate PHP but to re-activate Apache is because the way we install it is to choose the structure that will package PHP into Apache modules, a bit like the two kidnapped together, its advantage is easy to install, use, the lack of performance is poor, need to use more resources. (in Ubuntu, for example, if the Curiosity system currently has a ready-to-use module, please refer to this item:/etc/php5/mods-available/)

After you re-activate Apache, you can rearrange the web, and you'll be able to see the login page:

The account is entered in the preset root, the password is entered in the installation of the password, the screen after the login will probably grow like this:

To this side basically completes the LAMP server the most basic establishment.

Remember

The lamp shelf is actually not difficult, and will then use the time to write an article about the installation of the lamp installed WordPress notebook.

Regarding the Security section, this article does not contain the header information hidden, as well as the HTTPS/SSL encryption part, that is, the user can easily from the HTTP header to obtain the system-built related suite, version, and when accessing the Web, All the information contained in the account password is unencrypted plaintext and can easily be "anotherjob" by the relevant tool (such as Wireshark or tcpdump), simply to say that it is not safe enough, and if you are interested in these two things, you may refer to the following two notes:

Use Apache, Nginx, PHP Web site to pay attention to the security things

Use Nginx to build a A + class HTTPS Web server

In addition, as mentioned earlier, this article is written in the fact that PHP 7.0 has been launched, about PHP 7.x and PHP 5.x performance difference can be taken to this side of the performance test:

Roseapple Pi Lotus Cloudy Performance simple (benchmark)

The last thing to say is ... It only tells you how to make sure that the function works, but doesn't tell you what to do if you don't have a normal operation, well, what to say, the difficulty of removing the wrong, the fault is relatively high (it is actually very much), it is difficult to one by one, the suggestion that when the problem is encountered in the amount of the wrong message, the wrong message of the graphics screen, Is it true that the information provided by the wrong message and the verification of your steps are correct and successful after each step? Are there any other bug messages? Finally, the card in which step and other related information, and slowly find the problem, really do not see why, you can use these "important information" to help others!

LAMP Picture Original from HTTP://WWW.PROGRAMMABLEWEB.COM/NEWS/WHAT-MEAN-STACK-AND-WHY-IT-BETTER-LAMP/ANALYSIS/2015/12/22

  • 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.