LNMP Server Environment configuration (linux+nginx+mysql+php)

Source: Internet
Author: User
Tags fpm install php imagemagick openssl openssl library snmp svn zend

Server Configuration

1. After the purchase of a good VPS login server first modify password passwd root
2. Modify the SSH timeout time

The code is as follows Copy Code
Vi/etc/ssh/sshd_config
Clientaliveinterval 60
Clientalivecountmax 30

3. Install Setup

The code is as follows Copy Code

#安装setuptool
Yum Install Setuptool
#可以发现执行setup后不全, install one more for system service management
Yum Install Ntsysv
#再安装个防火墙, as well as firewall settings, network settings in Setup
Yum Install Iptables
#安装setup中配套的防火墙设置
Yum Install System-config-securitylevel-tui
#安装setup中配套的网络设置
Yum Install System-config-network-tui

4. Format the disk, mount the disk

Client environment: MAC OS X
Remote Connection mode: Run Terminal, enter command SSH USERNAME@IP
Hard disk partition and mount operation steps:
1. View the hard drive (name/dev/xvdb) that is not mounted

  code is as follows copy code
# fdisk-l
Disk/ Dev/xvdb doesn ' t contain a valid partition Table
2. Create Partition
# FDISK/DEV/XVDB
...
Enter N
Command (M for help): N
Enter P
Command action
E extended
P primary partition (1-4)
P
Enter 1< br> Partition Number (1-4): 1
Return
-A-cylinder (1-2610, default 1):
Using Default value 1
return
Last cyl Inder, +cylinders or +size{k,m,g} (1-2610, default 2610):
Using Default Value 2610
Enter W
Command (M for help): W
The partition table has been altered!
3. Format Partition
# MKFS.EXT3/DEV/XVDB1
4. Build Mount Directory
# mkdir/data
5. Mount Partition
# Mount/dev/xvdb1/data
6. Set Mount automatically mount
Vi/etc/fstab
Enter I into inert mode in VI, move the cursor to the end of the file and enter, copy/paste the contents below, then press ESC, enter: X Save and exit Www.111cn.net
/dev/ Xvdb1/data ext3 defaults 0 0
7. Confirm that mount is successful
Reboot server
# reboot
View hard disk partition
# DF
/DEV/XVDB1 20635700 176196 19 411268 1%/data

5. Install GCC First
6. Install Nginx

The code is as follows Copy Code
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.gz
Tar zxvf pcre-8.31.tar.gz
CD pcre-8.31/
./configure
Make && make install
Cd.. /
Checking for a bsd-compatible install .../usr/bin/install-c
Checking whether build environment is sane ... yes
Checking for a thread-safe mkdir-p .../bin/mkdir-p
Checking for gawk ... gawk
Checking whether make sets $ (make) ... yes
Checking for gcc ... no
Checking for cc ... No
Checking for cl.exe ... no
Configure:error:in '/web/soft/pcre-8.31 ':
Configure:error:no acceptable C compiler found in $PATH
"Config.log ' For more details"
If such an error occurs, the system does not compile GCC
Yum install gcc resolves this issue
libtool:compile:unrecognized option '-dhave_config_h '
Libtool:compile:Try ' Libtool--help ' for more information.
MAKE[1]: * * * [Pcrecpp.lo] Error 1
MAKE[1]: Leaving directory '/web/soft/pcre-8.31 '
Make: * * * [ALL] Error 2
Lack of gcc-c++
Yum Install gcc-c++
can be compiled by

Two. Install Nginx

The code is as follows Copy Code

Official website: http://www.nginx.org/
wget http://www.nginx.org/download/nginx-1.2.5.tar.gz
Tar zxvf nginx-1.2.5.tar.gz
CD nginx-1.2.5/
./configure--user=www--group=www--prefix=/web/server/nginx--with-http_stub_status_module--with-http_ssl_module
Make && make install
Cd.. /
Error Tip Summary:
Installation prompts error libpcre.so.1, you need to execute the command ln-s/usr/local/lib/libpcre.so.1/lib64
If you do not have the PCRE library installed, you will be prompted when you compile the installation nginx./configure:error:the HTTP Rewrite module requires the PCRE library.
If prompted error nginx: [Emerg] Getpwnam ("www") failed indicates that there are no WWW users in the system groupadd-f www useradd-g www www
If prompted incorrectly./CONFIGURE:ERROR:SSL modules require the OpenSSL library. You need to install OpenSSL
SSL official website address: http://www.openssl.org/source/
wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
To reinstall Nginx after compiling and installing SSL
./configure--user=www--group=www--prefix=/web/server/nginx--with-http_stub_status_module--with-openssl=/usr/ Local/ssl
If GCC is not installed on the system, you will need to install GCC first. Command Yum install gcc*
Other errors:
Compile NGINX hint gzip module requires the Zlib library
Novice when trying to install nginx, often because of lack of dependent components, causing nginx the corresponding module can not be installed, in the execution of "./configure" often appear error.
If you added "--with-http_gzip_static_module" after "./configure" (add gzip compression module), you are prompted with the following error:
./configure:error:the HTTP gzip module requires the Zlib library.
Can either disable the module by Using–without-http_gzip_module
option, or install the Zlib library into the system, or build the Zlib library
Statically from the source with Nginx by using–with-zlib= option.
You need to install "zlib-devel". SSH executes the following command:
Yum install-y zlib-devel or go to the official website to download zlib installation wget http://zlib.net/zlib-1.2.7.tar.gz


7. Install MySQL

The code is as follows Copy Code
RPM-IVH mysql.rpm

8. Install PHP See

Install php5.4.0, compile installation php-5.4.0, php5.4.0 Zend Guard Loader temporarily do not support, waiting for Zend official update.

The code is as follows Copy Code
1. Download
wget wget http://cn.php.net/distributions/php-5.4.0.tar.gz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
wget "Http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0"
wget "Http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&big_mirror=0"
wget "Http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0"
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.7.5-9.tar.gz
wget HTTP://PECL.PHP.NET/GET/IMAGICK-3.0.1.TGZ2. Compile the support libraries required to install PHP 5.4.0
wget http://pecl.php.net/get/memcache-3.0.7.tgz
Tar zxvf libiconv-1.14.tar.gz
CD libiconv-1.14
./configure--prefix=/usr/local
Make
Make install
Cd.. /
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
Cd.. /.. /
Tar zxvf mhash-0.9.9.9.tar.gz
CD mhash-0.9.9.9/
./configure
Make
Make install
Cd.. /
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
Tar zxvf mcrypt-2.6.8.tar.gz
CD mcrypt-2.6.8/
/sbin/ldconfig
./configure
Make
Make install
Cd.. /
3. Compile mysql5.5.21
wget http://mysql.stu.edu.tw/Downloads/MySQL-5.5/mysql-5.5.21.tar.gz
wget http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz
Tar xvzf cmake-2.8.7.tar.gz
./configure
Make
Make install
Compile and install MySQL
Tar xvzf mysql-5.5.21.tar.gz
CD mysql5.5.21
RM CMakeCache.txt
CMake.
-dcmake_install_prefix=/usr/local/mysql5.5.21/
-dmysql_datadir=/usr/local/mysql5.5.21/data
-dwith_innobase_storage_engine=1
-dmysql_tcp_port=3306
-dmysql_unix_addr=/usr/local/mysql5.5.21/data/mysql.sock
-dmysql_user=mysql
-dwith_debug=0
Make && make install 4. Compiling PHP
Install Dependency Pack
Yum install ncurses-devel libxml2-devel bzip2-devel libcurl-devel curl-devel libjpeg-devel libpng-devel freetype-devel Net-snmp-devel
Tar xvzf php-5.4.0.tar.gz
CD php-5.4.0
./configure--prefix=/web/server/php--with-config-file-path=/web/server/php/etc--with-mysql--with-mysqli- With-pdo-mysql--with-iconv-dir=/usr/local--enable-fpm--disable-phar--with-fpm-user=www-data--with-fpm-group= Www-data--with-pcre-regex--with-zlib--with-bz2--enable-calendar--with-curl- Enable-ftp--with-gd--with-jpeg-dir--with-png-dir--with-zlib-dir--with-freetype-dir-- Enable-gd-jis-conv--with-mhash--enable-mbstring--with-mcrypt--enable-pcntl--enable-xml-- Enable-shmop--enable-sockets--enable-zip--enable-bcmath--with-snmp--disable-ipv6
Make zend_extra_libs= '-liconv '
Make Test
Make install
CP php.ini-production/usr/local/php5.4.0/etc/php.ini5. Compile and install PHP5 extension module
If you are running/web/server/php/bin/phpize, you are prompted to install M4 autoconf
Cannot find autoconf. Please check your autoconf installation and the
$PHP _autoconf environment variable. Then, rerun this script.
Yum Install autoconf
Yum Install M4
Tar zxvf memcache-3.0.7.tgz
CD memcache-3.0.7/
/web/server/php/bin/phpize
./configure--with-php-config=/web/server/php/bin/php-config
Make
Make install
Cd.. /
/* No compilation succeeded/*
Tar xvzf memcached-1.0.2.tgz
CD memcached-1.0.2
/web/server/php/bin/phpize
./configure--with-php-config=/web/server/php/bin/php-config
Make
Make install
Cd.. /
/* No compile/* *
Tar zxvf ImageMagick.tar.gz
CD imagemagick-6.5.1-2/
./configure
Make
Make install
Cd.. /
/* No compile/* *
Tar zxvf imagick-2.3.0.tgz
CD imagick-2.3.0/
/usr/local/php5.4.0/bin/phpize
./configure--with-php-config=/usr/local/php5.4.0/bin/php-config
Make
Make install
Cd.. /6. Modify Configuration
Vi/web/server/php/etc/php.ini
Finally add:
; Change for Hugwww
Extension_dir =/usr/local/php5.4.0/lib/php/extensions/no-debug-non-zts-20090626/
Extension = "memcache.so"
Extension = "memcached.so"
Extension = "imagick.so"
Modified to:
Cgi.fix_pathinfo=0
Open_basedir =/tmp:/www/web
expose_php = Off
Allow_url_fopen = Off
Disable_functions =phpinfo,passthru,ini_restore,eval Finish!

. Boot boot See

Edit the/etc/rc.d/rc.local file and add the file you want to start

The code is as follows Copy Code
/web/server/nginx/sbin/nginx
/web/server/php/sbin/php-fpm
/web/server/subversion/bin/svnserve-d-r/web/svn/repos
/web/server/memcached/bin/memcached-d-M 100-u www-l 127.0.0.1-p 11211-c 256-p/tmp/memcached.pid
/web/server/apache/bin/apachectl

The above is the start Nginx service
Start the PHP service
Start the SVN service
Start the memcached service

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.