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
tomcat
iis
apache
nginx
In 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";
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