Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The environment in which RHEL7.0 compiles and installs Nginx1.6.0+MySQL5.6.19+PHP5.5.14

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains the "RHEL7.0 compilation and installation of Nginx1.6.0+MySQL5.6.19+PHP5.5.14 running environment", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "RHEL7.0 compilation and installation of Nginx1.6.0+MySQL5.6.19+PHP5.5.14 running environment"!

Preparation:

RHEL 7.0system installation and configuration graphic tutorial https://www.yisu.com/os/192932.html

Use the system image file to configure the local yum source

1. Upload the system image file rhel-server-7.0-x86_64-dvd.iso to the / usr/local/src directory using tools such as WinSCP.exe.

2. Use the Putty.exe tool to remotely connect to the RHEL server

3. Mount the system image file

Mkdir / media/cdrom # create a new image file mount directory

Cd / usr/local/src # enters the directory where the system image files are stored

Ls # lists the directory files, and you can see the system image files you just uploaded

Mount-t iso9660-o loop / usr/local/src/rhel-server-7.0-x86_64-dvd.iso / media/cdrom # Mount the system image

Cd / media/cdrom # enter the mount directory and use the ls command to see that the files already exist

Note: umount / media/cdrom # uninstall the system image

4. Set the system image files to be mounted automatically on boot.

Vi / etc/fstab # adds the following code. Realize automatic mount on boot

/ usr/local/src/rhel-server-7.0-x86_64-dvd.iso / media/cdrom iso9660 defaults,ro,loop 0 0

: wq! # Save exit

Note: iso9660 uses df-T to view

5. Configure the local yum source

Cd / etc/yum.repos.d/ # enter the yum configuration directory

Touch rhel-media.repo # create a yum configuration file

Vi rhel-media.repo # Edit the configuration file to add the following

[rhel-media]

Name=Red Hat Enterprise Linux 7.0 # Custom name

Baseurl= file:///media/cdrom # Local CD mount path

Enabled=1 # enable yum source, 0 is not enabled, 1 is enabled

Gpgcheck=1 # check GPG-KEY,0: no check, 1: check

Gpgkey= file:///media/cdrom/RPM-GPG-KEY-redhat-release # GPG-KEY path

: wq! # Save exit

6. Configure the yum command

Yum clean all # clear the yum cache

Yum makecache # caches package information from the local yum source

Now you can use the yum command to install the software automatically.

Configure the firewall and open port 80 and port 3306

RHEL 7.0 uses firewall as the firewall by default, which is changed to iptables firewall here.

1. Close firewall:

Systemctl stop firewalld.service # stop firewall

Systemctl disable firewalld.service # prevents firewall from booting

2. Install iptables firewall

Yum install iptables-services # installation

Vi / etc/sysconfig/iptables # Editing Firewall profile

# 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]

-An INPUT-m state-- state ESTABLISHED,RELATED-j ACCEPT

-An INPUT-p icmp-j ACCEPT

-An INPUT-I lo-j ACCEPT

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 22-j ACCEPT

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 80-j ACCEPT

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 3306-j ACCEPT

-An INPUT-j REJECT-- reject-with icmp-host-prohibited

-A FORWARD-j REJECT-- reject-with icmp-host-prohibited

COMMIT

: wq! # Save exit

Systemctl restart iptables.service # finally restart the firewall to make the configuration effective

3. Close SELINUX

Vi / etc/selinux/config

# SELINUX=enforcing # comment out

# SELINUXTYPE=targeted # comment out

SELINUX=disabled # increased

: wq! # Save exit

Setenforce 0 # makes the configuration effective immediately

IV. System agreement

Software source code package location: / usr/local/src

Source package compilation installation location: / usr/local/ software name

Download the software package

1. Download nginx

Http://nginx.org/download/nginx-1.6.0.tar.gz

2. Download MySQL

Http://cdn.mysql.com/Downloads/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 (nginx pseudo-static is supported)

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 compilation 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 (required for gd library)

Https://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2

13. Tiff (required for gd library)

Http://download.osgeo.org/libtiff/tiff-4.0.3.tar.gz

14. Libpng (required for gd library)

Ftp://ftp.simplesystems.org/pub/png/src/libpng16/libpng-1.6.12.tar.gz

15. Freetype (required for gd library)

Http://ring.u-toyama.ac.jp/archives/graphics/freetype/freetype2/freetype-2.5.3.tar.gz

16. Jpegsrc (required for gd library)

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

6. Install compilation tools and library files (install using yum command)

Yum install-y apr* autoconf automake bison 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 keyutils-libs-devel 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-common php-gd policycoreutils telnet nasm nasm* wget zlib-devel

Installation section

The following is done by using the putty tool to remotely log in to the server and operate under the command line

First, install MySQL

1. Install 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 a user mysql and join the mysql group, and do not allow mysql users to log in directly to the system

Mkdir-p / data/mysql # create MySQL database storage directory

Chown-R mysql:mysql / data/mysql # sets MySQL database storage directory permissions

Mkdir-p / usr/local/mysql # create the MySQL installation directory

Cd / usr/local/src # enters the package storage directory

Tar zxvf mysql-5.6.19.tar.gz # decompression

Cd mysql-5.6.19 # enter the directory

Cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/data/mysql-DSYSCONFDIR=/etc # configuration

Make # compilation

Make install # installation

Rm-rf / etc/my.cnf # Delete the default configuration file of the system (do not delete it if there is no default)

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

Ln-s / usr/local/mysql/my.cnf / etc/my.cnf # soft connections added to the / etc directory

Cp. / support-files/mysql.server / etc/rc.d/init.d/mysqld # add Mysql to the system startup

Chmod 755 / etc/init.d/mysqld # increased execution permissions

Chkconfig mysqld on # join Boot Boot

Vi / etc/rc.d/init.d/mysqld # editing

Basedir=/usr/local/mysql # MySQL Program installation path

Datadir=/data/mysql # MySQl database storage directory

Service mysqld start # Startup

Vi / etc/profile # adds 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 # makes the configuration effective immediately

The following two lines link the library files of myslq to the default location of the system, so that you do not have to specify the library file address of mysql when compiling software such as PHP.

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 the Mysql password and press enter Y to enter the password twice as prompted

Second, install Nginx

1. Install 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. Install 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 # adds the openssl service to the system environment variable: add the following line at the end

Export PATH=$PATH:/usr/local/openssl/bin

: wq! # Save exit

Source / etc/profile # makes the configuration effective immediately

3. Install 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. Install 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 points to the path of decompression of the source package, not the path of installation, otherwise an error will be reported.

Make

Make install

/ usr/local/nginx/sbin/nginx # launch Nginx

Set nginx to boot

Vi / etc/rc.d/init.d/nginx # Edit 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=\ ([^] *\). * /\ 1Uniple 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 # gives file execution permissions

Chkconfig nginx on # set boot up

/ etc/rc.d/init.d/nginx restart # restart

Third, install php

1. Install yasm

Cd / usr/local/src

Tar zxvf yasm-1.2.0.tar.gz

Cd yasm-1.2.0

. / configure

Make

Make install

2. Install libmcrypt

Cd / usr/local/src

Tar zxvf libmcrypt-2.5.8.tar.gz

Cd libmcrypt-2.5.8

. / configure

Make

Make install

3. Install 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. Install 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. Install 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 # compilation

Make install # installation

7. Install jpeg

Cd / usr/local/src

Tar zxvf jpegsrc.v9a.tar.gz

Cd jpeg-9a

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

Make # compilation

Make install # installation

8. Install libgd

Cd / usr/local/src

Tar zxvf libgd-2.1.0.tar.gz # decompression

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 # compilation

Make install # installation

9. Install 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-bit, execute the following two commands, otherwise there will be an error in installing php (32-bit system does not need to be executed)

Ln-s / usr/lib64/libltdl.so / usr/lib/libltdl.so

\ 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-sysvsem-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-enable-soap-without-pear-with-gettext-enable-session-with-mcrypt with-curl enable-ctype # configuration

Make # compilation

Make install # installation

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 configuration file that comes with the system

Ln-s / usr/local/php/etc/php.ini / etc/php.ini # add soft link to / etc directory

Cp / usr/local/php/etc/php-fpm.conf.default / usr/local/php/etc/php-fpm.conf # copy template file as 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 # editing

User = www # set the php-fpm running account to www

Group = www # set the php-fpm running group to www

Pid = run/php-fpm.pid # cancel the previous semicolon

: wq!

Set php-fpm to 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 the startup directory

Chmod + x / etc/rc.d/init.d/php-fpm # add execute permission

Chkconfig php-fpm on # set boot up

Vi / usr/local/php/etc/php.ini # Edit configuration file

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

# list the functions that can be disabled by PHP. If some programs need to use this function, you can delete it and undisable it.

Find:; date.timezone =

Change it to: date.timezone = PRC # set time zone

Find: expose_php = On

Modified to: expose_php = Off # suppresses the display of php version information

Find: short_open_tag = Off

Modified to: short_open_tag = ON # supports php short tags

Find opcache.enable=0.

Modified to support opcode caching for opcache.enable=1 # php

Found: opcache.enable_cli=1 # php supports opcode caching

Modified to: opcache.enable_cli=0

On the last line, add: zend_extension=opcache.so # to enable opcode caching

: wq! # Save exit

Configure nginx to support php

Vi / usr/local/nginx/conf/nginx.conf

To modify the / usr/local/nginx/conf/nginx.conf configuration file, the following modifications are required

The first line of user www www; # user is uncommented, and the Nginx running group is changed to www www;. It must be the same as the user,group configuration in / usr/local/php/etc/php-fpm.conf, otherwise there will be errors in php operation.

Index index.html index.htm index.php; # add 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

}

# Uncomment part of FastCGI server location, note the parameter of fastcgi_param line, change it to $document_root$fastcgi_script_name, or use absolute path

/ etc/init.d/nginx restart # restart nginx

Service php-fpm start # launch php-fpm

Test piece

Cd / usr/local/nginx/html/ # enter the nginx default website root directory

Rm-rf / usr/local/nginx/html/* # Delete the default test page

Vi index.php # create a new index.php file

: wq! # Save exit

Chown www.www / usr/local/nginx/html/-R # sets the directory owner

Chmod 700 / usr/local/nginx/html/-R # set directory permissions

Open the server IP address in the browser and you will see the following interface

Thank you for reading, the above is the content of "RHEL7.0 compiling and installing Nginx1.6.0+MySQL5.6.19+PHP5.5.14 running environment". After the study of this article, I believe you have a deeper understanding of the problem of RHEL7.0 compiling and installing Nginx1.6.0+MySQL5.6.19+PHP5.5.14 running environment, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report