Method for configuring Nginx php-fpm Drupal in CentOS 6.3

Source: Internet
Author: User
Tags anonymous curl fpm install php php language php download drupal phpmyadmin

All in accordance with the principle of simplicity to do, can be yum/rpm, resolutely do not compile manually, this deployment environment based on the CentOS 6.3 x86_64 system.


Update Yum

The code is as follows Copy Code

[Root@imysql ~]# yum-y Update
[Root@imysql ~]# Yum Install libaio-devel.x86_64

Installing the Curl Module

The code is as follows Copy Code

[Root@imysql ~]# Yum Install Curl-devel
[Root@imysql ~]# yum-y install libpng-devel libjpeg-devel freetype-devel gmp-devel libxml2-devel

Install Nginx

The code is as follows Copy Code

[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 ~]# Yum Install spawn-fcgi
[Root@imysql ~]# chkconfig Nginx on

Install PHP-FPM

The code is as follows Copy Code

[Root@imysql ~]# RPM-IVH RPM-UVH http://repo.webtatic.com/yum/el6/latest.rpm
[Root@imysql ~]# yum-y Install php54w

Configure nginx+php

/etc/nginx/nginx.conf configuration files can be made without any modifications.

Edit/etc/nginx/conf.d/default.conf, take this site as an example, the configuration file is as follows:

The code is as follows Copy Code

server {
Listen 80;
server_name Www.111cn.Net;

root/data/www/www.111cn.net/;
Index index.php index.htm index.html index.shtml;

Error_page 404/page_not_found;
Error_page 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 the configuration of the Nginx virtual host, as well as Drupal's rewrite rule configuration, simple and fast.
Start test


After each modification of the configuration file, remember to perform the following command to test the correctness of the configuration file:

The code is as follows Copy Code

[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

After confirming that the configuration file is correct, execute the following command overload Nginx to take effect, the above careful friend will find that the MySQL database is not installed because Drupal requires database support

Drupal is an open source Content Management Framework (CMF) written in the PHP language, made up of content management systems (CMS) and the PHP Development Framework (framework), so let's go ahead and install the MySQL database.

Installing the MySQL Database

Execute Yum program to install MySQL

The code is as follows Copy Code

1.yum install MySQL Mysql-server

Add MySQL Entry startup entries (this will automatically start MySQL when the system starts) and start the MySQL server immediately:

The code is as follows Copy Code

1.chkconfig--levels 235 mysqld on

2./etc/init.d/mysqld start

Set MySQL root account password:

The code is as follows Copy Code

1.mysql_secure_installation


Note:running all PARTS The This SCRIPT are recommended for all MySQL
SERVERS in PRODUCTION use! Please READ each step carefully!


In order to log into MySQL to secure it, we'll need the current
Password for the root user. If you ' ve just installed MySQL, and
You haven ' t set the root password yet, the password'll be blank,
So your should just press ENTER here.

Enter current password for root (enter for none):
OK, successfully used password, moving on ...

Setting The root password ensures that nobody can log into the MySQL
Root user without the proper authorisation.

Set root Password? [y/n] <--ENTER
New Password: <--your MySQL root password
Re-enter new password: <--your MySQL root password
Password Updated successfully!
Reloading privilege tables.
... success!


By default, a MySQL installation has a anonymous user, allowing anyone
To log into the MySQL without have to have a user account created for
them. This is intended only for testing, and to make the installation
Go a bit smoother. Should remove them before moving into a
Production environment.

Remove anonymous users? [y/n] <--ENTER
... success!

Normally, Root should only is allowed to connect from ' localhost '. This
Ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [y/n] <--ENTER
... success!

By default, the MySQL comes with a database named ' test ' that anyone can
Access. This is also intended a for testing, and should to be removed
Before moving into a production environment.

Remove test database and access to it? [y/n] <--ENTER
-Dropping test database ...
... success!
-Removing privileges on test database ...
... success!

Reloading the privilege tables would ensure that all changes made so far
would take effect immediately.

Reload privilege tables now? [y/n] <--ENTER
... success!

Cleaning up ...


All done! If you ' ve completed all of the above steps, your MySQL
Installation should now is secure.

The for using mysql!

Install phpMyAdmin

From phpMyAdmin official website: http://www.phpmyadmin.net/home_page/downloads.php Download the latest phpMyAdmin installation package, download to the site directory by default under/var/www/html/. After extracting the phpMyAdmin compressed package, find config.sample.inc.php renamed to config.inc.php, modify the configuration, the installation is complete.

The code is as follows Copy Code

[Root@imysql ~]# [Root@imysql ~]#/etc/init.d/nginx Reload
#或者restart
[Root@imysql ~]#/etc/init.d/nginx Restart

At this point, the configuration is complete!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.