Website Development Series 1 - Server Environment Setup, Website Development Setup_PHP Tutorial

WBOY
Release: 2016-07-12 09:03:22
Original
969 people have browsed it

Website Development Series 1 - Server Environment Setup, Website Development Setup

First of all, the audience of this series of articles is those who have just graduated and want to do website development, or want to know about other development positions. This introductory tutorial for website development assumes that the reader has a computer-related professional foundation and will skip many basics. The detailed principles can be explained by Baidu yourself or I will add them later. The characteristics of the programming language itself will not be involved in many.

Well, let me briefly introduce myself. I am a male science and engineering graduate from South China Agricultural University, majoring in software engineering. I worked in a startup company called Kailangao in Guangzhou for more than two years from 2012 to 2014, mainly responsible for Nodejs server development. and technical team management. In August 2014, I tried to start a business for three months but ended in failure. In December 2014, I worked as a front-end developer for Southern Weekend New Media for more than half a year and started to get involved in PHP development. I resigned in August 2015 and have been working in a company since. I am the technical director of a b2b start-up company in a traditional industry. I am still relatively inexperienced, and it is impossible for me to know and understand all programming languages ​​and software thoroughly. Please point out any mistakes I make.

Learning objectives:

Learning process

  • First let’s start with the goal. Our goal is to create a website, a website that others can access through the website address (URL), so the website must run on a server to provide services for visiting users, then provide this service The machine is also called a web server. How to understand the server? Compared with another noun PC (personal computer), a simple understanding is that a server is a powerful computer used to provide some services, and the software running on this physical machine varies according to the services provided. We are also divided into web servers, database servers, mail servers, cache servers, proxy servers, etc. At this time, the names of web servers also refer to software such as nginx and apache.

  • Web server, also known as website server, as the name suggests, provides website access services. So What software can function as a web server? When learning JAVA, we need to install tomcat, when learning .NET, we need to install iis, when learning PHP, we need to install apache or nginx, by the way, tomcat, iis, apache or nginx is one of the web servers we call. So, what functions do they provide as web servers?

tomcat

iis

apache

Website Development Series 1 - Server Environment Setup, Website Development Setup_PHP Tutorialnginx

Website Development Series 1 - Server Environment Setup, Website Development Setup_PHP TutorialIn order to explain the role of the web server, we should first choose one of the programming languages, configure the operating environment, and be able to access and return data , and then talk about the web server play a role. Here, I choose a typical lamp website technology combination to illustrate, and at the same time explain other types of web servers by analogy.

First of all, the simplest hello world website does not actually require a mysql database, so start with the simplest configuration. You can use wamp directly under windows (http://www.wampserver.com/ ) integration, for this tutorial, I spent 666 oceans to buy Alibaba Cloud’s Linux server, cenos7.0 64-bit .

 1. Download apache, http://httpd.apache.org/, you can download the 2.4.18 version, please refer to the installation process for details Attachment:

After apache is installed, it is installed in /usr/local/apache2 by default, so in order to start it globally, a hard link to httpd is created, ln /usr/local/apache2/bin/httpd /usr/local/bin/ .

 2. The programming language is php, first download php from http://php.net/, the latest version is 7.0.0, but here we take 5.6.16 as an example , Windows has thread-safe and non-thread-safe versions. Download the thread-safe version for now. The specific differences will not be explained for the time being.

After installing php, start php-fpm, temporarily use the default configuration, and use TCP to connect to port 9000. For details, please refer to the attachment.

 3. Then I hope that when accessing the localhost address or 127.0.0.1, the web page returns the hello world string and displays it to the browser, so I write a file named index.php

vim /var/www/test/index.php (the directory does not exist and needs to be created first)

<span>1</span> <?<span>php</span>
2 <span>echo</span> "hello world";
Copy after login

  • Okay, at this point, how to connect these three to achieve web page access?

xxx.xxx.xxx.xxx - - [16/Dec/2015:15:57:51 0800] "GET / HTTP/1.1" 200 26 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit /537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36"

4. The output content is the php file code we wrote, not the execution result. Why? Because php is a scripting language, it requires the previously installed php to interpret the execution output. Therefore, the next step is to add php to the apache configuration. There is more than one mode for apache to run php. The fastcgi mode is used here, and the others will be explained later. Pattern practices and principles. Remove the comments of the following two modules, add the module configuration, and restart the apache server.

LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so


 ProxyPass "/" "fcgi://127.0.0.1:9000/var/www/test/index.php" enablereuse=on

Summary:

Of course, there are still many small problems to be solved in the entire configuration process. While solving these problems, it also forces me to learn and improve myself. If you have any questions, leave a comment and I will try my best to answer them. But in the next issue, I will make a big reversal. 1. I will use Nginx as the reverse proxy server to replace apache and adopt the LNMP architecture; 2. I will configure the Laravel PHP framework and be able to access Laravel's hello world home page, Larevel is also a framework used for website development, rather than building a website from scratch.

Attachment: LAMP environment setup

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1081087.htmlTechArticleWebsite Development Series 1 - Server Environment Setup, Website Development Setup First of all, the audience of this series of articles is fresh graduates Want to do website development, or want to learn about website development in other development positions...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template