CentOS6.6 32-bit Minimal version: Install Nginx Mysql PHP Memcached and centos6.6nginx

Source: Internet
Author: User
Tags php memcached

CentOS6.6 32-bit Minimal version: Install Nginx Mysql PHP Memcached and centos6.6nginx

CentOS is a free and stable Linux version released by Red Hat. Minimal is used in enterprise server applications, because Minimal is the CentOS "Purest" server system, even the vim editor of Minimal must be installed by yourself. Minimal has the least components, no desktop, and flexible scalability. It is very suitable for servers.

1. Configure the NIC

After CentOS of Minimal version is installed, the NIC Driver is down by default and needs to be manually activated. After the network cable is connected, run the following command:
[Root @ jhq0113 soft] # vi/etc/sysconfig/network-scripts/ifcfg-eth0

Then press I to enter the editing status and make the following changes:

After modification, Press ESC, shift +:, and wq to save and exit.

Then configure the DNS server address:

[Root @ jhq0113 soft] # vi/etc/resolv. conf

The most important thing is to configure the nameserver attribute, which can be your own gateway address, as shown in:

Save the modification and exit. Run the following command to activate the NIC:

[Root @ jhq0113 soft] # ifconfig eth0 up

Now, the NIC has been configured. If you still find that the NIC is not started, you can execute the following two commands to complete the configuration.

[Root @ jhq0113 soft] # chkconfig-add network
[Root @ jhq0113 soft] # chkconfig network on

Nic restart command:

2. configure the firewall and open ports 22 (SSH), 3306 (Mysql), 80 (Nginx), 11211 (Memcached), and 6379 (Redis ).
[Root @ jhq0113 soft] # vi/etc/sysconfig/iptables
To:

Restart the firewall to make the configuration take effect:
[Root @ jhq0113 soft] #/etc/init. d/iptables restart

3. install components
Update System:
[Root @ jhq0113 soft] # yum update
Enter y later for confirmation.

Install vim:
[Root @ jhq0113 soft] # yum install vim

Install compilation tools and dependencies:
[Root @ jhq0113 soft] # yum install make apr * autoconf automake curl-devel gcc-c ++ zlib-devel openssl-devel pcre-devel gd kernel keyutils patch perl kernel- headers compat * mpfr cpp glibc libgomp libstdc ++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel kernel-devel krb5-devel zlib-devel libXpm * freetype libjpeg * libpng * php -common php-gd ncurses * libtool * libxml2 libxml2-devel patch

4. Download Cmake, Mysql, PHP, Nginx, libevent, libmcrypt, pcre, memcached
If you are looking for these very difficult sources, we recommend you with a few good source addresses:
Alibaba: http://mirrors.aliyun.com/
Sohu: http://mirrors.sohu.com/
Netease: http://mirrors.163.com/

I downloaded it from Sohu. The version is as follows:

5. system conventions
Software source code package storage location:/usr/local/src
Source code package compilation and installation location:/usr/local/software name

The source code is stored in/usr/local/src and can be downloaded in Windows, transmitted to the specified directory through Xftp, cd to the specified directory, and wget.

6. Official compilation and Installation

Install Mysql:

Mysql requires Cmake for compilation and installation. Therefore, you must install Cmake before installing Mysql.


Decompress Cmake:
[Root @ jhq0113 src] # tar xzvf cmake-3.1.1.tar.gz

Go to the cmake unzip directory:
[Root @ jhq0113 src] # cd cmake-3.1.1

Pre-compile. This process may take some time:
[Root @ jhq0113 cmake-3.1.1] #./configure

Compile and install:
[Root @ jhq0113 cmake-3.1.1] # make & make install

Add a mysql Group
[Root @ jhq0113 cmake-3.1.1] # groupadd mysql

Create a mysql user and add it to the mysql group. mysql users are not allowed to log on to the system directly.
[Root @ jhq0113 cmake-3.1.1] # useradd-g mysql-s/bin/false

Create a directory for storing MySQL Databases
[Root @ jhq0113 cmake-3.1.1] # mkdir-p/data/mysql

Set the directory for storing MySQL Databases
[Root @ jhq0113 cmake-3.1.1] # chown-R mysql: mysql/data/mysql

Create a MySQL installation directory
[Root @ jhq0113 cmake-3.1.1] # mkdir-p/usr/local/mysql

Back to the/usr/local/src directory:
[Root @ jhq0113 cmake-3.1.1] # cd/usr/local/src

Decompress mysql:
[Root @ jhq0113 src] # tar xzvf mysql-5.6.13.tar.gz

Go to the mysql extract directory:
[Root @ jhq0113 src] # cd mysql-5.6.13

Use Cmake to pre-compile Mysql. This process may take some time:
[Root @ jhq0113 mysql-5.6.13] # cmake.-DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DMYSQL_DATADIR =/data/mysql-DSYSCONFDIR =/etc/

Compile:
[Root @ jhq0113 mysql-5.6.13] # make

Installation:
[Root @ jhq0113 mysql-5.6.13] # make install

Copy the configuration file (if there is a my. cnf file under the/etc directory by default, directly overwrite it ):
[Root @ jhq0113 support-files] # cp/usr/local/mysql/support-files/my-default.cnf/etc/init. d/my. cnf

Add Mysql path:
[Root @ jhq0113 support-files] # vim/etc/my. cnf

After modification:

Generate a Mysql System database:
[Root @ jhq0113 support-files] #/usr/local/mysql/scripts/mysql_install_db-user = mysql-basedir =/usr/local/mysql-datadir =/data/mysql

Add Mysql to the system and start it:
[Root @ jhq0113 support-files] # cp/usr/local/mysql/support-files/mysql. server/etc/rc. d/init. d/mysqld

Add the execution permission of mysqld:
[Root @ jhq0113 support-files] # chmod 755/etc/init. d/mysqld

Add mysqld to boot and start:
[Root @ jhq0113 support-files] # chkconfig mysqld on

Edit the configuration file:
[Root @ jhq0113 support-files] # vim/etc/init. d/mysqld

After modification:

Add the Mysql service to the system environment variable:
[Root @ jhq0113 support-files] # vim/etc/profile

After modification:

Link the library file of myslq to the default location of the system to ensure that you do not need to specify the library file address of mysql when compiling software such as PHP.
[Root @ jhq0113 support-files] # ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql
[Root @ jhq0113 support-files] # ln-s/usr/local/mysql/include/mysql/usr/include/mysql

Restart the system:
Reboot

Establish a connection:
[Root @ jhq0113 ~] # Ln-s/var/lib/mysql. sock/tmp/mysql. sock

Restart Mysqld:
[Root @ jhq0113 ~] # Service mysqld restart

Set the Mysql password:
[Root @ jhq0113 support-files] #/usr/local/mysql/bin/mysql_secure_installation

Modify the root password:

No password by default. Press enter, enter the password twice, and press Y to press Enter.

Set Mysql to allow remote Logon:
[Root @ jhq0113 ~] # Mysql-uroot-p

Enter the password to log on, and then execute the following statement to restrict the Mysql root User from logging on remotely under the specified IP address.
Mysql> grant all privileges on.To 'root' 192. 168. 1. * '% 'identified by 'your password ';

Update permission:
Mysql> flush privileges;

Exit:
Mysql> exit;

In this way, you can use Navicat to remotely log on to Mysql in 192.168.1.

So far, Mysql has been installed.

Install Nginx:
Install pcre before installing Nginx, go to the/usr/local/src directory, decompress pcre, enter the pcre decompression directory, and execute the following command to compile and install pcre:
[Root @ jhq0113 pcre-8.35] #./configure-prefix =/usr/local/pcre & make install

Create a web combination of web users and do not allow web users to directly log on to the system:
[Root @ jhq0113 pcre-8.35] # groupadd web
[Root @ jhq0113 pcre-8.35] # useradd-g web-s/bin/false

Compile and install nginx, decompress it, enter the installation directory, and execute the following command:
[Root @ jhq0113 nginx-1.7.0] #. /configure-prefix =/usr/local/nginx-without-http_memcached_module-user = web-group = web-with-http_stub_status_module-with-openssl =/usr/-with-pcre =/usr/local /src/pcre-8.35
Note:-with-pcre =/usr/local/src/pcre-8.31 points to the path of the source package decompression, rather than the installation path, otherwise an error will be reported

Compile and install:
[Root @ jhq0113 nginx-1.7.0] # make & make install

Edit the Nginx startup command:
[Root @ jhq0113 nginx-1.7.0] # vim/etc/init. d/nginx

Add the following content:

! /Bin/bashnginx Startup script for the Nginx HTTP Serverit 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: nginxpidfile:/var/run/nginx. pidconfig:/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 is 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 "$1" 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

Grant nginx execution permission:
[Root @ jhq0113 nginx-1.7.0] # chmod 775/etc/init. d/nginx

Set nginx startup:
[Root @ jhq0113 nginx-1.7.0] # chkconfig nginx on

Start nginx:
[Root @ jhq0113 nginx-1.7.0] # service nginx start

Test Nginx installation and startup status:

So far, Nginx installation is complete. After PHP is installed, support for PHP and set the custom release directory.

Create a web directory:
[Root @ jhq0113 nginx-1.7.0] # mkdir-p/home/data/web

Not complete to be continued!

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.