Configuring a local Yum source with a system-mirrored file
1, using WinSCP.exe and other tools upload system image files Rhel-server-7.0-x86_64-dvd.iso to/usr/local/src directory
2. Connect to Rhel server remotely using Putty.exe tool
3. Mount System image files
Mkdir/media/cdrom #新建镜像文件挂载目录
CD/USR/LOCAL/SRC #进入系统镜像文件存放目录
LS #列出目录文件, you can see the system image file just uploaded
Mount-t Iso9660-o Loop/usr/local/src/rhel-server-7.0-x86_64-dvd.iso/media/cdrom #挂载系统镜像
Cd/media/cdrom #进入挂载目录, use the LS command to see that a file exists
Note: Umount/media/cdrom #卸载系统镜像
4, set up automatically mounted system image files
Vi/etc/fstab #添加以下代码. Enable automatic mount on boot
/usr/local/src/rhel-server-7.0-x86_64-dvd.iso/media/cdrom iso9660 defaults,ro,loop 0 0
Note: iso9660 use df-t to view
5. Configure local Yum Source
Cd/etc/yum.repos.d/#进入yum配置目录
Touch Rhel-media.repo #建立yum配置文件
VI Rhel-media.repo #编辑配置文件, add the following
name=red Hat Enterprise Linux 7.0 #自定义名称
Baseurl=file:///media/cdrom #本地光盘挂载路径
Enabled=1 #启用yum源, 0 is not enabled, 1 is enabled
Gpgcheck=1 #检查GPG-key,0 for no check, 1 for inspection
Gpgkey=file:///media/cdrom/rpm-gpg-key-redhat-release #GPG-key Path
Yum Makecache #缓存本地yum源中的软件包信息
You can now install the software automatically using the Yum command.
Second, configure the firewall, open 80 ports, 3306 ports
RHEL 7.0 uses firewall as a firewall by default, and this is iptables firewall instead.
Systemctl Stop Firewalld.service #停止firewall
Systemctl Disable Firewalld.service #禁止firewall开机启动
2. Install iptables Firewall
Yum Install iptables-services #安装
Vi/etc/sysconfig/iptables #编辑防火墙配置文件
# Firewall configuration written by System-config-firewall
# Manual Customization of this file is not recommended.
-A input-m state--state established,related-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
Systemctl Restart Firewalld.service #最后重启防火墙使配置生效
#SELINUXTYPE =targeted #注释掉
Software source code Package storage location:/USR/LOCAL/SRC
Source Package Compile Installation location:/usr/local/software Name
Http://nginx.org/download/nginx-1.6.0.tar.gz
Http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.19.tar.gz
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://download.savannah.gnu.org/releases/freetype/ft2demos-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
VI. installation of compilation tools and library files (installed using the yum command)
Yum install-y apr* autoconf automake bison cloog-ppl compat* cpp Curl curl-devel fontconfig fontconfig-devel freetype fre etype* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibc kernel kernel-headers keyutils keyutils-libs-d Evel Krb5-devel libcom_err-devel libpng* libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* Libgomp LIBXML2 libxml2-devel libxpm* libtiff libtiff* make MPFR ncurses* ntp OpenSSL openssl-devel patch pcre-devel perl php-comm On php-gd policycoreutils telnet nasm nasm* wget zlib-devel
System Yun-wei www.osyunwei.com warm reminder: qihang01 original Content © Copyright, reproduced please indicate the source and the original chain
The following is a remote login to the server with the Putty tool, operating below the command line
Tar zxvf cmake-2.8.11.2.tar.gz
useradd-g MySQL mysql-s/bin/false #创建用户mysql并加入到mysql组, MySQL users are not allowed to log on 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.19.tar.gz #解压
CMake. -dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/data/mysql-dsysconfdir=/etc #配置
Rm-rf/etc/my.cnf #删除系统默认的配置文件 (not deleted if default is not)
Cd/usr/local/mysql #进入MySQL安装目录
./scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql--datadir=/data/mysql #生成mysql系统数据库
Soft connection of ln-s/usr/local/mysql/my.cnf/etc/my.cnf #添加到/etc Directory
CP./SUPPORT-FILES/MYSQL.SERVER/ETC/RC.D/INIT.D/MYSQLD #把Mysql加入系统启动
chmod 755/etc/init.d/mysqld #增加执行权限
Chkconfig mysqld on #加入开机启动
Vi/etc/rc.d/init.d/mysqld #编辑
Basedir=/usr/local/mysql #MySQL程序安装路径
Datadir=/data/mysql #MySQl数据库存放目录
Vi/etc/profile #把mysql服务加入系统环境变量: Add the following line at the end
Export path= $PATH:/usr/local/mysql/bin
Source/etc/profile #使配置立即生效
#下面这两行把myslq的库文件链接到系统默认的位置 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 #创建目录
Ln-s/tmp/mysql.sock/var/lib/mysql/mysql.sock #添加软链接
Mysql_secure_installation #设置Mysql密码, enter 2 times password according to the prompts Y return
Tar zxvf pcre-8.35.tar.gz
./configure--prefix=/usr/local/pcre
Tar zxvf openssl-1.0.1h.tar.gz
./config--prefix=/usr/local/openssl
Vi/etc/profile #把openssl服务加入系统环境变量: Add the following line at the end
Export path= $PATH:/usr/local/openssl/bin
Source/etc/profile #使配置立即生效
Tar zxvf zlib-1.2.8.tar.gz
./configure--prefix=/usr/local/zlib
Useradd-g www www-s/bin/false
Tar zxvf nginx-1.6.0.tar.gz
./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
/usr/local/nginx/sbin/nginx #启动Nginx
Vi/etc/rc.d/init.d/nginx #编辑启动文件添加下面内容
############################################################
# Nginx-this script starts and stops the Nginx daemon
# Description:nginx is a HTTP (s) server, HTTP (s) reverse
# Proxy and IMAP/POP3 proxy server
# 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.
# Check that networking are up.
["$NETWORKING" = "no"] && exit 0
nginx= "/usr/local/nginx/sbin/nginx"
Nginx_conf_file= "/usr/local/nginx/conf/nginx.conf"
[-f/etc/sysconfig/nginx] &&. /etc/sysconfig/nginx
Lockfile=/var/lock/subsys/nginx
# 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
Options= ' $nginx-v 2>&1 | grep ' Configure arguments: '
for opt in $options; Todo
If [' Echo $opt | grep '. *-temp-path ']; Then
Value= ' echo $opt | Cut-d "=" F 2 '
Mkdir-p $value && chown-r $user $value
[f $NGINX _conf_file] | | Exit 6
Echo-n $ "Starting $prog:"
Daemon $nginx-C $NGINX _conf_file
[$retval-eq 0] && Touch $lockfile
Echo-n $ "Stopping $prog:"
[$retval-eq 0] && rm-f $lockfile
#configtest | | Return $?
#configtest | | Return $?
Echo-n $ "Reloading $prog:"
$nginx-T-C $NGINX _conf_file
Rh_status >/dev/null 2>&1
echo $ "Usage: $ {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
############################################################
System Yun-wei www.osyunwei.com warm reminder: qihang01 original Content © Copyright, reproduced please indicate the source and the original chain
chmod 775/etc/rc.d/init.d/nginx #赋予文件执行权限
Chkconfig Nginx on #设置开机启动
/etc/rc.d/init.d/nginx Restart #重启
Third, the installation of PHP
Tar zxvf yasm-1.2.0.tar.gz
2. Installation Libmcrypt
Tar zxvf libmcrypt-2.5.8.tar.gz
Tar xvf libvpx-v1.3.0.tar.bz2
./configure--PREFIX=/USR/LOCAL/LIBVPX--enable-shared--ENABLE-VP9
Tar zxvf tiff-4.0.3.tar.gz
./configure--prefix=/usr/local/tiff--enable-shared
Tar zxvf libpng-1.6.12.tar.gz
./configure--prefix=/usr/local/libpng--enable-shared
Tar zxvf freetype-2.5.3.tar.gz
./configure--prefix=/usr/local/freetype--enable-shared
Tar zxvf jpegsrc.v9a.tar.gz
./configure--prefix=/usr/local/jpeg--enable-shared
Tar zxvf libgd-2.1.0.tar.gz #解压
./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 #配置
Tar zxvf t1lib-5.1.2.tar.gz
./configure--prefix=/usr/local/t1lib--enable-shared
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)
Ln-s/usr/lib64/libltdl.so/usr/lib/libltdl.so
cp-frp/usr/lib64/libxpm.so*/usr/lib/
TAR-ZVXF php-5.5.14.tar.gz
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 #配置
CP Php.ini-production/usr/local/php/etc/php.ini #复制php配置文件到安装目录
Rm-rf/etc/php.ini #删除系统自带配置文件
Ln-s/usr/local/php/etc/php.ini/etc/php.ini #添加软链接到/etc Directory
cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf #拷贝模板文件为php-fpm configuration file
Ln-s/usr/local/php/etc/php-fpm.conf/etc/php-fpm.conf #添加软连接到/etc Directory
Vi/usr/local/php/etc/php-fpm.conf #编辑
user = www #设置php-fpm running account is www
Group = www #设置php-fpm run Group is www
PID = Run/php-fpm.pid #取消前面的分号
CP/USR/LOCAL/SRC/PHP-5.5.14/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/php/etc/php.ini #编辑配置文件
Find: 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 remove it and disable it.
Modified as: Date.timezone = PRC #设置时区
Modified to: expose_php = off #禁止显示php版本的信息
Find: Short_open_tag = Off
Modified to: Short_open_tag = on #支持php短标签
Modified to Opcache.enable=1 #php支持opcode缓存
Find: Opcache.enable_cli=1 #php支持opcode缓存
Modified to: opcache.enable_cli=0
Add on last line: Zend_extension=opcache.so #开启opcode缓存功能
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去掉注释, 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; #添加index. php
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
#取消FastCGI 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 #重启nginx
Service PHP-FPM start #启动php-fpm
cd/usr/local/nginx/html/#进入nginx默认网站根目录
rm-rf/usr/local/nginx/html/* #删除默认测试页
VI index.php #新建index. php file
Chown www.www/usr/local/nginx/html/-R #设置目录所有者
chmod 700/usr/local/nginx/html/-R #设置目录权限
Open the server IP address in the browser and see the following interface