LNMP installation configuration in CentOS environment _linux

Source: Internet
Author: User
Tags bz2 chmod curl fpm openssl pear openldap phpmyadmin

Installing dependent libraries and development environments

Copy Code code as follows:

#依赖库和开发工具

Yum-y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-deve L zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel Curl curl-devel e2fsprogs E2 Fsprogs-devel krb5 krb5-devel libidn libidn-devel OpenSSL openssl-devel openldap openldap-devel Nss_ldap Openldap-clients openldap-servers
#Nginx

Yum-y Install Pcre-devel Zlib-devel
#Php

Yum-y Install gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel freetype-devel
#Mysql

Yum-y Install Bison gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libtool-ltdl-devel* mysql-devel
Download Packages

#创建目录

Mkdir/web

Cd/web
#PHP5.3.8

wget http://php.net/distributions/php-5.3.8.tar.bz2
#PHP库文件

wget http://ncu.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz

wget http://ncu.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz

wget http://ncu.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
#Nginx1.5.3

wget http://www.nginx.org/download/nginx-1.5.3.tar.gz
#Nginx (Pcre)

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.13.tar.gz

If no 8.13 can download the latest ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/here
#Mysql5.5.17

wget http://mysql.mirrors.pair.com/Downloads/MySQL-5.5/mysql-5.5.32.tar.gz

Download the latest: http://mysql.mirrors.pair.com/Downloads/MySQL-5.5/
#Mysql (CMake)

wget http://www.cmake.org/files/v2.8/cmake-2.8.6.tar.gz

installing MySQL

Copy Code code as follows:

#安装cmake

TAR-ZXVF cmake-2.8.6.tar.gz

CD cmake-2.8.6/

./configure

Gmake && gmake install && CD. /
#添加mysql用户

/usr/sbin/groupadd MySQL

/usr/sbin/useradd-g MySQL MySQL

Mkdir-p/data/mysql

Chown-r Mysql:mysql/data/mysql
#安装Mysql

TAR-ZXVF mysql-5.5.17.tar.gz

CD mysql-5.5.17

CMake. -dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/data/mysql-dsysconfdir=/etc/

Make && make install
#设置Mysql

There are five configuration information files in the #在support-files directory:

#my-small.cnf (Memory <=64m)

#my-medium.cnf (Memory 128M)

#my-large.cnf (Memory 512M)

#my-huge.cnf (Memory 1g-2g)

#my-innodb-heavy-4g.cnf (Memory 4GB)

Cd/usr/local/mysql

CP./SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF

Vi/etc/my.cnf

#在 [MYSQLD] paragraph increased

DataDir =/data/mysql

Wait-timeout = 30

Max_connections = 512

Default-storage-engine = MyISAM

#在 [MYSQLD] paragraph modification

Max_allowed_packet = 16M
#生成授权表

Cd/usr/local/mysql

./scripts/mysql_install_db--user=mysql
#更改密码

/usr/local/mysql/bin/mysqladmin-u Root Password 123456
#开启mysql

/usr/local/mysql/bin/mysqld_safe &
#测试连接mysql

/usr/local/mysql/bin/mysql-u root-p 123456

show databases;

Exit
#设置开机启动

Vi/etc/rc.d/rc.local
#加入

/usr/local/mysql/bin/mysqld_safe &

May appear error 2002 (HY000): Can ' t connect to the local MySQL server through socket '/tmp/mysql.sock ' (2)

CD/TMP//found no

Ln-s/var/lib/mysql/mysql.sock/tmp/mysql.sock

cd/var/run/

Chown-r MySQL mysqld

Installing PHP

Copy Code code as follows:

#1

TAR-ZXVF libiconv-1.14.tar.gz && CD libiconv-1.14/

./configure--prefix=/usr/local

Make && make install && CDs. /
#2

TAR-ZXVF libmcrypt-2.5.8.tar.gz && CD libmcrypt-2.5.8/

./configure && make && make install

/sbin/ldconfig && cd libltdl/&&/configure--enable-ltdl-install

Make && make install && CDs. /
#3

TAR-ZXVF mhash-0.9.9.9.tar.gz && cd mhash-0.9.9.9/&&/configure

Make && make install && CDs. /
#4

Ln-s/usr/local/lib/libmcrypt.la/usr/lib/libmcrypt.la

Ln-s/usr/local/lib/libmcrypt.so/usr/lib/libmcrypt.so

Ln-s/usr/local/lib/libmcrypt.so.4/usr/lib/libmcrypt.so.4

Ln-s/usr/local/lib/libmcrypt.so.4.4.8/usr/lib/libmcrypt.so.4.4.8

Ln-s/USR/LOCAL/LIB/LIBMHASH.A/USR/LIB/LIBMHASH.A

Ln-s/usr/local/lib/libmhash.la/usr/lib/libmhash.la

Ln-s/usr/local/lib/libmhash.so/usr/lib/libmhash.so

Ln-s/usr/local/lib/libmhash.so.2/usr/lib/libmhash.so.2

Ln-s/usr/local/lib/libmhash.so.2.0.1/usr/lib/libmhash.so.2.0.1

Ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config
#5
TAR-ZXVF mcrypt-2.6.8.tar.gz &&CD mcrypt-2.6.8/

/sbin/ldconfig

./configure

Make && make install && CDs. /
#6
TAR-XJVF php-5.3.8.tar.bz2

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

--WITH-CONFIG-FILE-PATH=/USR/LOCAL/PHP/ETC \

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

--with-mysql=/usr/local/mysql \

--with-mysqli=/usr/local/mysql/bin/mysql_config \

--with-jpeg-dir--with-png-dir--with-zlib \

--with-mhash--enable-sockets--enable-ftp \

--with-libxml-dir--enable-xml--disable-rpath \

--enable-safe-mode--enable-bcmath \

--enable-shmop--enable-sysvsem \

--enable-inline-optimization--with-curl \

--with-curlwrappers \

--enable-mbregex \

--enable-mbstring--with-mcrypt--with-gd \

--enable-gd-native-ttf--with-openssl--with-mhash \

--enable-pcntl--enable-sockets--with-ldap--WITH-LDAP-SASL \

--ENABLE-FPM \

--with-xmlrpc--enable-zip--enable-soap \

--without-pear \

Make zend_extra_libs= '-liconv '

#注意这里容易出现 Make: * * * [ext/phar/phar.php] Error 127

#出现mysql Client Solutions

#ln-S/usr/local/mysql/lib/libmysqlclient.so/usr/lib/

#ln-S/usr/local/mysql/lib/libmysqlclient.so.18/usr/lib/libmysqlclient.so.18

#或者chmod: Cannot Access "Ext/phar/phar.phar": No file or directory

#make: [Ext/phar/phar.phar] Error 1 (ignored)

#解决方法在编译的时候加--without-pear Parameters

#如果还不行, make does not add the zend_extra_libs= '-liconv ' parameter

Make install
#选择PHP. ini configuration file
CP Php.ini-production/usr/local/php/etc/php.ini
Change PHP-FPM
#添加WWW用户
/usr/sbin/groupadd www &&/usr/sbin/useradd-g www www

Mkdir-p/var/log/nginx && chmod +w/var/log/nginx &&chown-r Www:www/var/log/nginx

Mkdir-p/data/www && chmod +w/data/www && chown-r www:www/data/www

Cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf

Vi/usr/local/php/etc/php-fpm.conf
#去掉/change in the configuration file;

Pm.max_children = 64

Pm.start_servers = 20

Pm.min_spare_servers = 5

Pm.max_spare_servers = 35

Pm.max_requests = 1024

user = www
Group = www
#检查语法是否正确

/usr/local/php/sbin/php-fpm-t

#出现NOTICE: Configuration file/usr/local/php/etc/php-fpm.conf test is successful successful

/USR/LOCAL/PHP/SBIN/PHP-FPM &

#设置开机启动

Vi/etc/rc.d/rc.local

#在行末加入

/USR/LOCAL/PHP/SBIN/PHP-FPM &
#返回安装包目录

Cd/web
Install Nginx

#安装pcre库

TAR-ZXVF pcre-8.13.tar.gz && cd pcre-8.13/&&/configure

Make && make install && CDs. /
#安装Nginx


TAR-ZXVF nginx-1.0.9.tar.gz && CD nginx-1.0.9 &&

./configure--user=www--group=www \

--prefix=/usr/local/nginx \

--sbin-path=/usr/local/nginx/sbin/nginx \

--conf-path=/usr/local/nginx/conf/nginx.conf \

--with-http_stub_status_module \

--with-http_ssl_module \

--with-pcre \

--lock-path=/var/run/nginx.lock \

--pid-path=/var/run/nginx.pid

Make && make install && CDs. /
#更改配置
Vi/usr/local/nginx/conf/nginx.conf
#修改一些参数, do not replace files directly, this is only part of

Copy Code code as follows:

User www

Events {

Use Epoll;

Worker_connections 1024;

}

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;

}


Copy Code code as follows:

#注意这里

# $document _root$fastcgi_script_name;

#检测配置文件

/usr/local/nginx/sbin/nginx-t
#提示表示成功
#nginx: The configuration file/usr/local/nginx/conf/nginx.conf syntax is OK
#nginx: Configuration file/usr/local/nginx/conf/nginx.conf test is successful

#开启Nginx

/usr/local/nginx/sbin/nginx &
#平滑重启Nginx

/usr/local/nginx/sbin/nginx-s Reload
#添加开机启动

Vi/etc/rc.d/rc.local
#最后移行加入

/usr/local/nginx/sbin/nginx
#测试

cd/usr/local/nginx/html/

Touch index.php

vi/usr/local/nginx/html/index.php

Copy Code code as follows:

<?php

Phpinfo ();

?>


phpMyAdmin Download Address
Http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/4.0.4.2/phpMyAdmin-4.0.4.2-all-languages.tar.gz/download

#discuz伪静态

Copy Code code as follows:

rewrite ^ ([^\.] *)/topic-(. +) \.html$ $1/portal.php?mod=topic&topic=$2 last;

rewrite ^ ([^\.] *)/article-([0-9]+)-([0-9]+) \.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;

rewrite ^ ([^\.] *)/forum-(\w+)-([0-9]+) \.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;

rewrite ^ ([^\.] *)/thread-([0-9]+)-([0-9]+)-([0-9]+) \.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3d$4&page =$3 last;

rewrite ^ ([^\.] *)/group-([0-9]+)-([0-9]+) \.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;

rewrite ^ ([^\.] *)/space-(USERNAME|UID)-(. +) \.html$ $1/home.php?mod=space&$2=$3 last;

rewrite ^ ([^\.] *)/blog-([0-9]+)-([0-9]+) \.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;

rewrite ^ ([^\.] *)/(Fid|tid)-([0-9]+) \.html$ $1/index.php?action=$2&value=$3 last;

if (!-e $request _filename) {

return 404;

}

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.