Everything from simple in line with the principle of do, to yum / rpm, and determined not to manually compile 🙂
The deployment environment is based on CentOS 6.3 x86_64 systems.
0.5 Preparations
1 2 3 4 5 6 |
yum [root@imysql ~]# yum -y update [root@imysql ~]# yum install libaio-devel.x86_64 [root@imysql ~]# yum install curl-devel [root@imysql ~]# yum -y install libpng-devel libjpeg-devel freetype-devel gmp-devel libxml2-devel |
1. Install nginx
1 2 3 |
[root@imysql ~]# rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm [root@imysql ~]# yum -y install nginx [root@imysql ~]# chkconfig nginx on |
2. Install php-fpm
1 2 |
[root@imysql ~]# rpm -ivh rpm -Uvh http://repo.webtatic.com/yum/el6/latest.rpm [root@imysql ~]# yum -y install php54w |
3. Configure nginx + php
/etc/nginx/nginx.conf profile can not make any changes.
Edit /etc/nginx/conf.d/default.conf, to site an example, the configuration file as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
server { listen 80; server_name imysql.com *.imysql.com; root /data/www/imysql.cn/; index index.php index.htm index.html index.shtml; error_page 404 /page_not_found; error_page 500 502 503 504 /page_not_found; location ~ /\.ht { deny all; } if ($fastcgi_script_name ~ \..*\/.*php) { return 403; } location / { if (!-e $request_filename) { rewrite ^/(.*)$ /index.php?q=$1 last; } } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 1h; } location ^~ /sites/default/files/imagecache/ { index index.php index.html; if (!-e $request_filename) { rewrite ^/(.*)$ /index.php?q=$1 last; break; } } } |
The above configuration includes a virtual host configuration nginx, and rewrite the rules of drupal configuration, simple and fast.
4. Start Test
After modifying the configuration file every time, remember the following command to test the correctness of the configuration file:
1 2 3 |
[root@imysql ~]# /etc/init.d/nginx configtest nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful |
Confirm the configuration file is correct, execute the following command reload nginx, to take effect:
1 2 3 4 |
[root@imysql ~]# /etc/init.d/nginx reload [root@imysql ~]# /etc/init.d/nginx restart |
Done 🙂