LAMPWebServer web hosting server quickly built into idea-php Tutorial

Source: Internet
Author: User
Tags website server create blog web hosting server hosting
LAMPWebServer web servers are quickly built into the introduction...

LAMP stands for the combination of Linux + Apache + MySQL + PHP and other website servers.

  1. Production System
  2. Http server
  3. Materials
  4. Post-website statement

LAMP can be said to be a widely used network to build environment combination. In addition, it also integrates with other products with the same functions, for example, you can change Linux to FreeBSD or Windows FAMP and WAMP, and change Apache to nginx lnmp. in the Linux distribution (branch), Debian/Ubuntu is the most typical deployment, this document uses Ubuntu/Debian as an example, but is basically used based on Debian and GNU/Linux distributions of Ubuntu.

According to the W3Techs statistics, the operating system of Linux in the web server has a high market rate of 36.2% (68% in Unix and 53.2% in Linux ), debian/Ubuntu except Linux 32.6%/31.1%:

The Web Server hosting domain of Aapache has a market share rate of over half of users:

For 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 reason for reading this article is mainly because

Many people use WordPress to create blog posts and blog posts. WordPress currently has a 26% online market access rate, on average, one website is built on WordPress every four minutes. we can imagine that WordPress is quite mature in terms of convenience in the community and community, considering that self-configuring WordPress is better than directly using WordPress.com

The current service is more efficient and has more functions. at the same time, you can learn technical skills, however, for beginners, the fear of problems has always been the biggest obstacle, so I wrote this LAMP notebook for beginners to take the test, for other websites that use PHP plug-ins in the same way, they are basically unavailable.

According to the W3Techs statistics, WordPress's website market availability has increased by 26%, and the Content Management System (CMS) is used) higher market availability for website management (59.2% ):

W3Techs:

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

Although the latest PHP version is 7.0, it is not long before PHP 7 was launched, the official Debian/Ubuntu kit has not been used to compile the kit used by the released release version (but the Ubuntu Xenial Xerus 16.04 LTS will be available soon !) Currently, the mainstream version of PHP is 5.x, apart from the integration of the new version of the system into the suite, there is probably only ppa security. PHP 7.0 is not a key and unnecessary part of this article, in fact, some PHP programs are not compatible with each other. for part of PHP 7.0, you may have another simple article, this article focuses on PHP 5.x, which is the easiest way to get.

Next, the text begins.

This article assumes that you have installed Ubuntu 14.04 server with basic Unix operations. if you have not installed it, you can skip this article:

Step by step, install Ubuntu 14.04 Server on VirtualBox firewall host

With Ubuntu/Debian (Linux, the fastest and simplest method of LAMP startup can be written into the following line (if you want to ignore long arguments, this article will only do the following ):

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, you will need to set the password of the database. after checking the password twice, you just need to wait for the setting to finish running. In fact, it is okay, if you are afraid of long-running commands, you can use tasksel to install lamp-server in Ubuntu based Linux, as there is no lamp-server option under Debian, some web-server options are available, but they do not include the security of mysql resources, it is recommended to directly use apt-get to complete the security, so tasksel is not required.

In fact, tasksel has been mentioned before, and various variant versions (such as Lubuntu and Kubuntu) and commonly used suites have been installed on the kernel, users can quickly install and switch the functions they need. if you are interested, you can refer to this article:

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

In Ubuntu, one of the following commands is lamp-server, which allows you to run the following commands quickly. in this process, you will also set the metadata secret:

Shell

$ sudo tasksel install lamp-server
$ sudotaskselinstalllamp-server

After the login line, security will be implemented, starting with the login plane of the original deployment Suite:

Information confidentiality:

Confirm information confidentiality:

Security Kit:

Because there are not many basic kits to be used, the most easy-to-configure architecture will be completed here. Next, we will carry out some basic verification work, confirm that security is successful and relevant services are activated.

After the security check is completed, you can start to renew the certificate.

1.Confirm apache operation

Through the curl Command, send an http request to the current machine (127.0.0.1) and use the-I Response to retrieve only the response header (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 200 OKDate: Thu, 25 Feb 2016 17:11:41 GMTServer: Apache/2.4.7 (Ubuntu)Last-Modified: Thu, 25 Feb 2016 15:33:31 GMTETag: "2cf6-52c99e79eb044"Accept-Ranges: bytesContent-Length: 11510Vary: Accept-EncodingContent-Type: text/html
$ curl -I 127.0.0.1HTTP/1.1 200 OKDate: Thu, 25 Feb 2016 17:11:41 GMTServer: Apache/2.4.7 (Ubuntu)Last-Modified: Thu, 25 Feb 2016 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 200 OKDate: Fri, 26 Feb 2016 11:57:22 GMTServer: Apache/2.4.10 (Debian)Last-Modified: Fri, 26 Feb 2016 11:43:55 GMTETag: "2b60-52caad05f4514"Accept-Ranges: bytesContent-Length: 11104Vary: Accept-EncodingContent-Type: text/html
$ curl -I 127.0.0.1HTTP/1.1 200 OKDate: Fri, 26 Feb 2016 11:57:22 GMTServer: Apache/2.4.10 (Debian)Last-Modified: Fri, 26 Feb 2016 11:43:55 GMTETag: "2b60-52caad05f4514"Accept-Ranges: bytesContent-Length: 11104Vary: Accept-EncodingContent-Type: text/html

We can see the success message of HTTP/1.1 200 OK! About the meaning of http tokens, refer to Wikipedia: List of HTTP status codes.

At the same time, we can also open the corresponding webpage through the browser. if you are setting the webpage on this machine, you can enable http: // localhost/, http: // 127.0.0.1/or http: // 0.0.0.0/. if the server is not set on this machine, please refer to the corresponding IP address or website domain name./Port redirect). If it succeeds, you should see the following interface (Apache2 Ubuntu/Debian Default Page). If you are not using Ubuntu/Debian, the interface may be different, but Datong Xiaoyu usually hasIt works!As follows:

The above Apache2 Ubuntu/Debian Default Page also includes some descriptive information such as the settings and structure of the case study. new users can understand them! After confirming that apache can be used to establish normal operation, it is necessary to confirm whether apache's php model can work normally.

2. confirm that apache works properly with php. the practice is to write a simple php statement that saves the case as a "php" example and sends the request to apache, check whether the program has been successfully rejected.

According to the Apache2 Ubuntu/Debian Default Page on zookeeper, the root object (document root) of the configured website server is/var/www/html, in this example, the website and group set in this case are root, so don't forget to use sudo to raise the permission when creating and storing data, here, we need to put the following php program under/var/www/html:

PHP

      
      

Shell

$ Echo'
        
$ Echo'
        

Then, just like checking whether apache is running normally, you can open the application from the browser, but remember to add the corresponding website name to the back of the website, for example, http: // localhost/phptest. php

If the operation succeeds, the following response should be displayed:

3.Confirm data sources for normal operation

Information validation statement. after the following commands are executed, enter the password and press enter to confirm whether the logon is successful:

Shell

$ mysql -u root -p
$ mysql -u root -p

Logon succeeded:

After you confirm the logon, press Ctrl + d or press enter to exit (also use quit !)

4.The last step is to confirm that the Web server can normally access data sources through php.We have passed through the well-known data processing tool phpmyadmin, the following area of the Web site: https://www.phpmyadmin.net/downloads/, as of now the latest version of 4.5.5, this shows an example of a phpMyAdmin-4.5.5-all-languages.tar.xz.

In the following example, the case will be resolved to the/var/www/html/object mentioned 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 access the corresponding location from the receiver, for example: http: // localhost/phpMyAdmin-4.5.5-all-languages/

After opening, I did not expect the warning message:

If you see such a dataset, it indicates that there is no module available, or there is no security. the preceding example shows that the json module is missing, but we have installed the php5-json suite either with apt-get or tasksel, so the reason should be that the suite was not used. Debian/Ubuntu has a good tool named php5enmod (installed after the php5-common suite, because the suite dependency will be installed ), we can use this command to parse the json Schema of php:

Shell

$ sudo php5enmod json
$ sudophp5enmodjson

Restart apache

Shell

$ sudo service apache2 restart
$ sudoserviceapache2restart

The reason for this is not to re-activate php, but to re-activate apache is that we chose to package php into an apache schema in the preceding security mode, it is similar to a framework that includes two users. the architecture is easy to install and use, and the lack of architecture is poor performance and requires a large amount of resources. (For Ubuntu as an example, if you are curious about which modules have been installed and can be used on the system, please refer to this tutorial: /etc/php5/mod-available /)

After you restart apache, you can refresh the website and check the logon details:

Please refer to the root account configured in the hosts file. the password is the password set when the security token is entered. the password size after logon will be as long as this:

In this case, the most basic setup of the LAMP server is basically completed.

Postscript

When the LAMP rack is set up, it is not enough. in the future, a record about installing WordPress after LAMP is set up will be written in an empty time window.

For the security aspect, this article does not include header information, and https/ssl encryption, that is to say, the user can easily obtain the related suite and version built by the system from the HTTP header, and when accessing the website, all the information contained in the specified cipher library is in unencrypted plaintext, which is easily "exported" by the related tool (such as Wireshark or tcpdump ), simply put, security is not guaranteed. if you are interested in these two things, you can refer to the following two documents:

Precautions for using apache, nginx, and PHP to build websites

Build an https network server in A + and other regions using nginx

In addition, as mentioned above, PHP 7.0 has already been launched when I wrote this article, you can test the performance of PHP 7.x and PHP 5.x in the following cases:

Roseapple Pi transfer efficiency benchmark (benchmark)

The last thing to say is... The above only tells you how to confirm that the function has a normal operation, but does not tell you how to say if there is no normal operation. well, what should we say, in addition to the ratio and the ratio (in fact, it is much higher), it is also very helpful to have one-to-one column listing, when a problem occurs, I suggest that you write down the response information and cut the response area of the response information, then, check the information and operation information provided by the website information, and confirm whether the operation is correct. after each step is completed, is the operation successful? Is there any other response message? The last step is to wait for the related information and find out the problem. if you really don't know why, you can use these "important information" to ask for help from 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.