Prepare the article:
CentOS 7.0 System installation Configuration Diagram tutorial
Http://www.jb51.net/os/188487.html
First, configure the firewall, open 80 ports, 3306 ports
CentOS 7.0 uses firewall as a firewall by default, and this is iptables firewall instead.
1. Close firewall:
Systemctl Stop Firewalld.service #stop firewall
Systemctl Disable Firewalld.service #Disable firewall boot
2. Install iptables Firewall
Yum Install iptables-services #install
Vi/etc/sysconfig/iptables #Edit the firewall configuration file
# Firewall configuration written by System-config-firewall
# Manual Customization to this file is not recommended.*filter
: INPUT ACCEPT [0:0]
: FORWARD ACCEPT [0:0]
: OUTPUT ACCEPT [0:0]
-A input-m State--state Establi Shed,related-j ACCEPT
-a input-p icmp-j ACCEPT-a
input-i lo-j ACCEPT
-a input-m state--state new-m TC P-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 Forwa Rd-j REJECT--reject-with icmp-host-prohibited
COMMIT
: wq! #Save exit
Systemctl Restart Iptables.service #Last restart the firewall to make the configuration take effect
Systemctl Enable Iptables.service #Set the firewall to boot
Second, close SELinux
Vi/etc/selinux/config
#SELINUX =enforcing #Comment out
#SELINUXTYPE =targeted #Comment out
Selinux=disabled #add
: wq! #Save exit
Setenforce 0 # Make the configuration take effect immediately
Third, the system agreement
Software source code Package storage location:/USR/LOCAL/SRC
Source Package Compile Installation location:/usr/local/software Name
Four, download the software package
1, download Nginx (currently stable version)
Http://nginx.org/download/nginx-1.6.0.tar.gz
2, download MySQL
Http://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.19.tar.gz
3, download PHP
Http://cn2.php.net/distributions/php-5.5.14.tar.gz
4, download pcre (support nginx pseudo static)
Ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz
5, download OpenSSL (nginx extension)
Http://www.openssl.org/source/openssl-1.0.1h.tar.gz
6, download zlib (nginx extension)
Http://zlib.net/zlib-1.2.8.tar.gz
7, download cmake (MySQL compiler Tool)
Http://www.cmake.org/files/v2.8/cmake-2.8.11.2.tar.gz
8, download libmcrypt (PHP extension)
Http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
9, download yasm (PHP extension)
Http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
10, t1lib (PHP extension)
Ftp://sunsite.unc.edu/pub/Linux/libs/graphics/t1lib-5.1.2.tar.gz
11, download the GD library installation package
Https://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz
12, LIBVPX (GD library needs)
https://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2
13, TIFF (GD library needs)
Http://download.osgeo.org/libtiff/tiff-4.0.3.tar.gz
14, libpng (GD library needs)
Ftp://ftp.simplesystems.org/pub/png/src/libpng16/libpng-1.6.12.tar.gz
15, FreeType (GD library needs)
Http://ring.u-toyama.ac.jp/archives/graphics/freetype/freetype2/freetype-2.5.3.tar.gz
16, JPEGSRC (GD library needs)
Http://www.ijg.org/files/jpegsrc.v9a.tar.gz
The above packages are uploaded to the/USR/LOCAL/SRC directory using the WinSCP tool
WINSCP Download Address: http://winscp.net/download/winscp554.zip
Installation of compilation tools and library files (installed using the yum command)
Yum install-y apr* autoconf automake bison bzip2 bzip2* cloog-ppl compat* cpp Curl Curl-devel fontconfig Fontconfig-devel FreeType freetype* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibc kernel kernel-headers keyutils ke Yutils-libs-devel krb5-devel libcom_err-devel libpng libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++- Devel libtool* libgomp libxml2 libxml2-devel libxpm* libtiff libtiff* make MPFR ncurses* ntp OpenSSL openssl-devel patch p Cre-devel perl php-common php-gd policycoreutils telnet t1lib t1lib* nasm nasm* wget zlib-devel
Installation article
The following is a remote login to the server with the Putty tool, operating below the command line
First, install MySQL
1. Installation CMake
Cd/usr/local/src
Tar zxvf cmake-2.8.11.2.tar.gz
CD cmake-2.8.11.2
./configure
Make
Make install
2, install MySQL
Groupadd MySQL #add mysql group
Useradd-g MySQL mysql-s/bin/false #Create user mysql and join the mysql group, MySQL users are not allowed to log on directly to the system
Mkdir-p/data/mysql #Create a MySQL database storage directory
Chown-r Mysql: mysql/data/mysql #Set MySQL database storage directory permissions
Mkdir-p/usr/local/mysql #Create MySQL installation directory
CD/USR/LOCAL/SRC #Enter the package storage directory
Tar zxvf mysql-5.6.19.tar.gz #Unzip
CD mysql-5.6.19 #Enter the directory
CMake. -dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/data/mysql-dsysconfdir=/etc #Configuration
Make #Compile
Make install #install
Rm-rf/etc/my.cnf # Delete the system default configuration file (not deleted if default is not)
Cd/usr/local/mysql #Enter the MySQL installation directory
./scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql--datadir=/data/mysql #generate mysql system database
Soft connection of ln-s/usr/local/mysql/my.cnf/etc/my.cnf #Add to /etc Directory
CP./SUPPORT-FILES/MYSQL.SERVER/ETC/RC.D/INIT.D/MYSQLD #Add Mysql to the system to start
Chmod 755/etc/init.d/mysqld #Add execute permission
Chkconfig mysqld on #Add boot
Vi/etc/rc.d/init.d/mysqld #edit
Basedir=/usr/local/mysql #MySQL program installation path
Datadir=/data/mysql #MySQl database storage directory
: wq! #Save exit
Service mysqld Start #Start
Vi/etc/profile #Add the mysql service to the system environment variable: Add the following line at the end
Export path= $PATH:/usr/local/mysql/bin
: wq! #Save exit
Source/etc/profile # Make the configuration take effect immediately
The following two lines link the MYSLQ library file to the default location of the system, so that you can compile software such as PHP without specifying MySQL's library file address.
Ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql
Ln-s/usr/local/mysql/include/mysql/usr/include/mysql
Mkdir/var/lib/mysql #Create directory
Ln-s/tmp/mysql.sock/var/lib/mysql/mysql.sock #Add soft links
Mysql_secure_installation #Set Mysql password, enter 2 times password according to the prompts Y return
Second, install Nginx
1. Installation Pcre
Cd/usr/local/src
Mkdir/usr/local/pcre
Tar zxvf pcre-8.35.tar.gz
CD pcre-8.35
./configure--prefix=/usr/local/pcre
Make
Make install
2. Installation OpenSSL
Cd/usr/local/src
Mkdir/usr/local/openssl
Tar zxvf openssl-1.0.1h.tar.gz
CD openssl-1.0.1h
./config--prefix=/usr/local/openssl
Make
Make install
Vi/etc/profile
Export path= $PATH:/usr/local/openssl/bin
: wq!
Source/etc/profile
3. Installation Zlib
Cd/usr/local/src
Mkdir/usr/local/zlib
Tar zxvf zlib-1.2.8.tar.gz
CD zlib-1.2.8
./configure--prefix=/usr/local/zlib
Make
Make install
4. Installation Nginx
Groupadd www
Useradd-g www www-s/bin/false
Cd/usr/local/src
Tar zxvf nginx-1.6.0.tar.gz
CD nginx-1.6.0
./configure--prefix=/usr/local/nginx--without-http_memcached_module--user=www--group=www--with-http_stub_ Status_module--with-http_ssl_module--with-http_gzip_static_module--with-openssl=/usr/local/src/openssl-1.0.1h- -with-zlib=/usr/local/src/zlib-1.2.8--with-pcre=/usr/local/src/pcre-8.35
Note:--with-openssl=/usr/local/src/openssl-1.0.1h--with-zlib=/usr/local/src/zlib-1.2.8--with-pcre=/usr/local/src /pcre-8.35 Point is the source package decompression path, not the installation path, otherwise it will error
Make
Make install
/usr/local/nginx/sbin/nginx #start Nginx
Set Nginx Boot
Vi/etc/rc.d/init.d/nginx #Edit the startup file to add the following
#!/bin/sh # # nginx - this script starts and stops the nginx daemon # # chkconfig: - 85 15 # description: Nginx is an HTTP(S) server, HTTP(S) reverse \ # proxy and IMAP/POP3 proxy server # processname: nginx # config: /etc/nginx/nginx.conf # config: /usr/local/nginx/conf/nginx.conf # pidfile: /usr/local/nginx/logs/nginx.pid # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx" prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx make_dirs() { # make required directories user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -` if [ -z "`grep $user /etc/passwd`" ]; then useradd -M -s /bin/nologin $user fi options=`$nginx -V 2>&1 | grep 'configure arguments:'` for opt in $options; do if [ `echo $opt | grep '.*-temp-path'` ]; then value=`echo $opt | cut -d "=" -f 2` if [ ! -d "$value" ]; then # echo "creating" $value mkdir -p $value && chown -R $user $value fi fi done } start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs echo -n $"Starting $prog: " daemon $nginx -c $NGINX_CONF_FILE retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog: " killproc $prog -QUIT
retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { #configtest || return $? stop
sleep 1
start
} reload() { #configtest || return $? echo -n $"Reloading $prog: " killproc $nginx -HUP
RETVAL=$? echo } force_reload() {
restart
} configtest() { $nginx -t -c $NGINX_CONF_FILE } rh_status() {
status $prog } rh_status_q() {
rh_status >/dev/null 2>&1
} case "$1" in start)
rh_status_q && exit 0 $1 ;;
stop)
rh_status_q || exit 0 $1 ;;
restart|configtest) $1 ;;
reload)
rh_status_q || exit 7 $1 ;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" exit 2 esac
: wq! #Save exit
Chmod 775/etc/rc.d/init.d/nginx #Import file execution permission
Chkconfig Nginx on #Set boot
/etc/rc.d/init.d/nginx Restart #restart
When you open the server IP address in the browser, you will see the following interface, which indicates that the Nginx installation was successful.
Third, the installation of PHP
1. Installation Yasm
Cd/usr/local/src
Tar zxvf yasm-1.2.0.tar.gz
CD yasm-1.2.0
./configure
Make
Make install
2. Installation Libmcrypt
Cd/usr/local/src
Tar zxvf libmcrypt-2.5.8.tar.gz
CD libmcrypt-2.5.8
./configure
Make
Make install
3. Installation LIBVPX
Cd/usr/local/src
Tar xvf libvpx-v1.3.0.tar.bz2
CD libvpx-v1.3.0
./configure--PREFIX=/USR/LOCAL/LIBVPX--enable-shared--ENABLE-VP9
Make
Make install
4. Install TIFF
Cd/usr/local/src
Tar zxvf tiff-4.0.3.tar.gz
CD tiff-4.0.3
./configure--prefix=/usr/local/tiff--enable-shared
Make
Make install
5. Installation libpng
Cd/usr/local/src
Tar zxvf libpng-1.6.12.tar.gz
CD libpng-1.6.12
./configure--prefix=/usr/local/libpng--enable-shared
Make
Make install
6. Installation FreeType
Cd/usr/local/src
Tar zxvf freetype-2.5.3.tar.gz
CD freetype-2.5.3
./configure--prefix=/usr/local/freetype--enable-shared
Make #compile
Make install #install
7. Install JPEG
Cd/usr/local/src
Tar zxvf jpegsrc.v9a.tar.gz
CD jpeg-9a
./configure--prefix=/usr/local/jpeg--enable-shared
Make #compile
Make install #install
8. Installation LIBGD
Cd/usr/local/src
Tar zxvf libgd-2.1.0.tar.gz #unzip
CD libgd-2.1.0 #enter the directory
./configure--PREFIX=/USR/LOCAL/LIBGD--enable-shared--with-jpeg=/usr/local/jpeg--with-png=/usr/local/libpng- With-freetype=/usr/local/freetype--with-fontconfig=/usr/local/freetype--with-xpm=/usr/--with-tiff=/usr/local/ TIFF--with-vpx=/usr/local/libvpx #Configuration
Make #compile
Make install #install
9. Installation T1lib
Cd/usr/local/src
Tar zxvf t1lib-5.1.2.tar.gz
CD t1lib-5.1.2
./configure--prefix=/usr/local/t1lib--enable-shared
Make Without_doc
Make install
10. Install PHP
Note: If the system is 64 bits, please perform the following two commands, or install PHP will be wrong (32-bit system does not need to do)
\cp-frp/usr/lib64/libltdl.so*/usr/lib/
\cp-frp/usr/lib64/libxpm.so*/usr/lib/
Cd/usr/local/src
TAR-ZVXF php-5.5.14.tar.gz
CD php-5.5.14
Export Ld_library_path=/usr/local/libgd/lib
./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql-- With-mysqli=/usr/local/mysql/bin/mysql_config--with-mysql-sock=/tmp/mysql.sock--with-pdo-mysql=/usr/local/ MySQL--with-gd--with-png-dir=/usr/local/libpng--with-jpeg-dir=/usr/local/jpeg--with-freetype-dir=/usr/local/ FreeType--with-xpm-dir=/usr/--with-vpx-dir=/usr/local/libvpx/--with-zlib-dir=/usr/local/zlib--with-t1lib=/usr/ Local/t1lib--with-iconv--enable-libxml--enable-xml--enable-bcmath--enable-shmop-- Enable-inline-optimization--enable-opcache--enable-mbregex--enable-fpm--enable-mbstring--enable-ftp-- Enable-gd-native-ttf--with-openssl--enable-pcntl--enable-sockets--with-xmlrpc--enable-zip-- Without-pear--with-gettext--enable-session--with-mcrypt--with-curl--enable-ctype #配置
Make #compile
Make install #install
CP Php.ini-production/usr/local/php/etc/php.ini #Copy the php configuration file to the installation directory
Rm-rf/etc/php.ini # Delete the system's own configuration file
Ln-s/usr/local/php/etc/php.ini/etc/php.ini #Add a soft link to the /etc Directory
Cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf #copy template file for php-fpm configuration file
Ln-s/usr/local/php/etc/php-fpm.conf/etc/php-fpm.conf #Add a soft connection to the /etc Directory
Vi/usr/local/php/etc/php-fpm.conf #Edit
User = www #set php-fpm running account is www
Group = www #set php-fpm run Group is www
PID = Run/php-fpm.pid #Cancel the preceding semicolon
: wq! #Save exit
Set PHP-FPM boot
CP/USR/LOCAL/SRC/PHP-5.5.14/SAPI/FPM/INIT.D.PHP-FPM/ETC/RC.D/INIT.D/PHP-FPM #copy php-fpm to startup directory
Chmod +x/etc/rc.d/init.d/php-fpm #Add Execute Permissions
Chkconfig PHP-FPM on #Set boot up
Vi/usr/local/php/etc/php.ini #Edit Profile
Find: Disable_functions =
Modified to: Disable_functions = Passthru, exec, system, chroot, scandir, chgrp, chown, shell_exec, proc_open, proc_get_status, ini_alter, inio_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
#Listing functions that can be disabled by PHP, if some programs need to use this function, you can remove it and disable it.
Find:;d Ate.timezone =
Modified as: Date.timezone = PRC #Set time zone
Find: expose_php = On
Modified to: expose_php = off # disables display of php version information
Find: Short_open_tag = Off
Modified to: Short_open_tag = on #Support php short tags
Find Opcache.enable=0
Modified to Opcache.enable=1 #phpSupport opcode cache
Find: Opcache.enable_cli=1 #phpSupport opcode cache
Modified to: opcache.enable_cli=0
Add on last line: Zend_extension=opcache.so #Enable opcode caching
: wq! #Save exit
Configure Nginx to support PHP
Vi/usr/local/nginx/conf/nginx.conf
Modifying the/usr/local/nginx/conf/nginx.conf configuration file requires the following modifications
User www www. #user remove the comment, modify Nginx run group is www www; must be the same as the User, group configuration in/usr/local/php/etc/php-fpm.conf, otherwise PHP will run wrong
Index index.html index.htm index.php; #addindex.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;
}
# cancelFastCGI the comments in the Location Server section, note fastcgi_param the parameters of the row, change to $document_root$fastcgi_script_name, or use an absolute path
/etc/init.d/nginx Restart # Restart nginx
Service PHP-FPM start #Start php-fpm
Test article
Cd/usr/local/nginx/html/#Enter the default website root directory of nginx
Rm-rf/usr/local/nginx/html/* # Delete the default test page
VI index.php #create index. php file
: wq! #Save exit
Chown www.www/usr/local/nginx/html/-R #Set Directory Owner
Chmod 700/usr/local/nginx/html/-R #Set directory permissions
Open the server IP address in the browser and see the following interface
At this point, CentOS 7.0 compiles the installation nginx1.6.0+mysql5.6.19+php5.5.14 tutorial complete.