Nginx+php+mysql configuration under Linux (CentOS)--Your own LNMP configuration

Source: Internet
Author: User
Tags bz2 fpm install php install openssl openssl php source code svn automake

Description: All software downloads the latest version of the stable version from the official website

###################
#
# get the latest source package
#
#####################

#建立独立的webserver
#mkdir-pv/usr/local/webserver

#放置源码包的目录
#mkdir-PV/USR/LOCAL/WEBSERVER/SRC

#cd/USR/LOCAL/WEBSERVER/SRC

# # PHP Source code
#wget Http://www.php.net/get/php-5.3.4.tar.bz2/from/tw2.php.net/mirror

# #php加速器
#wget http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2

# #memcache客户端
#wget http://pecl.php.net/get/memcache-3.0.5.tgz

# #memcached服务器端

#wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz

# # MySQL Database
#wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.48.tar.gz/from/http://mysql.cdpa.nsysu.edu.tw/

# # Nginx Latest stable version
#wget http://www.nginx.org/download/nginx-0.8.54.tar.gz

#下载php-FPM, a simple and robust PHP fastcgi management tool. This corresponds to the php-5.3.x. It is recommended to use SVN method to extract

#tar JXVF php-5.3.4.tar.bz2
#cd php-5.3.
#svn Co http://svn.php.net/repository/php/php-src/branches/PHP_5_3/sapi/fpm sapi/fpm

(Note: php-5.3.5 begins to have the FPM integrated and does not have to be co again)
#查看fpm是否已经检出
#ls SAPI/FPM

######################
#
# installation
#
######################

# # Install MySQL 5.5

Installing a software class library that relies on package dependencies: gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel*# Install gccyum-y install gcc*yum-y  ncurses-devel# installation cmakeyum install-y cmake.x86_64# install Bisonyum install-y bison.x86_64 bison-devel.x86_64cmake-dcmake_install_prefix=/usr/local/webserver/mysql5.5.23 \-DMYSQL_UNIX_ADDR=/ Tmp/mysql.sock \-ddefault_charset=utf8 \-ddefault_collation=utf8_general_ci \-dwith_extra_charsets:string=utf8, GBK \-dwith_myisam_storage_engine=1 \-dwith_innobase_storage_engine=1 \-dwith_memory_storage_engine=1 \-DWITH_ readline=1 \-denabled_local_infile=1 \-dmysql_datadir=/data/mysql/3306 \-dmysql_user=mysql \-DMYSQL_TCP_PORT=3306# Make#make install MySQL, you need to set up a service, mainly MY.CNF configuration, set up MySQL data directory, etc., depending on the actual needs

Install dependent packages
Relying on the Software class library:
GCC gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel*
#安装gccyum-y Install gcc*
#安装cmakeyum install-y cmake.x86_64
#安装bisonyum install-y bison.x86_64 bison-devel.x86_64

cmake-dcmake_install_prefix=/usr/local/webserver/mysql5.5.23 \-dmysql_unix_addr=/tmp/mysql.sock \-DDEFAULT_ Charset=utf8 \-ddefault_collation=utf8_general_ci \-DWITH_EXTRA_CHARSETS:STRING=UTF8,GBK \-DWITH_MYISAM_STORAGE_ engine=1 \-dwith_innobase_storage_engine=1 \-dwith_memory_storage_engine=1 \-dwith_readline=1 \-DENABLED_LOCAL_ infile=1 \-dmysql_datadir=/data/mysql/3306 \-dmysql_user=mysql \-dmysql_tcp_port=3306

# # Install PHP

# #安装php的时候可能很多组件都会缺失, you can install these missing components directly with Yum

Yum Install GD gd-devel.x86_64

Yum Install Libjpeg Libjpeg-devel

Yum install-y libxml2-devel.x86_64 XML2

Yum Install-y OpenSSL Openssl-devel

Yum install libmcrypt-devel.x86_64 libmcrypt.x86_64 curl-devel.x86_64 curl.x86_64

#./configure–prefix=/usr/local/webserver/php–with-config-file-path=/usr/local/webserver/php/etc–with-gd– with-mysql=/usr/local/webserver/mysql–enable-mbstring–with-curl–with-mcrypt–with-zlib–with-mhash–enable-fpm– Enable-pcntl–enable-sysvsem–enable-shmop–with-jpeg-dir=/usr–with-iconv-dir=/usr/local

#make

#make Install

Note: If iconv.c:1017:undefined reference to ' Libiconv_open ' appears when compiling, the following actions can be taken:

"My method."

Note:for CentOS >= 5.4 Iconv-devel is provided by glibc

Libiconv is included in the glibc, so the Glic class library can be installed

#yum install-y glibc-devel.x86_64

"Methods on the Internet"

Workaround:
#wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
#tar-ZXVF libiconv-1.13.1.tar.gz
#cd libiconv-1.13.1
#./configure–prefix=/usr/local/libiconv
# make
# make Install

Add –with-iconv=/usr/local/libiconv when PHP configure

The following two methods are said to be available (not tested):

A: edit Makefile about 77 rows of places:
Extra_libs = ..... -lcrypt
In the end, add-liconv, for example:
Extra_libs = ..... -lcrypt-liconv
Run make again.


B:
#make zend_extra_libs= '-liconv '
#make Install

Installing the Memcache Client

Specific installation details see: http://www.php.net/manual/en/memcache.installation.php

#tar ZXVF memcache-3.0.5.tgz
#cd memcache-3.0.5/
#/usr/local/webserver/php/bin/phpize
#./configure–with-php-config=/usr/local/webserver/php/bin/php-config
#生成/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/memcach.so
#make && make Install

Installing the memcached server side

#tar ZXVF
#./configure–prefix=/usr/local/webserver/memcached
#make && make Install

#启动memcached
#/usr/local/webserver/memcached-d-M 256-u root

Install EA

#cd/usr/local/webserver/src/eaccelerator-0.9.6.1
#/usr/local/webserver/php/bin/phpize # # # # Use generate Configure file
#./configure–enable-eaccelerator=shared–with-php-config=/usr/local/webserver/php/bin/php-config
#生成/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so

Installing Nginx

# Nginx needs Pcre Library
#yum Install Pcre-devel

# SSL installation required for HTTPS
#yum Install OpenSSL Openssl-devel

#cd nginx-0.8.54
#./configure
#make
#make Install

Configuration

server {
Listen 80;
server_name www.abc.com;
CharSet Utf-8;
Access_log Logs/host.access.log Main;
Location/{
Root/home/nginx;
Index index.html index.htm index.php;
Index index.php;
if (-f $request _filename/index.html) {
Rewrite (. *) $1/index.html break;
}
if (-f $request _filename/index.php) {
Rewrite (. *) $1/index.php;
}
if (!-f $request _filename) {
Rewrite (. *)/index.php;
}

}

Error_page 404/404.html;

# REDIRECT Server error pages to the static page/50x.html
#
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;

}

# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
Location ~ \.php$ {
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename/home/nginx/$fastcgi _script_name;
Include Fastcgi_params;
}

# Deny access to. htaccess files, if Apache ' s document Root
# concurs with Nginx ' s one
#
Location ~/\.ht {
Deny all;
}
}

######################################

Nginx+php+mysql configuration under Linux (CentOS)--Your own LNMP configuration

Related Article

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.