Hello friends! I bring you a proposal on how to publish a Blog based on WordPress, with the Lighty as a web page server, the Spawn-FastCGI, PHP, the APC Alternative PHP Cache (Alternative PHP Cache), and everything in Debian Squeeze. I clarify that the translations I do from English to Spanish are very free on my part and may not be entirely accurate from a linguistic or semantic point of view. Personally, they are enough for me.
And gentlemen, this article is just the “Gateway”To the fascinating world of serving static and / or dynamic web pages. I am not an expert on web servers. However, many have already asked me which server do you prefer, Federico, with the Nginx, the Lighty or the Apache? I always answer that with all three. Each one has its charm and the Apache Is The Apache. In future posts we will address solutions like this with Nginx and Apache. By the way, there are rumors in the www Village about the end of Lighty, and the truth is that Debian 7 still keeps it in its repositories. For something, right?
We will see:
- Definitions for beginners
- Lighty's Recommended Solution
- Solution we will address
- Sample server data
- Installing required packages
- Setting up and checking
Useful definitions for beginners
Web Servers: It is the technology that has implicit computer programs that process applications making bidirectional and / or unidirectional and synchronous or asynchronous connections with the client, generating or transferring a response in any language or client-side application. […] Web Services arose from a need to standardize communication between different platforms (PC, Mainframe, Mac, etc.) and programming languages (PHP, C, Java, etc.). Attempts had previously been made to create standards but they failed or were not successful enough, some of them are DCOM and CORBA, as they are dependent on the implementation of the vendor DCOM - Microsoft, and CORBA - ORB. […] Despite limiting the use of Web services to the HTTP Protocol, Web services were not designed for a particular protocol, that is, nothing prevented the use of SOAP over some other Internet protocol (SMTP, FTP, etc. ). HTTP is mainly used because it is a widely spread protocol and is less restricted by firewalls (ports such as FTP are generally blocked, but HTTP is most likely not blocked).
lighttpd: Web server for Unix / Linux and Microsoft Windows operating systems. Also know as lightyIs a alternative to the web server Apache. It is designed to be secure, fast (very fast in fact), standards compliant, and flexible. Specially designed to take on heavy loads without losing balance using little RAM and little CPU. Provides high response speeds. Some sites that use it are YouTube, Wikipedia and others, which support a large traffic. It is distributed under a BSD License.
De Wikipedia. CGI: Common input interface (in English Common gateway interface, abbreviated CGI) is an important technology on the World Wide Web that allows a client (web browser) to request data from a program running on a web server. CGI specifies a standard for transferring data between the client and the program. It is a communication mechanism between the web server and an external application whose final result of execution is MIME objects. Applications that run on the server are called CGIs.
FastCGI is a protocol for connecting interactive programs with a web server. FastCGI is a variation of the well-known Common Gateway Interface (CGI or Common Input Interface). The main objective of FastCGI is to reduce the load associated with connecting the web server and programs Cummon Gaway Interface, which allows a server to serve more requests at the same time.
Spawn, in Computing refers to a function that loads and executes a new child or child process. The parent or parent process can wait for the child process to finish, or it can continue to run asynchronously. Creating new child processes requires enough memory to run the parent process and child process, or multiple child processes.
Recommended solution in the documentation of the Official Wiki of the lighttpd for high performance
If we read the document Docs_ModFastCGI of the aforementioned site, there is a paragraph that, translated very freely into Spanish on my part, would say:
External Spawning: Running the FastCGI Spawning processes directly on the web page server has some disadvantages such as:
- The FastCGI process can only be run on the local server.
- It has the same permission as the web page server.
- It has the same base directory as the web page server.
When we use a server FastCGI Separate -or External- in order to take some load off the web server, we have to control the FastCGI process through an external program such as "spawn-fcgi”. The "spawn-fcgi" program is used to start the FastCGI process in its own environment, fix its user id, group-id, and change to another root directory (chroot).
I clarify that the translation of Spawn as a noun it is "seafood egg”, While as a verb, spawning means more or less "externally spawning”. The English are a little joking when they use that word in computing, right?
The basics for practical purposes is that, by means of the solution proposed in the documentation, the FastCGI process and as many secondary processes or children (child processes) as necessary will be executed on one or more servers external to the web page server. That being executed on a different server than the one we use as a web server, of course it will be subjected to a lower load. And finally, that to use an external FastCGI server, the FastCGI process must be started and controlled by the program spawn-fcgi.
External Spawning is for those who need to install one or more servers and take on a large number of requests, such as an Internet Access Provider (ISP), or sites such as blog.desdelinux.net, etc. Explaining that solution in detail is Totally Out of Our Reach.
Solution that we will address in the post
Only one server to accommodate all the necessary services. It works and is suitable for a low-performance site, such as an Enterprise LAN. The method explained can serve as a guide for those who need greater availability and security.
Sample server data
Name: web.amigos.cu IP address: 192.168.10.20 Domain: amigos.cu
Of course, in a production environment - and even testing or at home - we must have the records DNS direct and reverse that refer to our server.
Installing required packages
As the user root we execute:
aptitude install lighttpd lighttpd-doc php5-cgi php5-gd aptitude install mysql-server mysql-client php5-mysql
The Lighty configuration files are installed in / etc / lighttpd. The program spwan-fcgi installs automatically. The documentation package files can be found at / usr / share / doc / lighttpd-doc. We strongly recommend reading the documentation, which is in English. During package installation mysql-server, they ask us for the user's password root for the MySql. We recommend using the same password that you have already declared for that user.
Setting up and checking
As we are done with the installation of the WordPress support, we must start with the configuration and tests.
We enable Lighty modules:
lighttpd-enable-mod fastcgi-php simple-vhost service lighttpd restart
We check if our server works. We open the browser and write the URLhttp://web.amigos.cu, and at least we will be able to list the directory / Var / www.
Index of /
NAME | LAST MODIFIED | SIZE | TYPE |
---|---|---|---|
Parent Directory / | - | Directory | |
index.lighttpd.html | 2013-Jan-19 18:16:41 | 3.5K | text / html |
nano /etc/lighttpd/lighttpd.conf
We remove the comment or hash symbol # what's in front of "Mod_rewrite" and add below that line "Mod_fastcgi", so that the beginning of the file is as follows:
server.modules = ("mod_access", "mod_alias", "mod_compress", "mod_redirect", "mod_rewrite", "mod_fastcgi",)
We check that the PHP is working correctly. To do this we create a file (temporarily) in the directory / Var / www:
nano /var/www/index.php
and the content of the previous file will only be:
Then we restart the service:
service light tpd restart
If we point in our browser to http://web.amigos.cu, we will see the information page of PHP Version 5.3.3-7. Therefore, everything works correctly.
It is very interesting to know the changes in the Lighty configuration after enabling the module mod_fastcgi. Through less /etc/lighttpd/conf-enabled/15-fastcgi-php.conf, we can find out. Compare the configuration read with the one in the package documentation lighttpd-doc.
Now we must tell Lighty to which directory it should direct traffic through port 80, by configuring a Virtual Host. The values that we will modify in the file /etc/lighttpd/conf-enabled/10-simple-vhost.confThey are personal and will respond to the characteristics of each installation. We will accept the values of the root directory of the server, and of the root directory of the documents, which Lighty recommends by default and we will only modify the FQDN name of the virtual host.
nano /etc/lighttpd/conf-enabled/10-simple-vhost.conf
And the final content of the file should be (remember to adapt it to your needs):
# /usr/share/doc/lighttpd-doc/simple-vhost.txt server.modules + = ("mod_simple_vhost") ## The document root of a virtual host is document-root = ## simple-vhost.server-root + $ HTTP ["host"] + simple-vhost.document-root simple-vhost.server-root = "/ srv" simple-vhost.document-root = "htdocs" ## the default host if no host is sent simple -vhost.default-host = "web.amigos.cu"
After saving the changes, we proceed to create the necessary directories according to what was previously stated. Directory / srv was created during the Squeeze installation, so we don't need to create it:
mkdir -p /srv/web.amigos.cu/htdocs
As we already have correctly declared the virtual host and the directory associated with our domain name, we can dispense with the files created in / var / www, and create a new one. index.php more custom in directory / htdocs o root directory of the virtual host documents:
rm /var/www/index.* nano /srv/web.amigos.cu/htdocs/index.php
We add the following content to the previous file:
Hello friends! Sure everything shows OK
We save the changes and restart the service:
service light tpd restart
Let's refresh our browser and check that the displayed page changed and now reflects, in addition to the output of the command phpinfo (), the greeting. It will not be necessary to restart the service in the future if we change the content of the index.php or another web page. This operation will only be done if we change the configuration of the Lighty.
And Congratulations Friends !. We already have a Debian 6.0 Squeeze with the Lighttpd web page server configured to work with the PHP5 language and MySql as the database server. We also have the correct Lighty Vhost file configuration to handle multiple domains.
Continued ...
And then, how am I? Mr. WordPress will ask. Follow us on the II part and end and end of this article.
Congratulations. I will implement it in my virtual machine.
Thank you very much for your comment
God what a beautiful desktop that of your debian could you say everything you used for that topic please?