Dry centos6.5_nginx1.40_php5.57_mysql5.5.35 compile and install full record

Source: Internet
Author: User
Tags chmod fpm install php mcrypt openssl snmp iptables openldap

Http://www.unixdo.com/Unix_Linux/CentOS65_Nginx140_Php557_MySQL5535.html

Environment Description: CentOS 6.5 32-bit Nginx1.40 Php5.57 MySQL5.5.35

First, the preparatory work

Configure firewalls to allow firewalls to pass through the (sshd), WEB, 3306 (MYSQL) ports
Iptables-a input-p TCP--dport 80-j ACCEPT
Iptables-a input-p TCP--dport 3306-j ACCEPT
Iptables-a input-p TCP--dport 22-j ACCEPT
Iptables-a output-p TCP--sport 22-j ACCEPT
/etc/rc.d/init.d/iptables Save # Saving configuration

To turn off SELinux:

Vi/etc/selinux/config
#SELINUX =enforcing #注释掉
#SELINUXTYPE =targeted #注释掉
Selinux=disabled #增加
: Wq Save, exit
Reboot #重启系统


Second, the system contract

Software source code Package storage Location:/OPT Source Package Compilation installation location:/usr/local/software Name

Third, download the Software toolkit:

1, download Nginx (currently stable version)
Http://nginx.org/download/nginx-1.4.4.tar.gz
2, download pcre (support Nginx pseudo-static)
Ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.gz
4. Download MySQL5.5.35
Http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.35.tar.gz
5, download php-5.5.7 (currently the latest version)
Http://mirrors.sohu.com/php/php-5.5.7.tar.gz
6. Download CMake (MySQL compilation tool)
Http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
7. Download Libmcrypt (phplibmcrypt module)
Http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz

After the download is completed, it is transferred to the OPT directory and can be downloaded directly from the OPT directory using wget.

Iv. Yum installs common compilation tools and library files:

Yum install make apr* autoconf automake bzip2 bzip2-devel Curl curl-devel gcc gcc-c++ Gcc-g77 E2fsprogs E2fsprogs-devel ZL ib* zlib-devel OpenSSL openssl-devel pcre-devel gd gd-devel kernel keyutils patch perl kernel-headers compat* MPFR cpp gli BC Libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel Krb5-devel zlib-devel libxpm* libvpx libjpeg libpng zlib libxpm libxpm-devel t1lib libt1-devel freetype freetype-devel li bpng* libpng10 libpng10-devel libpng-devel php-common php-gd ncurses* ncurses-devel libtool* libtool-libs libxml2-devel p Atch glibc glibc-devel glib2 glib2-devel krb5 krb5-devel libevent libevent-devel libidn libidn-devel nss_ldap OpenLDAP ope Nldap-clients openldap-devel openldap-servers OpenSSL openssl-devel pspell-devel net-snmp* net-snmp-devel-y

Once all the installation packages have been downloaded and installed, you can start the installation.

V. Installation of CMake and MySQL:

Installing CMake
Cd/opt && tar zxvf cmake-2.8.8.tar.gz
CD cmake-2.8.8
./configure && make && make install

Install MySQL

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/opt
Tar zxvf mysql-5.5.35.tar.gz
CD mysql-5.5.35

Cmake-dcmake_install_prefix=/usr/local/mysql \
-dmysql_unix_addr=/tmp/mysql.sock \
-ddefault_charset=utf8 \
-DDEFAULT_COLLATION=UTF8_GENERAL_CI \

-dwith_extra_charsets=all \

-dwith_myisam_storage_engine=1 \
-dwith_innobase_storage_engine=1 \
-dwith_memory_storage_engine=1 \
-dwith_readline=1 \
-denabled_local_infile=1 \
-dmysql_datadir=/data/mysql \
-dmysql_user=mysql \
-dmysql_tcp_port=3306 \
-DSYSCONFDIR=/ETC \
-dinstall_sharedir=share

Make && make install

To start configuring MySQL after the installation is complete:

CP./SUPPORT-FILES/MY-HUGE.CNF/ETC/MY.CNF #拷贝配置文件 (Note: If the/etc directory has a my.cnf under the default, it can be overwritten directly) vi/etc/my.cnf #编辑配置文件, in the [mysqld] Section adds the following line DataDir =/data/mysql #添加MySQL数据库路径

: wq! #保存退出

Cd/usr/local/mysql

./scripts/mysql_install_db--user=mysql #生成mysql系统数据库cp./support-files/mysql.server/etc/rc.d/init.d/mysql # Add MySQL to the system boot chmod 755/etc/init.d/mysql #增加执行权限chkconfig mysql on #加入开机启动vi/etc/rc.d/init.d/mysql #编辑basedir =/usr/ Local/mysql #MySQL程序安装路径datadir =/data/mysql #MySQl数据库存放目录service mysqld start #启动vi/etc/profile # Add the MySQL service to the system environment variable: At the end of adding the following line export path= $PATH:/usr/local/mysql/bin:wq! #保存退出

The following line links the MYSLQ library file to the default location of the system, so you can compile software like PHP without specifying the MySQL library file address.

Ln-s/usr/local/mysql/include/mysql/usr/include/mysql

Reboot #需要重启系统, wait for the system to restart after the operation continues under the terminal command line mysql_secure_installation #设置Mysql密码根据提示按Y Enter and then input 2 times the password continue to press Y to enter, until the setup is complete or directly modify the password/ usr/local/mysql/bin/mysqladmin-u root-p Password "123456" #修改密码service mysqld restart #重启

To this, MySQL installation is complete!

Six, install Pcre and Nginx:

Install Pcre:

Cd/opt

Mkdir/usr/local/pcre #创建安装目录

Tar zxvf pcre-8.31.tar.gz

CD pcre-8.31

./configure--prefix=/usr/local/pcre #配置

Make && make install

Install Nginx:

Cd/opt

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.4.0.tar.gz

CD nginx-1.4.0

./configure--prefix=/usr/local/nginx--user=www--group=www--with-http_stub_status_module--with-openssl=/usr/-- with-pcre=/opt/pcre-8.31

Note:--with-pcre=/opt/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

Vii. installing Libmcrypt, JPEG, PNG, FreeType, and PHP:

Install Libmcrypt:

Cd/opt

Tar zxvf libmcrypt-2.5.8.tar.gz
CD libmcrypt-2.5.8
./configure && make && make install

Installing JPEG6
Mkdir/usr/local/jpeg6
Mkdir/usr/local/jpeg6/bin
Mkdir/usr/local/jpeg6/lib
Mkdir/usr/local/jpeg6/include
Mkdir/usr/local/jpeg6/man
Mkdir/usr/local/jpeg6/man/man1
Cd/opt
Tar zxf jpegsrc.v6b.tar.gz
CD jpeg-6b
./configure--prefix=/usr/local/jpeg6/--enable-shared--enable-static
Make && make install

Install PNG

Cd/opt

Tar zxvf libpng-1.6.10.tar.gz

./configure--prefix=/usr/local/png--enable-shared

Make && make install

Installing FreeType

Cd/opt

Tar zxvf freetype-2.5.3.tar.gz

CD freetype-2.5.3

./configure--prefix=/usr/local/freetype--enable-shared
Make && make install

Install PHP:

Cd/opt

Tar zxvf php-5.5.7.tar.gz

CD php-5.5.7

Mkdir-p/USR/LOCAL/PHP5

./configure--PREFIX=/USR/LOCAL/PHP5--with-config-file-path=/usr/local/php5/etc--with-mysql=/usr/local/mysql-- With-mysqli=/usr/local/mysql/bin/mysql_config--with-mysql-sock=/tmp/mysql.sock--with-gd--with-iconv--with-zlib --enable-xml--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--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-mcrypt--with-curl-- with-jpeg-dir=/usr/local/jpeg6/--with-png-dir=/usr/local/png--with-freetype-dir=/usr/local/freetype

Make && make install

To configure PHP:

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/OPT/PHP-5.5.7/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 #编辑配置文件
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.
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短标签

Configuration Nginx Support Phpvi/usr/local/nginx/conf/nginx.conf #编辑配置文件, the following changes should be made to the user www www; #首行user去掉注释, modify Nginx run group as www www; must be the same as the User,group configuration in/usr/local/php5/etc/php-fpm.conf, or PHP will run error index index.php Index.html index.htm; #添加index. php# Pass the PHP scripts to FastCGI server listening on 127.0.0.1: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;} #取消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 an absolute path/etc/init.d/ Nginx Restart #重启nginxcd/usr/local/nginx/html/#进入nginx默认网站根目录rm-rf/usr/local/nginx/html/* #删除默认测试页vi index.php #编辑 & lt;? Phpphpinfo ();? >:wq! #保存退出chown www.www/usr/local/nginx/html/-R #设置目录所有者chmod 700/usr/local/nginx/html/-R #设置目录权限shutdown-R now #重启系统

Open the server IP address in the browser, you will see the following interface, the configuration is successful

Server-related Operations Command service nginx restart #重启nginxservice mysql 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# ########################################################################### #备注: Nginx Default Site Directory is:/usr/local/nginx/ html/permission settings: chown www:www/usr/local/nginx/html/-rmysql Database directory is:/data/mysql permission settings: Chown mysql.mysql-r/data/mysql

Dry centos6.5_nginx1.40_php5.57_mysql5.5.35 compile and install full record

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.