Centos6.4 _ X64 compile and install php-5.4.17, nginx-1.4.2, mysql-5.6.13

Source: Internet
Author: User
Centos6.4 _ X64 compiler installation php-5.4.17, nginx-1.4.2, mysql-5.6.13 installation reference:

CentOS 6.3 Compilation and installation Nginx1.2.2 + mysql5.25a + PHP5.4.5

Http://www.dedecms.com/knowledge/servers/linux-bsd/2012/0819/8411.html

Record your own compilation and Installation notes:

Preparation:
1. configure the IP address, DNS, and gateway to ensure that the remote connection tool can be used to connect to the server.
Tutorial on setting IP addresses, gateways, and DNS in CentOS:
2. configure the firewall and enable port 80 and Port 3306
Vi/etc/sysconfig/iptables
-A input-m state -- state NEW-m tcp-p tcp -- dport 80-j ACCEPT # Allow port 80 to pass the firewall
-A input-m state -- state NEW-m tcp-p tcp -- dport 3306-j ACCEPT # Allow Port 3306 to pass the firewall
Note: Many users add these two rules to the last line of the firewall configuration, which causes firewall startup failure. the correct rule should be added to the default port 22.
The firewall rules are as follows:
System O & M reminder: qihang01 original content is copyrighted. For more information, see the source and original article links.
######################################## #################
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
* Filter
: Input accept [0: 0]
: Forward accept [0: 0]
: Output accept [0: 0]
-A input-m state -- state ESTABLISHED, RELATED-j ACCEPT
-A input-p icmp-j ACCEPT
-A input-I lo-j ACCEPT
-A input-m state -- state NEW-m tcp-p tcp -- dport 22-j ACCEPT
-A input-m state -- state NEW-m tcp-p tcp -- dport 80-j ACCEPT
-A input-m state -- state NEW-m tcp-p tcp -- dport 3306-j ACCEPT
-A input-j REJECT -- reject-with icmp-host-prohibited
-A forward-j REJECT -- reject-with icmp-host-prohibited
COMMIT
######################################## #################
/Etc/init. d/iptables restart # restart the firewall to make the configuration take effect.
3. disable SELINUX
Vi/etc/selinux/config
# SELINUX = enforcing # Comment out
# SELINUXTYPE = targeted # Comment out
SELINUX = disabled # Add
: Wq save, close
Shutdown-r now # restart the system
IV. system conventions
Software source code package storage location:/usr/local/src
Source code package compilation and installation location:/usr/local/software name
5. download the software package
1. download nginx (Current stable version)

2. download pcre (support for nginx pseudo-static)

4. download MySQL

5. Download php

6. download cmake (MySQL compilation tool)

7. download libmcrypt (PHPlibmcrypt module)

6. install the compilation tool and library file (use the CentOS yum command for installation)

Yum-y install make apr * autoconf automake curl-devel gcc-c ++ zlib-devel openssl-devel pcre-devel gd kernel keyutils patch perl kernel-headers compat * mpfr cpp glibc libgomp libstdc ++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm * freetype libstjpeg * libpng * php-common php-gd ncurses * libtool * libxml2 libxml2-devel patch

Installation
Use putty to remotely log on to the server.

1. install cmake
Cd/usr/local/src
Tar zxvf cmake-2.8.8.tar.gz
Cd cmake-2.8.8
./Configure
Make # compile
Make install # install

I installed cmake using yum.

========================================================== ====================

II. install mysql

The purpose of installing mysql here is to expand and compile pdo_mysql later, so only a few steps are set:
Groupadd mysql # Add a mysql Group
Useradd-g mysql-s/bin/false # Create a user mysql and add it to the mysql group. mysql users are not allowed to log on directly to the system.
Mkdir-p/data/mysql # Create a directory for storing MySQL databases
Chown-R mysql: mysql/data/mysql # set MySQL database directory permissions
Mkdir-p/usr/local/mysql # create the MySQL installation directory
Cd/usr/local/src
Tar zxvf mysql-5.6.13.tar.gz # extract
Cd mysql-5.6.13

Cmake.-DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DINSTALL_DATADIR =/usr/local/mysql/data-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = bytes-DEXTRA_CHARSETS = all-variables = 1

Parameter description:

-DCMAKE_INSTALL_PREFIX =/usr/local/mysql // installation directory
-DINSTALL_DATADIR =/usr/local/mysql/data // database storage directory
-DDEFAULT_CHARSET = utf8 // use the utf8 character
-DDEFAULT_COLLATION = utf8_general_ci // Check the character
-DEXTRA_CHARSETS = all // install all extended character sets
-DENABLED_LOCAL_INFILE = 1 // allow local data import

# Make

# Make install

3. install pcre

Cd/usr/local/src
Mkdir/usr/local/pcre # create the installation directory
Tar zxvf pcre-8.33.tar.gz
Cd pcre-8.33
./Configure -- prefix =/usr/local/pcre # configuration
Make
Make install

========================================================== ====================

Install Nginx

Cd/usr/local/src
Groupadd www # Add a www Group
Useradd-g www-s/bin/false # Create an nginx running account www and add it to the www group. www users are not allowed to log on to the system directly.
Tar zxvf nginx-1.2.2.tar.gz
Cd nginx-1.2.2
. /Configure -- prefix =/usr/local/nginx -- without-http_memcached_module -- user = www -- group = www -- with-http_stub_status_module -- with-openssl =/usr/-- with-pcre =/usr/local /src/pcre-8.31
Note: -- with-pcre =/usr/local/src/pcre-8.31 points to the path of the source package decompression, rather than the installation path, otherwise an error will be reported
Make
Make install
/Usr/local/nginx/sbin/nginx # start nginx
Enable nginx startup
Vi/etc/rc. d/init. d/nginx # create and edit the startup file and add the following content

========================================================== ====================
#! /Bin/bash
# Nginx Startup script for the Nginx HTTP Server
# It is v.0.0.2 version.
# Chkconfig:-85 15
# Description: Nginx is a high-performance web and proxy server.
# It has a lot of features, but it's not for everyone.
# Processname: nginx
# Pidfile:/var/run/nginx. pid
# Config:/usr/local/nginx/conf/nginx. conf
Nginxd =/usr/local/nginx/sbin/nginx
Nginx_config =/usr/local/nginx/conf/nginx. conf
Nginx_pid =/usr/local/nginx/logs/nginx. pid
RETVAL = 0
Prog = "nginx"
# Source function library.
./Etc/rc. d/init. d/functions
# Source networking configuration.
./Etc/sysconfig/network
# Check that networking is up.
[$ {NETWORKING} = "no"] & exit 0
[-X $ nginxd] | exit 0
# Start nginx daemons functions.
Start (){
If [-e $ nginx_pid]; then
Echo "nginx already running ...."
Exit 1
Fi
Echo-n $ "Starting $ prog :"
Daemon $ nginxd-c $ {nginx_config}
RETVAL =$?
Echo
[$ RETVAL = 0] & touch/var/lock/subsys/nginx
Return $ RETVAL
}
# Stop nginx daemons functions.
Stop (){
Echo-n $ "Stopping $ prog :"
Killproc $ nginxd
RETVAL =$?
Echo
[$ RETVAL = 0] & rm-f/var/lock/subsys/nginx/usr/local/nginx/logs/nginx. pid
}
Reload (){
Echo-n $ "Reloading $ prog :"
# Kill-HUP 'cat $ {nginx_pid }'
Killproc $ nginxd-HUP
RETVAL =$?
Echo
}
# See how we were called.
Case "$1" in
Start)
Start
;;
Stop)
Stop
;;
Reload)
Reload
;;
Restart)
Stop
Start
;;

Status)
Status $ prog
RETVAL =$?
;;
*)
Echo $ "Usage: $ prog {start | stop | restart | reload | status | help }"
Exit 1
Esac
Exit $ RETVAL
========================================================== ====================
: Wq! # Save and exit
Chmod 775/etc/rc. d/init. d/nginx # grant the file execution permission
Chkconfig nginx on # set startup
/Etc/rc. d/init. d/nginx restart # restart
Service nginx restart

========================================================== ====================
5. install libmcrypt
Cd/usr/local/src
Tar zxvf libmcrypt-2.5.8.tar.gz # extract
Cd libmcrypt-2.5.8 # go to the Directory
./Configure # configuration
Make # compile
Make install # install

========================================================== ====================

Install php

. /Configure -- prefix =/usr/local/php-5.4.17 -- with-config-file-path =/usr/local/php-5.4.17/etc -- with-gd -- with-iconv -- with-zlib -- enable-xml -- enable-bcmath -- enable-shmop -- enable-sysvsem -- enable-inline-optimization -- with-curlwrappers -- enable-mbregex -- enable-fpm -- enable-mbstring -- enable -ftp -- enable-gd-native-ttf -- with-openssl -- enable-pcntl -- enable-sockets -- with-xmlrpc -- enable-zip -- enable-soap -- without-pear -- -gettext -- enable-session -- with-curl

& -- Enable-sysvmsg -- enable-sysvsem -- enable-sysvshm # Here are the system modules that need to be enabled by the application. I installed the system in later compilation and did not add it during compilation *

Cp php. ini-production/usr/local/php5/etc/php. ini # Copy the php configuration file to the installation directory
Rm-rf/etc/php. ini # Delete the built-in configuration file of the system
Ln-s/usr/local/php5/etc/php. ini/etc/php. ini # add soft link
Cp/usr/local/php5/etc/php-fpm.conf.default/usr/local/php5/etc/php-fpm.conf # copy the template file as the php-fpm configuration file
Vi/usr/local/php5/etc/php-fpm.conf # Edit
User = www # set the php-fpm runtime account to www
Group = www # set the php-fpm running group to www
Pid = run/php-fpm.pid # Remove the semicolon above
Set the startup of php-fpm
Cp/usr/local/src/php-5.4.5/sapi/fpm/init. d. php-fpm/etc/rc. d/init. d/php-fpm # Copy php-fpm to the Startup directory
Chmod + x/etc/rc. d/init. d/php-fpm # Add execution permission
Chkconfig php-fpm on # set startup
Vi/usr/local/php5/etc/php. ini # Edit the configuration file
Find: disable_functions =
Changed to disable_functions = passthru, exec, system, chroot, scandir, chgrp, chown, shell_exec, proc_open, proc_get_status, ini_alter, ini_alter, rewrite, dl, openlog, syslog, readlink, symlink, delimiter, dll, popen, disk_free_space, checkdnsrr, checkdnsrr, getservbyname, getservbyport, delimiter, posix_ctermid, delimiter, delimiter, posix_getegid, delimiter, posix_getgrnam, posix_getgroups, upper, lower, lower, posix_getpid, lower, posix_getpwnam, lower, lower, posix_getsid, posix_getuid, lower, posix_kill, posix_mkfifo, lower, posix_setsid, posix_setuid, posix_strerror, posix_times, posix_ttyname, posix_uname
# List functions that can be disabled by PHP. if some programs need this function, they can be deleted and disabled.
System O & M reminder: qihang01 original content is copyrighted. For more information, see the source and original article links.
Locate:; date. timezone =
Change to: date. timezone = PRC # set the time zone
Find: expose_php = On
Change to: expose_php = OFF # Disable Display of php version information
Find: short_open_tag = Off
Changed to: short_open_tag = ON # php short labels supported

VII. Configure nginx to support php
Vi/usr/local/nginx/conf/nginx. conf # Modify the configuration file as follows:
User www; # remove comments from the first line of user and change the Nginx runtime group to www; the group configuration must be the same as the user in the/usr/local/php5/etc/php-fpm.conf, otherwise, an error occurred while running php.
Index. php index.html index.htm; # Add index. php
# Pass the PHP scripts to FastCGI server listening on Fig: 9000
#
Location ~ \. Php $ {
Root html;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
Include fastcgi_params;
}
# Cancel the location comment of the FastCGI server and change the parameter of the fastcgi_param line to $ document_root $ fastcgi_script_name or use the absolute path.
/Etc/init. d/nginx restart # restart nginx
Test
Cd/usr/local/nginx/html/# enter the default nginx website root directory
Rm-rf/usr/local/nginx/html/* # Delete the default test page
Vi index. php # Edit
Phpinfo ();
?>
: Wq! # Save and exit
Chown/usr/local/nginx/html/-R # set the directory owner
Chmod 700/usr/local/nginx/html/-R # set directory permissions
Shutdown-r now # restart the system

Server-related operation commands
Service nginx restart # restart nginx
Service mysqld restart # restart mysql
/Usr/local/php5/sbin/php-fpm # start php-fpm
/Etc/rc. d/init. d/php-fpm restart # restart php-fpm
/Etc/rc. d/init. d/php-fpm stop # stop php-fpm
/Etc/rc. d/init. d/php-fpm start # start php-fpm
######################################## #####################################
Note:
The default nginx site directory is/usr/local/nginx/html/
Permission settings: chown/usr/local/nginx/html/-R
The MySQL database directory is/data/mysql.
Permission settings: chown mysql. mysql-R/data/mysql
So far, CentOS 6.4 Compilation and installation of Nginx1.4.2 + MySQL5.6.13 + PHP5.4.17 have been completed

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.