This is an absolutely basic task for a sys admin to find out the version of the linux distro installed on a system or server. To find your centos version use any or. Setup Nginx + php- FPM + apc + Maria. DB on Debian 7 – The perfect LEMP server. Debian webserver. Debian is a great choice for setting up linux webservers. According to current stats it is the most popular server OS followed closely by centos. I am a great fan of the apt/dpkg/gdebi commands, which make it so easy to install and update packages on the system. To setup a complete functional php webserver, you need to install a couple of extra things which include a webserver and a database. In this post we shall be setting up nginx, php, php- fpm, apc and Maria. DB. Nginx is a modern webserver, that has been designed to handle large amounts of traffic using the least amount of resources in terms of RAM and CPU. Before nginx the traditional webserver used through out the internet was apache. However as the internet became more populated, the need for a faster and efficient webserver grew. Nginx vs Apache. Apache by design is very bulky and has tons of features, most of which are not necessary for typical websites. It was probably designed to satisfy everyone's needs, but this ended up making it a large and heavy webserver with mostly unused features. Nginx on the other hand is a very sleek and swift webserver that focuses entirely on speed, scalability, and efficiency. The technicals of how it does so are large and beyond the scope of this post. May be we could take a look later on. Just for your information this website runs on nginx. Now without any further discussion lets get to work. Install Nginx on Debian. The nginx package is right there in the debian repositories so you dont have to look anywhere else. Fire up apt- get and install it.# apt- get install nginx. Now launch the nginx server.# service nginx start. Starting nginx: nginx. Now access the nginx server from browser by opening the urlhttp: //localhost/and you should get the welcome message. Welcome to nginx! Important notes. There are few things you should memorise to manage your nginx server better. The nginx configuration files are found in the following location/etc/nginx/. Instead we create a separate configuration file for each vhost/site and save it in the following directories./etc/nginx/sites- available. This is similar to apache. The sites- enabled directory contains the configurations for vhosts that are to be enabled. It contains symlinks to the corresponding configuration files in sites- available directory. Setup a virtualhost. Now that we have installed nginx, its time to setup a virtual host. Unixmen provide Linux Howtos, Tutorials, Tips & Tricks,Opensource News. It cover most popular distros like Ubuntu, LinuxMint, Fedora, Centos.![]() This is what you would be doing on a real webserver to setup your site. Inside /etc/nginx/sites- available you would see a file named default. It is a template file to create your own configuration files. Just copy it and name it to your site.# cp default binarytides. When a matching server block is found, it would use the configuration from that particular server block. Dear Sir, I need your support for startup for Online Grocery Shopping, We have to build our own Cent OS Server. We have to host the website in our Server.
Another thing to configure is the web root directory for this site/vhost. Note that this is by default /usr/share/nginx/www which you might want to change to something else. The general convention is to have a separate directory for each vhost. For example/usr/share/nginx/www/binarytides. So create an appropriate directory and point the root setting in the configuration file to the directory.. It might show some warnings which can be fixed later. Finally restart nginx for the new configuration to take effect# service nginx restart. Restarting nginx: nginx: . Now create a new index. Install php and php- fpm. The next thing to install is the php interpreter and php- fpm. ![]() Php- FPM is dedicated fastcgi process manager for php that can interface or connect with any compatible webserver and manage php processes to process php requests. Nginx < == communicates ==> Php- FPM < == manages ==> php child process. Install the necessary packages first.# apt- get install php. It will automatically install the necessary dependencies. You can install php. ![]() Php- fpm runs as a separate server and nginx communicates with it over a socket. Hence the php execution is totally outside the server. Also since fpm keeps php process persistent, it fully supports APC. Now locate the php fpm configuration files. The files at located at/etc/php. A pool is a bunch of php processes running with same user/group. So if you want the php files of each site to run with a separate user permission, then you need to create separate pools of fpm. For simplicity sake we just showing a single pool here. The pool configuration files are inside the pool. If the group is not set, the default user's group. This socket must be given to nginx for nginx to be able to talk to fpm. Connect fpm with nginx. We are not going to change much here. Just note down the socket path. We have to put this into the nginx configuration file. Go back to your nginx configuration and open it again. It contains a section for php fpm configuration which looks like this# pass the PHP scripts to Fast. CGI server listening on 1. So that when accessing a directory, if no file is specified, then index. Setup apc - alternate php cache. APC is a great way to speed up the execution of php scripts. Apc compiles php code and keeps the opcode in memory and uses it next time without compiling the same php code again from file. This drastically speeds up execution. Apart from opcode cache, apc also offers a user cache to store raw data for the php application in memory. Php as of version 5. OPcache which does the same thing as apc opcode cache thereby deprecating apc. Setting up apc is very simple and quick. Just install the apc package for php. Then restart php fpm# service php. Now check the phpinfo page again and it should have the apc details as well. The apc configuration file is located at /etc/php. The configuration can be tweaked a bit for optimal performance for your needs. Here is the kind of configuration that I useextension=apc. Install Maria. DB on Debian. Now comes the last and final component of the LEMP stack. That is the Maria. DB database and not mysql. Well by now you should be knowing that mysql is in the hands of oracle and no more a community belonging. So major corps have started switching to mariadb. The good thing is that mariadb is binary compatible with mysql with lots of additional features. So if you are already using mysql for your php applications then shifting to mariadb would be absolutely hassle free. Maria. DB is not present in the debian repositories. To get the repositories visit the following pagehttps: //downloads. Select Debian as the distro, Wheezy as the release and version 1. Then select a mirror on the right side. Now scroll down to the bottom of the page to find the repository details. Here are the commands that I gotsudo apt- get install python- software- properties. Now update the apt cache and install the mariadb packagessudo apt- get update. While installation mariadb would ask for the password of user root. Enter the password and make sure not to forget. After the installation finishes check your mariadb version# mysql - V. Ver 1. 5. 1 Distrib 1. Maria. DB, for debian- linux- gnu (x. But the name mariadb is there in the version information. Webserver is ready. So now the LEMP web server is ready to use. You may want to install a couple of extra goodies like phpmyadmin to manage your database better. Phpmyadmin is there in the debian repository so install it right from there. Have any questions ? Feel free to comment below. Last Updated On : 8th April 2. Nginx + PHP- FPM + Maria. DB on Cent. OS 7 / RHEL 7. Nginx is a free, open- source, high- performance HTTP server. Nginx is known for its stability, rich feature set, simple configuration, and low resource consumption. This tutorial shows you how to install Nginx on an Cent. OS 7 / RHEL 7 with PHP support (through PHP- FPM) and Maria. DB support. PHP- FPM is an alternative PHP Fast. CGI implementation, it has some additional features useful for sites of any size, especially busier sites). The first thing you need to do is to login as root, switch to root user. Start My. SQL server. Step 3: To make the My. SQL to start during the every boot, Type the following on terminal and hit Enter. Install Nginx repository rpm to download the Nginx from the official site.# rpm - Uvh http: //nginx. RPMS/nginx- release- centos- 7- 0. Uvh http: //nginx. RPMS/nginx- release- centos- 7- 0. Install Nginx using the following command. Start the Nginx after the installation.# systemctl restart nginx. Iptables and SELinux: Issue the following commands to allow http request through the firewall.# firewall- cmd - -permanent - -zone=public - -add- service=http. If you get any error of SELinux on the Nginx logs, here is the tutorial on setting SELinux policy for Nginx. Open web browser and visit http: //your- ip- address, you should see the following page; this will confirm you that the ngnix is successfully installed on the server. Cent. OS 7 – Nginx Default Page. The default nginx document root on Cent. OS 7 is /usr/share/nginx/html/. The configuration files are under /etc/nginx directory. Auto start Nginx at system start up.# systemctl enable nginx. Installing PHP5- FPM: Next is to install PHP through PHP- FPM (PHP- FPM (Fast. CGI Process Manager), it is an alternative PHP Fast. CGI implementation. Install it by issuing the following command.# yum install php- fpm php- mysql php- cli# yum install php- fpm php- mysql php- cli. Edit /etc/php. ini. If you scroll further down, you will see all modules that are already enabled in PHP. Scroll down the browser and look for the My. SQL support information. Cent. OS 7 – Nginx PHP FPM With Maria. DB Support. That’s all!
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
November 2017
Categories |