First of all, the audience of this series of articles is those who have just graduated and want to do website development, or are in other development positions and want to learn about introductory tutorials on website development. By default, readers have computer-related professional foundations and will skip a lot of basics. You can Baidu for the details. Or I will add later that the characteristics of the programming language itself will not cover many. Well, let me briefly introduce myself, I am South China Agriculture
First of all, the audience of this series of articles is those who have just graduated and want to do website development, or who want to learn about introductory tutorials for website development in other development positions. By default, readers have computer-related professional foundations and will skip a lot of basics. You can Baidu for the details. Or I will add later that the characteristics of the programming language itself will not cover 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 at 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 a 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
Website Development Series 1 Server Environment Construction
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 style="color: #008080;">1</span> <span style="color: #000000;">php</span> 2 <span style="color: #0000ff;">echo</span> "hello world";
Listen 80<span style="color: #000000;">(监听端口,可在这里修改) User daemon(启动使用的用户) Group daemon(启动使用的组) DocumentRoot </span>"/usr/local/apache2/htdocs"(文档根目录,也就是我们访问url为/时指向的文件系统目录,修改为DocumentRoot "/var/www/test"<span style="color: #000000;">) <directory>"/var/www/test"<span style="color: #000000;">>(设置对应目录的访问权限) Options Indexes FollowSymLinks AllowOverride None Require all granted </span></directory> <ifmodule dir_module>(设置默认首页) DirectoryIndex index.html index.php </ifmodule> ErrorLog </span>"logs/error_log"(错误日志,修改为ErrorLog "/var/log/apache/error_log.log"<span style="color: #000000;">) LogLevel warn(日志等级) CustomLog </span>"logs/access_log"(正常访问日志,CustomLog "/var/log/apache/access_log.log")
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