centos6.4_x64 Compile and install php-5.4.17, nginx-1.4.2, mysql-5.6.13

Source: Internet
Author: User
Tags check character
Installation reference:

CentOS 6.3 Compile and install nginx1.2.2+mysql5.5.25a+php5.4.5

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

Record yourself compiling the installation Note:

Prepare the article:
First, configure IP, DNS, gateway, ensure the use of Remote Connection tool to connect to the server
CentOS set IP address, gateway, DNS tutorial:
Second, configure the firewall, open 80 port, 3306 port
Vi/etc/sysconfig/iptables
-A input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT #允许80端口通过防火墙
-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT #允许3306端口通过防火墙
Special Note: Many netizens add these two rules to the last line of the firewall configuration, causing the firewall to fail to start, the correct one should be added to the default 22 port under this rule
After adding the firewall rules as follows:
System operation and maintenance warm reminder: qihang01 original content copyright, reproduced please indicate the source and the original link
#########################################################
# Firewall configuration written by System-config-firewall
# Manual Customization of this file are 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 #最后重启防火墙使配置生效
Third, close SELinux
Vi/etc/selinux/config
#SELINUX =enforcing #注释掉
#SELINUXTYPE =targeted #注释掉
Selinux=disabled #增加
: Wq Save, close
Shutdown-r now #重启系统
Iv. System Conventions
Software source code Package storage location:/USR/LOCAL/SRC
Source Package Compilation Installation location:/usr/local/software Name
V. Download the package
1, download Nginx (currently stable version)

2, download pcre (support Nginx pseudo-static)

4. Download MySQL

5. Download PHP

6. Download CMake (MySQL compilation tool)

7. Download Libmcrypt (phplibmcrypt module)

Vi. install the compilation tools and library files (install using the CentOS Yum command)

Yum-y install make apr* autoconf automake curl-devel gcc gcc-c++ zlib-devel OpenSSL openssl-devel pcre-devel gd kernel ke Yutils Patch perl kernel-headers compat* MPFR cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_e Rr-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libxpm* freetype libjpeg* libpng* php-common php-gd ncurse s* libtool* libxml2 libxml2-devel patch

Installation article
The following is a remote login to the server using the Putty tool, which operates under the command line

First, install the CMake
Cd/usr/local/src
Tar zxvf cmake-2.8.8.tar.gz
CD cmake-2.8.8
./configure
Make #编译
Make install #安装

I am using Yum to install CMake

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

Second, install MySQL

The purpose of installing MySQL here is to post-scale the compilation Pdo_mysql so that only a few simple steps are set:
Groupadd MySQL #添加mysql组
useradd-g MySQL mysql-s/bin/false #创建用户mysql并加入到mysql组, does not allow MySQL users to log in directly to the system
Mkdir-p/data/mysql #创建MySQL数据库存放目录
Chown-r Mysql:mysql/data/mysql #设置MySQL数据库目录权限
Mkdir-p/usr/local/mysql #创建MySQL安装目录
Cd/usr/local/src
Tar zxvf mysql-5.6.13.tar.gz #解压
CD mysql-5.6.13

CMake. -dcmake_install_prefix=/usr/local/mysql-dinstall_datadir=/usr/local/mysql/data-ddefault_charset=utf8-ddefault_ Collation=utf8_general_ci-dextra_charsets=all-denabled_local_infile=1

Parameter description:

-dcmake_install_prefix=/usr/local/mysql//installation directory
-dinstall_datadir=/usr/local/mysql/data//Database storage directory
-ddefault_charset=utf8//using UTF8 characters
-DDEFAULT_COLLATION=UTF8_GENERAL_CI//Check character
-dextra_charsets=all//Install all extended character sets
-denabled_local_infile=1//Allow import of data from local

#make

#make Install

Third, installation Pcre

Cd/usr/local/src
Mkdir/usr/local/pcre #创建安装目录
Tar zxvf pcre-8.33.tar.gz
CD pcre-8.33
./configure--prefix=/usr/local/pcre #配置
Make
Make install

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

Installing Nginx

Cd/usr/local/src
Groupadd www #添加www组
Useradd-g www www-s/bin/false #创建nginx运行账户www并加入到www组, www users are not allowed to log in directly to the system
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 source package decompression path, not the installation path, otherwise it will be an error
Make
Make install
/usr/local/nginx/sbin/nginx #启动nginx
Set Nginx on Start
Vi/etc/rc.d/init.d/nginx #新建编辑启动文件添加下面内容

=======================================================
#!/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 are 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 "$" 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! #保存退出
chmod 775/etc/rc.d/init.d/nginx #赋予文件执行权限
Chkconfig Nginx on #设置开机启动
/etc/rc.d/init.d/nginx Restart #重启
Service Nginx Restart

=======================================================
V. Installation of Libmcrypt
Cd/usr/local/src
Tar zxvf libmcrypt-2.5.8.tar.gz #解压
CD libmcrypt-2.5.8 #进入目录
./configure #配置
Make #编译
Make 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--with-gettext-- Enable-session--with-curl

&&--enable-sysvmsg--enable-sysvsem--ENABLE-SYSVSHM #此处是应用程序所需开启的几个系统模块我是后期编译安装了并未在编译时增加 *

CP Php.ini-production/usr/local/php5/etc/php.ini #复制php配置文件到安装目录
Rm-rf/etc/php.ini #删除系统自带配置文件
Ln-s/usr/local/php5/etc/php.ini/etc/php.ini #添加软链接
cp/usr/local/php5/etc/php-fpm.conf.default/usr/local/php5/etc/php-fpm.conf #拷贝模板文件为php-fpm configuration file
Vi/usr/local/php5/etc/php-fpm.conf #编辑
user = www #设置php-fpm run account is www
Group = www #设置php-fpm run Group is www
PID = Run/php-fpm.pid #取消前面的分号
Set PHP-FPM boot up
CP/USR/LOCAL/SRC/PHP-5.4.5/SAPI/FPM/INIT.D.PHP-FPM/ETC/RC.D/INIT.D/PHP-FPM #拷贝php-fpm to startup directory
chmod +x/etc/rc.d/init.d/php-fpm #添加执行权限
Chkconfig PHP-FPM on #设置开机启动
Vi/usr/local/php5/etc/php.ini #编辑配置文件
Found: Disable_functions =
Modified to: Disable_functions = Passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini _alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server, Escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space, POSIX_CTERMID,POSIX_GET_LAST_ERROR,POSIX_GETCWD, Posix_getegid,posix_geteuid,posix_getgid, Posix_getgrgid,posix_ Getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, Posix_getppid,posix_getpwnam, Posix_getpwuid, Posix_getrlimit, Posix_getsid,posix_getuid,posix_isatty, Posix_kill,posix_mkfifo,posix_setegid, Posix_seteuid,posix_setgid, Posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname, Posix_uname
#列出PHP可以禁用的函数, if some programs need to use this function, you can delete, cancel disable.
System operation and maintenance warm reminder: qihang01 original content copyright, reproduced please indicate the source and the original link
Found:;d Ate.timezone =
Modified to: Date.timezone = PRC #设置时区
Found: expose_php = On
Modified to: expose_php = OFF #禁止显示php版本的信息
Found: Short_open_tag = Off
Modified to: Short_open_tag = on #支持php短标签

Seven, the configuration nginx support PHP
vi/usr/local/nginx/conf/nginx.conf #编辑配置文件, you need to make the following changes
user www www; #首行user去掉注释, modify nginx run group to www www; must be the same as the User,group configuration in/usr/local/php5/etc/php-fpm.conf, or PHP run Error
index index.php index.html index.htm; Add index.php
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
Location ~ \.php$ {
Root HT ml
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
include Fastcgi_params;
}
#取消FastCGI the comment for the server section location, and note the parameters of the Fastcgi_param row, change to $document_root$fastcgi_script_name, or use the absolute path
/etc/init.d/nginx Restart #重启nginx
Test article
cd/usr/local/nginx/html/#进入nginx默认网站根目录
rm-rf/usr/local/nginx/ html/* #删除默认测试页
VI index.php #编辑
!--? php
phpinfo ();
?
: wq! #保存退出
chown/usr/local/nginx/html/-R #设置目录所有者
chmod 700/usr/local/nginx/html/-R #设置目录权限
Shutdown-r now# reboot System

Server-related Operations commands
Service Nginx Restart #重启nginx
Service mysqld Restart #重启mysql
/USR/LOCAL/PHP5/SBIN/PHP-FPM #启动php-FPM
/ETC/RC.D/INIT.D/PHP-FPM Restart #重启php-fpm
/ETC/RC.D/INIT.D/PHP-FPM Stop #停止php-FPM
/ETC/RC.D/INIT.D/PHP-FPM Start #启动php-fpm
#############################################################################
Note:
Nginx Default Site Directory is:/usr/local/nginx/html/
Permission settings: chown/usr/local/nginx/html/-R
MySQL database directory is:/data/mysql
Permission settings: Chown mysql.mysql-r/data/mysql
At this point, the CentOS 6.4 compilation installation nginx1.4.2+mysql5.6.13+php5.4.17 completed

  • 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.