php environment general web server construction options

First, the choice of web server

  1. Apache
  2. nginx
  3. iis

Introduction to Apache ( Baidu Encyclopedia )

        Apache is the number one web server software used in the world. It can run on almost all widely used computer platforms and is one of the most popular web server-side software due to its cross-platform and security being widely used. It is fast, reliable and extensible with a simple API to compile interpreters like Perl / Python into the server.

 

Introduction to Nginx ( Baidu Encyclopedia )

Nginx  ("engine x") is a high-performance HTTP and reverse proxy server, as well as an IMAP/POP3/SMTP server . Nginx was developed by Igor Sysoev for the second most visited site in Russia , Rambler.ru, and the first public version 0.1.0 was released on October 4, 2004. It releases the source code under a BSD-like license and is known for its stability, rich feature set, sample configuration files, and low consumption of system resources . On June 1, 2011, nginx 1.0.4 was released.

Nginx is a lightweight web  server/ reverse proxy server and email (IMAP/POP3) proxy server distributed under a BSD-like protocol. Developed by the Russian programmer Igor Sysoev, it is used by the large Russian portal and search engine Rambler (Russian: Рамблер). Its characteristics are that it occupies less memory and has strong concurrency capabilities. In fact, the concurrency capabilities of nginx are indeed better among web servers of the same type. The users of nginx websites in mainland China include: Baidu, JD.com , Sina , NetEase , Tencent , Taobao, etc.

 

Introduction to IIS ( Baidu Encyclopedia )

        IIS is the abbreviation of Internet Information Services , which means Internet Information Services. It is a basic Internet service based on Microsoft Windows provided by Microsoft Corporation. Originally an optional package for the Windows NT edition, it was subsequently shipped with Windows 2000, Windows XP Professional, and Windows Server 2003, but there was no IIS on the Windows XP Home edition. IIS is a Web (web page) service component, including Web server, FTP server, NNTP server and SMTP server, which are used for web browsing, file transfer, news service and mail sending, etc. Publishing information on the local area network) has become a very easy task.

 

Advantages and disadvantages

Nginx:

Lightweight, same as web service, takes up less memory and resources than apache

Anti-concurrency, nginx processes requests asynchronously and non-blocking, while apache is blocking. Under high concurrency, nginx can maintain low resource consumption and high performance

Highly modular design, writing modules is relatively simple

The community is active, and various high-performance modules are produced quickly

Strictly speaking, Nginx is not running PHP, Nginx only forwards it to php-fpm , it is php-fpm that maintains PHP running...
php-fpm is stable now, but it still cannot release memory, so the general configuration is 500 times After the child process does not receive the task, the task itself is completed and ends by itself, and a new one is opened to continue running. This task is managed by php-fpm...

 

IIS:

Graphical management interface, easy to manage.
IIS and Apache run as modules and release memory automatically, but IIS is still unreliable for running PHP, which is relative to Nginx and Apache, so don't consider IIS now...

 

Apache:

rewrite, more powerful than nginx's rewrite

There are so many modules, you can find everything you can think of

Less bugs, nginx has relatively more bugs

Ultra stable

Apache performance is very good, has been used before. But now the development of Nginx is very NB, which promotes the development of php-fpm is also very complete and stable. php-fpm is something that everyone supports, so don’t consider the compatibility of running as a module (many PHP extensions occasionally have problems ), the future is the way the mainstream PHP runs, and the memory footprint is also small. Apache is too large to solve some pain points, leading to the rise of Nginx. For example, the speed limit under Apache that I care about is only cband, which is easier to use, but the third party does it, although it is not bad, but often this version does not support it, but that version supports it. And such functions of Nginx have been included as basic functions, and they are very powerful...

 

Under Win:
Don't use Nginx under Win platform, because there is no php-fpm under Win to manage the PHP process, so you can only use php-cgi, and php-cgi has no process management, so occasionally an error process will die your PHP If it hangs, it is necessary to manually start the process. You can also write a monitoring program to manage it yourself, which is generally impossible for people who maintain servers. Under Linux/BSD, php-fpm can set parameters to automatically start several processes, request how many times to eliminate and restart new processes, and there are many other ways to manage PHP processes. Everything is managed automatically by php-fpm. As for Nginx under Win, it uses the native Win32 API, which is implemented with select, while the more advanced technology I/O Completion Ports under Win has been done by a third party as far as I know, but the official Nginx does not seem to use IOCP, so the performance is definitely not that of Linux. The kqueue of epoll and BSD is good. In fact, it feels that most of the Win server is an enterprise station, and there is not much traffic. If there is a lot of access, most of them use Linux/BSD as a cluster. The key point is that there is no php-fpm under Win, so don't use Nginx under Win...
In fact, there is another point about not recommending the use of Win server: Is your Win server genuine? Maybe most of the servers are not, but in case of offending others and being reported, or if a big company goes public, there is still a possibility of being investigated...

Under Win, I have been using Apache for local development and testing. Because Apache has been used for more than 10 years, I am familiar with Apache, and it is stable. It is basically unnecessary to run it as a service. It is more convenient to use Apache for development machines. You are familiar with IIS or have feelings and can use IIS, otherwise Apache is recommended, and there will be no problems at all. It is also very stable to run. But I now use Nginx+php-cgi for Win development machine testing, haha, keep it unified, and I test it all right. Occasionally, when debugging PHP code once or twice a month, the PHP process dies, just start the service. Don't use Nginx in the production environment under Win, use Apache...

 

in conclusion:

If the server uses asp/.net, use Win, otherwise try to use Linux or BSD , if you need to maximize performance, you must use Linux or BSD...

Under Win, Apache+PHP is the first, followed by IIS+PHP…

Under Linux or BSD, Nginx+PHP is the first choice, followed by Apache+PHP…

PHP recommends PHP7, just one word for cool, not to mention the reason, there are introductions everywhere to upgrade to PHP7 cool…
 
references
 
2. Database selection
  1. mysql
  2. Oracle
  3. SQL Server

Introduction to MySQL ( Baidu Encyclopedia )

        MySQL is a relational database management system developed by the Swedish MySQL AB company and is currently  a product of Oracle  . MySQL is one of the most popular relational database management systems . In terms of WEB applications, MySQL is the best RDBMS (Relational Database Management System) application software.

 

Introduction to Oracle ( Baidu Encyclopedia )

        Oracle Database, also known as Oracle RDBMS, or Oracle for short. It is a relational database management system from Oracle Corporation . It is a product that has been leading the way in the database field. It can be said that the Oracle database system is a popular relational database management system in the world. The system has good portability, convenient use and strong functions, and is suitable for all kinds of large, medium, small and microcomputer environments. It is a high-efficiency, reliable, high-throughput database solution.

 

SQL Server ( Baidu Encyclopedia )

        SQL Server is a relational database management system. It was originally developed by Microsoft, Sybase and Ashton-Tate, and the first OS/2 version was released in 1988 . After the launch of Windows NT, Microsoft and Sybase parted ways in the development of SQL Server. Microsoft transplanted SQL Server to Windows NT system and focused on developing and promoting the Windows NT version of SQL Server. Sybase is more focused on the application of SQL Server on the UNIX operating system .

 

Comparison of relational databases

MySql database:

Advantages: 1. Data warehouse supporting 50 million records

2. Adapt to all platforms

3. It is open source software, and the version is updated quickly

4. The performance is excellent. Purely in terms of performance, MySQL is excellent because it includes a default desktop format, MyISAM. The MyISAM database is very disk compatible without taking up too much CPU and memory. MySQL can run on Windows systems without conflict, preferably on UNIX or UNIX-like systems. You can also gain some extra performance by using a 64-bit processor. Because MySQL uses 64-bit integer processing internally many times.

5. Inexpensive

Disadvantages: Lack of some stored program functions, such as MyISAM engine linking support for switching functions

 

 

MsSqlserver database:

Advantages: 1. True client/server architecture

2. Graphical user interface makes system management and database management more intuitive and simple

3. Rich programming interface tools provide users with more choices for programming

4. Fully integrated with WinNT, using many functions of NT, such as sending and receiving messages, managing login security, etc., SQL Server can also be well integrated with Microsoft BackOffice products.

5. It has good scalability and can be used across platforms.

6. Provides data warehouse functionality, which is only available in Oracle and other expensive DBMSs.

7. The processing speed is faster than Oracle, which is related to the agreement between the two.

 

Oracle database:

Advantages: 1. The stability of Oracle is better than that of Sql server.

2. Oracle's data import tool sqlload.exe is more powerful than Sqlserver's Bcp function, and Oracle can import text file data according to conditions.

3.Oracle's security mechanism is better than Sql server.

4.Sql server is better than Oracle in terms of ease of use and friendliness.

5. Oracle will be more stable in processing big data.

6. Sql Server is more powerful in data export.

 

Cons: Expensive

references
 
Other types of databases
Redis ( Baidu Encyclopedia )
        Redis is an open source  log-type, key-value database written in ANSI C language , supports network, can be memory-based and persistent , and provides APIs in multiple languages. Since March 15, 2010, the development of Redis has been hosted by VMware. Since May 2013, the development of Redis has been sponsored by Pivotal.
memcached ( Baidu Encyclopedia )
        Memcached is a high-performance distributed in-memory object caching system for dynamic web applications to reduce database load. It improves the speed of dynamic, database-driven websites by reducing the number of database reads by caching data and objects in memory. Memcached is based on a hashmap that stores key/value pairs . The daemon is written in C , but the client can be written in any language and communicate with the daemon through the memcached protocol.
the difference

1. Both Redis and Memcache store data in memory, both of which are in-memory databases. However, memcache can also be used to cache other things, such as pictures, videos, etc.;

2. Redis not only supports simple k/v type data, but also provides storage of data structures such as list, set, and hash;

3. Virtual memory -- when Redis runs out of physical memory, it can exchange some values ​​that have not been used for a long time to disk;

4. Expiration policy --memcache is specified when set, for example, set key1 0 0 8, that is, it will never expire. Redis can be set by, for example, expire, such as expire name 10;

5. Distributed--Set up a memcache cluster and use magent to be one master and multiple slaves; redis can be one master and multiple slaves. can be master and slave;

6. Data storage security -- after memcache hangs, the data is gone; redis can be regularly saved to disk (persistence);

7. Disaster recovery -- after memcache hangs, the data cannot be recovered; after redis data is lost, it can be recovered through aof;

8. Redis supports data backup, that is, data backup in master-slave mode;

9. Different application scenarios: In addition to being used as a NoSQL database, Redis can also be used as a message queue , data stack, and data cache; Memcached is suitable for caching SQL statements, data sets, user temporary data, delayed query data and sessions, etc. .

 

 

Personally, for applications with persistence requirements or advanced requirements for data structure and processing, choose redis, other simple key/value storage, and choose memcache.

references
The difference between redis and memcached (summary)  http://www.cnblogs.com/timothy-lai/p/5786502.html
The difference and choice between memcached and redishttp:  //www.cnblogs.com/xw2169/p/6017146.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326434308&siteId=291194637