CentOS Switch Nginx and Apache environment

Source: Internet
Author: User
Tags download redis php mysql zts

Pkill-9 Nginx directly kill the running program, close Nginxservice httpd start start Apache
Install lamp and VSFTPD, Redis under CentOS

Yum installs httpd and PHP, MySQL services

1: yum search httpd            // Search for packages beginning with httpd 2: yum install httpd.x86_64   //find apache  corresponding package name  apache  http server, installing 3: yum -y install mysql-server mysql php php-mysql  php-xml php-gd php-mbstring  //installation  mysql  php  and its extension 4: service  mysqld restart  //Start mysql    mysql -uroot -p   Empty    show databases;  View Datasheet 5: iptables -f   //empty your firewall 6:  service iptables save  //Save firewall Rules 7: service iptables stop  // Turn off firewall 8: apachectl restart  //this time will be error  9: vi /etc/httpd/conf/httpd.conf     //configuration httpd10::set nu  //Display line number    11: :/ServerName   //Find Servername12: :1   back to top row 13:  remove  ServerName www.example.com:80    front #       Save  14: serveice httpd restart  Restart  apache 15:  access ip  View Apache boot status 16: cd /var/www/html   //into the PHP default directory 17: vi index.php     //Create php file    save   Refresh View information 18:service mysqld start     Start MySQL

Using Yum to install Apache (httpd) php MySQL

Compiling lamp installation Method

One: Tool GCC installation

Yum Install gcc gcc-c++ kernel-devel

Two: Install Zlib

TAR–ZXVF zlib-1.2.5.tar.gz

CD zlib-1.2.5

./configure

Make && make install

III: Install Apache

TAR-JXVF httpd-2.2.19.tar.bz2

CD httpd-2.2.19

./configure--PREFIX=/USR/LOCAL/HTTP2 \

--enable-modules=all \

--enable-mods-shared=all \

--enable-so

Make && make install

Edit httpd.conf, put servername ... 80 comments Removed

/usr/local/http2/bin/apachectl start Apache

Four: Ready to install PHP, need to install some PHP dependency program

A: Install LIBXML2

Tar zxvf libxml2-2.7.2.tar.gz

CD libxml2-2.7.2

./configure--PREFIX=/USR/LOCAL/LIBXML2///If there is a problem with the compilation, configure plus--without-zlib can be compiled through

Make && make install

Make finished normal display

Making Install in XSTC

MAKE[1]: Entering directory '/USR/LOCAL/SRC/LIBXML2-2.7.2/XSTC '

MAKE[2]: Entering directory '/USR/LOCAL/SRC/LIBXML2-2.7.2/XSTC '

MAKE[2]: Nothing to is done for ' install-exec-am '.

MAKE[2]: Nothing to is done for ' install-data-am '.

MAKE[2]: Leaving directory '/USR/LOCAL/SRC/LIBXML2-2.7.2/XSTC '

MAKE[1]: Leaving directory '/USR/LOCAL/SRC/LIBXML2-2.7.2/XSTC '

B: Install Jpeg8

TAR-ZXVF jpegsrc.v8b.tar.gz

CD jpeg-8b

./configure--prefix=/usr/local/jpeg \

--enable-shared--enable-static

Make && make install

C: Install libpng

Tar zxvf libpng-1.4.3.tar.gz

CD libpng-1.4.3

./configure installing to the default directory

Make && make install

D: Install FreeType (font library)

Tar zxvf freetype-2.4.1.tar.gz

CD freetype-2.4.1

./configure--prefix=/usr/local/freetype

Make && make install

E: Install GD Library

TAR-ZVXF gd-2.0.35.tar.gz

Mkdir-p/USR/LOCAL/GD

CD gd-2.0.35

./configure--prefix=/usr/local/gd \

--with-jpeg=/usr/local/jpeg/\

--with-png--with-zlib \

--with-freetype=/usr/local/freetype

Make && make install

F: Installation php5

TAR-JXVF php-5.3.6.tar.bz2

CD php-5.3.6

./configure--prefix=/usr/local/php \

--WITH-APXS2=/USR/LOCAL/HTTP2/BIN/APXS \

--WITH-MYSQL=MYSQLND \

--WITH-PDO-MYSQL=MYSQLND \

--WITH-MYSQLI=MYSQLND \

--with-freetype-dir=/usr/local/freetype \

--WITH-GD=/USR/LOCAL/GD \

--with-zlib--WITH-LIBXML-DIR=/USR/LOCAL/LIBXML2 \

--with-jpeg-dir=/usr/local/jpeg \

--with-png-dir \

--enable-mbstring=all \

--enable-mbregex \

--enable-shared

Make && make install

CP Php.ini-development/usr/local/php/lib/php.ini

Edit the Apache configuration file to support PHP parsing

AddType application/x-httpd-php. php

LoadModule Php5_module modules/libphp5.so//Ensure there is

DirectoryIndex index.html Add index.php Set Default access page in front of index.html

V: Install MySQL

A: Compile and install MySQL

TAR-XZVF mysql-5.1.58.tar.gz

CD mysql-5.1.58

Yum-y Install Ncurses-devel

./configure--prefix=/usr/local/mysql \

--with-charset=utf8 \

--with-extra-charsets=gbk,gb2312,binary

Make && make install

B: Initialize MySQL

Groupadd MySQL//create a group called MySQL

useradd-g MySQL MySQL//create a user called MySQL, belonging to the MySQL group, preceded by a group, followed by the user

CP support-files/my-medium.cnf/etc/my.cnf//Copy configuration file

Cd/usr/local/mysql

Chown-r Mysql.mysql. Assigning permissions to a MySQL group

bin/mysql_install_db--user=mysql \//create MySQL system database and test database

--datadir=/usr/local/mysql/var

Chown-r Root. Change the owner of the current directory file to root to avoid the database

Factory reset to avoid previous data execution

Chown-r mysql var//give the database the directory var gives permissions to the MySQL user,

Only the current Var directory can be manipulated

Bin/mysqld_safe--user=mysql &

#[[email protected] init.d]# 170128 23:56:26 mysqld_safe Logging to '/var/log/mysqld.log '.

#170128 23:56:26 Mysqld_safe starting mysqld daemon with databases From/var/lib/mysql

#170128 23:56:26 mysqld_safe mysqld from PID File/var/lib/mysql/mysqld.pid ended

#/usr/local/mysql/bin/mysql_install_db--user=mysql//This command is the above error resolution method

ps-a | grep mysql//check if MySQL is started

Create a database of MySQL test databases and systems

Change the owner of the current directory file to root and avoid restoring the database to factory settings.

Set up MySQL and Apache, vsftpd service auto-start

Vim/etc/inittab put Id:5:init .... Change 5 to 3, let him go. Profile settings Server startup automatically switches to the command line

Vim/etc/rc.d/rc.local Configure this file, add the following line command

/usr/local/http2/bin/apachectl start

/usr/local/mysql/bin/mysqld_safe--user=mysql &

/ETC/RC.D/INIT.D/VSFTPD start

Service VSFTPD Start

Download Redis

wget http://download.redis.io/releases/redis-2.6.16.tar.gz

Tar zxvf redis-2.6.16.tar.gz

CD redis-2.6.16.tar.gz

Make Test

Yum Install Tcl

Make Test

Make Prefix=/usr/local/redis Install

cp/usr/local/src/redis-2.6.16/redis.conf./

./bin/redis-server./redis.conf

Vim redis.conf Change daemonize to Yes, set auto-start, restart Redis

Install PHP extension compilation

Enter Pecl.php.net

Cd/usr/local/src

wget http://pecl.php.net/get/redis-2.2.4.tgz

Tar zxvf redis-2.2.4.tgz

CD redis-2.2.4.tgz

LS found no configure

/usr/local/php/bin/phpize

LS found to appear configure

./configure--with-php-config=/usr/local/php/bin/php-config

Make && make install---------/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/--Copy extension directory

Introduction of compiled Redis.so

ls/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/found an extra redis.so.

Cd/usr/local/php/lib

Vim php.ini

Add below the Extension=php_shmop.dll

Extension =/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/redis.so

I'll restart it.

CentOS Switch Nginx and Apache environment

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.