centos_6.5 installation Nginx+php+mysql

Source: Internet
Author: User
Tags fpm install php install openssl openssl php script php source code sql error nginx server

Preparatory work
Install make
Yum-y install gcc automake autoconf libtool make
Installing g++
Yum Install gcc gcc-c++
The following officially begins
---------------------------------------------------------------------------
Generally we need to first install Pcre, Zlib, the former in order to rewrite rewrite, the latter in order to gzip compression.
Can be any directory, this article is selected/DATA/SOFT/SRC
One: Nginx installation
Cd/data/soft/src
1. Installing the Pcre Library
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/Download the latest pcre source package, download the compile and install the Pcre package using the command below:
Cd/data/soft/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.34.tar.gz
TAR-ZXVF pcre-8.34.tar.gz
CD pcre-8.34
./configure
Make
Make install
2. Installing the Zlib Library
http://zlib.net/zlib-1.2.8.tar.gz Download the latest zlib source package, download the compile and install the zlib package using the command below:
Cd/data/soft/src
wget http://zlib.net/zlib-1.2.8.tar.gz
TAR-ZXVF zlib-1.2.8.tar.gz
CD zlib-1.2.8
./configure
Make
Make install
3. Install SSL (some VPS does not install SSL by default)
Cd/data/soft/src
wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
TAR-ZXVF openssl-1.0.1c.tar.gz
Yum-y Install OpenSSL Openssl-devel
4. Installing Nginx
Nginx generally has two versions, the stable version and the development version, you can choose one of these two versions according to your purpose, below is the detailed steps of installing nginx into the/data/soft/nginx directory:
Cd/data/soft/src
wget http://nginx.org/download/nginx-1.4.2.tar.gz
TAR-ZXVF nginx-1.4.2.tar.gz
CD nginx-1.4.2
./configure--sbin-path=/data/soft/nginx/nginx \--conf-path=/data/soft/nginx/nginx.conf \--pid-path=/data/soft/ Nginx/nginx.pid \--with-http_ssl_module \--with-pcre=/data/src/pcre-8.34 \--with-zlib=/data/src/zlib-1.2.8 \-- With-openssl=/data/src/openssl-1.0.1c
Make
Make install
After successful installation, the/data/soft/nginx directory is as follows:
fastcgi.conf Koi-win Nginx.conf.default
Fastcgi.conf.default logs Scgi_params
Fastcgi_params Mime.types Scgi_params.default
Fastcgi_params.default Mime.types.default Uwsgi_params
HTML Nginx Uwsgi_params.default
Koi-utf nginx.conf Win-utf
5. Start
Ensure that the 80 port of the system is not occupied by other programs, run the/data/soft/nginx/nginx command to start Nginx,
Netstat-ano|grep 80
If you do not find the results, you will ignore this step if you have a result
Sudo/usr/local/nginx/nginx
Open the browser to access the IP of this machine if the browser appears Welcome to nginx! Indicates that Nginx is installed and running successfully.
Here Nginx installation is complete, if you just deal with static HTML will not continue to install, if you need to deal with PHP script, you also need to install PHP-FPM.
6.Nginx boot up
echo "/data/soft/nginx/sbin/nginx" >>/etc/rc.local
Two: Compile and install PHP-FPM
PHP-FPM is a PHP fastcgi manager that is only for PHP and can be downloaded in http://php-fpm.org/download.
PHP-FPM is actually a patch of PHP source code designed to integrate FASTCGI process management into a PHP package. It must be patch into your PHP source code and can be used after compiling and installing PHP.
The new version of PHP has been integrated PHP-FPM, is no longer a third-party package, recommended to use. PHP-FPM provides a better way to manage the PHP process, can effectively control memory and process, can be smooth overloaded PHP configuration, more than spawn-fcgi has more advantages, so by the official PHP included. In the./configure with the –ENABLE-FPM parameter can be opened PHP-FPM, the other parameters are configured PHP, the meaning of the specific options can be viewed here: http://www.php.net/manual/en/configure.about.php.
Pre-Installation Preparation
Execute under CentOS (automatically install GCC)
Yum-y install gcc automake autoconf libtool make
Yum-y Install gcc gcc-c++ glibc
Yum-y install libmcrypt-devel mhash-devel libxslt-devel \
Libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \
Zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel \
ncurses Ncurses-devel Curl curl-devel e2fsprogs e2fsprogs-devel \
krb5 krb5-devel libidn libidn-devel OpenSSL openssl-devel
1.PHP-FPM Installation (Recommended installation method)
Cd/data/soft/src
wget http://museum.php.net/php5/php-5.4.7.tar.gz
Tar zvxf php-5.4.7.tar.gz
CD php-5.4.7
./configure--prefix=/data/soft/php--enable-fpm--with-mcrypt \--enable-mbstring--disable-pdo--with-curl-- Disable-debug--disable-rpath \--enable-inline-optimization--with-bz2--with-zlib--enable-sockets \-- Enable-sysvsem--enable-sysvshm--enable-pcntl--enable-mbregex \--with-mhash--enable-zip--with-pcre-regex-- With-mysql--with-mysqli \--WITH-GD--with-jpeg-dir
Make all Install
2. The above completed the installation of PHP-FPM.
Here are the settings for the PHP-FPM running user
cd/data/soft/php
CP Etc/php-fpm.conf.default etc/php-fpm.conf
VI etc/php-fpm.conf
Modify
user = www
Group = www
If www user does not exist, add www user first
Groupadd www
Useradd-g www www
3. Modify Nginx configuration file to support PHP-FPM
Modify Nginx config file as, nginx.conf
Where the server segment adds the following configuration:
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
Location ~ \.php$ {
root/data/www; #项目根目录
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Include Fastcgi_params;
}
4. Create a test PHP file
Creating PHP Files
Under/data/www, create the index.php file and enter the following:
<?php
Echo Phpinfo ();
?>
5. Start the PHP-FPM service
/data/soft/php/sbin/php-fpm
To restart the Nginx server:
/data/nginx/nginx-s Reload
6.PHP-FPM Shutdown and restart
PHP-FPM off:
Kill-int ' Cat/data/soft/php/var/run/php-fpm.pid '
PHP-FPM Restart:
KILL-USR2 ' Cat/data/soft/php/var/run/php-fpm.pid '
7.PHP-FPM boot up
echo "/DATA/SOFT/PHP/SBIN/PHP-FPM" >>/etc/rc.local
Three: MySQL Installation
Cd/data/soft/src
wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.70.tar.gz
TAR-ZXVF mysql-5.1.70.tar.gz
CD mysql-5.1.70
Yum Install ncurses Ncurses-devel
./configure '--prefix=/data/soft/mysql '--without-debug '--with-charset=utf8 '--with-extra-charsets=all '-- Enable-assembler '--with-pthread '--enable-thread-safe-client '--with-mysqld-ldflags=-all-static '-- With-client-ldflags=-all-static '--with-big-tables '--with-readline '--with-ssl '--with-embedded-server '-- Enable-local-infile '--with-plugins=innobase ' make
Make install
To this MySQL is installed under the/data/soft/mysql path, below the beginning of MySQL configuration work
------------------------------------
Installing the MySQL options file
CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF
MySQL Setup boot from
Cp-r Support-files/mysql.server/etc/init.d/mysqld
/sbin/chkconfig--del mysqld
/sbin/chkconfig--add mysqld
Configure Permissions Table
Chown-r Mysql:mysql/data/soft/mysql
/data/soft/mysql/bin/mysql_install_db--user=mysql
Start MySQL
/etc/init.d/mysqld start
MySQL initialization configuration:
Export Path=/data/soft/mysql/bin: $PATH
/data/soft/mysql/bin/mysql_secure_installation
Note: The root password for MySQL is set as prompted here
Here the MySQL installation is complete and we start using the client connection to MySQL
If error:
SQL Error (1130): Host ' 192.168.1.100 ' isn't allowed to connect to this MySQL server
First, follow the steps below to log in to the MySQL server
To log in to MySQL, you need to switch to the MySQL bin directory under DOS to do the following:
#mysql-uroot-ppassword
Mysql>use MySQL;
Mysql>update User Set host = '% ' where user = ' root ';
Mysql>flush privileges;
Mysql>select ' host ', ' user ' from user where user= ' root ';
Mysql>quit
Ok. Remote Connection Successful!

centos_6.5 installation Nginx+php+mysql

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.