CentOS 5.5 Compile and install Lnmp

Source: Internet
Author: User
Tags download zend mcrypt

If you are installing Centos6.5 remember that Perl is required, otherwise you cannot install VMware tools!!!! Remember If a make error is required to install additional software, load it up .Make the install clean build

Web Server Architecture: linux+nginx+mysql+php

Specific Version: CentOS 5.5+nginx1.0.15+mysql5.5.23+php5.3.10

System Installation Tutorials: CentOS 5.5 Installation Illustration tutorial

Http://www.osyunwei.com/archives/3625.html

Prepare the article:

First, configure IP, DNS, gateway, ensure the use of Remote Connection tool to connect to the server

CentOS set IP address, gateway, DNS tutorial:

Http://www.osyunwei.com/archives/423.html

Second, configure the firewall, open 80 port, 3306 port

Vi/etc/sysconfig/iptables #编辑防火墙配置文件

-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT

-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT

System operation and maintenance www.osyunwei.com warm reminder: qihang01 original content copyright, reproduced please indicate the source and the original link

Special Note: Many netizens add these two rules to the last line of the firewall configuration, causing the firewall to fail to start, the correct one should be added to the default 22 port under this rule

After adding the firewall rules as follows:

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

# Firewall configuration written by System-config-securitylevel

# Manual Customization of this file are not recommended.

*filter

: INPUT ACCEPT [0:0]

: FORWARD ACCEPT [0:0]

: OUTPUT ACCEPT [0:0]

: Rh-firewall-1-input-[0:0]

-A input-j Rh-firewall-1-input

-A forward-j Rh-firewall-1-input

-A rh-firewall-1-input-i lo-j ACCEPT

-A rh-firewall-1-input-p ICMP--icmp-type any-j ACCEPT

-A rh-firewall-1-input-p 50-j ACCEPT

-A rh-firewall-1-input-p 51-j ACCEPT

-A rh-firewall-1-input-p UDP--dport 5353-d 224.0.0.251-j ACCEPT

-A rh-firewall-1-input-p udp-m UDP--dport 631-j ACCEPT

-A rh-firewall-1-input-p tcp-m tcp--dport 631-j ACCEPT

-A rh-firewall-1-input-m state--state established,related-j ACCEPT

-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 22-j ACCEPT

-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT

-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT

-A rh-firewall-1-input-j REJECT--reject-with icmp-host-prohibited

COMMIT

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

/etc/init.d/iptables Restart #最后重启防火墙使配置生效

Third, close SELinux

Vi/etc/selinux/config #编辑配置文件

#SELINUX =enforcing #注释掉

#SELINUXTYPE =targeted #注释掉

Selinux=disabled #增加

: Wq #保存

Shutdown-r now #重启系统

Iv. System Conventions

Software source code Package storage location:/USR/LOCAL/SRC

Source Package Compilation Installation location:/usr/local/software Name

V. Download the package

1, download Nginx (currently stable version)

Http://nginx.org/download/nginx-1.0.15.tar.gz

2, download pcre (support Nginx pseudo-static)

Ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz

3. Download MySQL

Http://mysql.mirrors.pair.com/Downloads/MySQL-5.5/mysql-5.5.23.tar.gz

4. Download PHP

Http://cn.php.net/distributions/php-5.3.10.tar.gz

5. Download CMake (MySQL compilation tool)

Http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz

6. Download Libmcrypt (phplibmcrypt module)

Ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz

System operation and maintenance www.osyunwei.com warm reminder: qihang01 original content copyright, reproduced please indicate the source and the original link

7. Download Zend Guard

Http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz #32位

Http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz #64位

Vi. install the compilation tools and library files (install using the CentOS Yum command)

Yum install make apr* autoconf automake Curl curl-devel gcc gcc-c++ zlib-devel OpenSSL openssl-devel pcre-devel gd kernel Keyutils Patch perl kernel-headers compat* cpp glibc libgomp libstdc++-devel keyutils-libs-devel libsepol-devel Libselinu X-devel krb5-devel zlib-devel libxpm* freetype libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel Patch

Installation article

The following is a remote login to the server using the Putty tool, which operates under the command line

To install LIBXML2 steps:

1, Decompression: $tar zxvf libxml2-2.6.20.tar.gz

2, into the decompression after the installation directory: $CD libxml2-2.6.20

3. Installation Trilogy: 1) $./configure

2) $make

3) $make Install

Installation Complete

Error Png.h not found

Checking for FABSF ... yes checking for Floorf ... yes checking for Jpeg_read_header in-ljpeg ... yes configure:error:png.h not Found.

Fix:yum install libpng-devel

First, install the Libmcrypt

Cd/usr/local/src

Tar zxvf libmcrypt-2.5.7.tar.gz #解压

CD libmcrypt-2.5.7 #进入目录

./configure #配置

Make #编译

Make install #安装

Second, installation CMake

Cd/usr/local/src

Tar zxvf cmake-2.8.8.tar.gz

CD cmake-2.8.8

./configure

Make #编译

Make install #安装

Third, installation Pcre

Cd/usr/local/src

Mkdir/usr/local/pcre #创建安装目录

Tar zxvf pcre-8.30.tar.gz

CD pcre-8.30

./configure--prefix=/usr/local/pcre #配置

Make

Make install

Iv. installation of MySQL

One: Uninstall the old version

Use the following command to check if MySQL Server is installed

Rpm-qa | grep MySQL

Some words are unloaded by the following command

RPM-E MySQL   //normal Delete mode rpm-e--nodeps mysql    //brute force Delete mode, if you use the above command to delete, prompted to have other dependent files, then use this command can be strongly deleted
Two: Install MySQL install the package required for compiling code
Yum-y install make gcc-c++ cmake bison-devel  ncurses-devel
Download MySQL 5.6.14
wget Http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.14.tar.gztar xvf mysql-5.6.14.tar.gzcd mysql-5.6.14
Compiling the installation
Cmake-dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/usr/local/mysql/data \
-dsysconfdir=/etc-dwith_myisam_storage_engine=1-dwith_innobase_storage_engine=1-dwith_memory_storage_engine=1- Dwith_readline=1-dmysql_unix_addr=/var/lib/mysql/mysql.sock-dmysql_tcp_port=3306-denabled_local_infile=1-dwith _partition_storage_engine=1-dextra_charsets=all-ddefault_charset=utf8-ddefault_collation=utf8_general_cimake && make Install

The compiled parameters can refer to http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html.

The whole process takes about 30 minutes ... A long wait

Three: Configure MySQL settings permissions

Use the following command to see if there are MySQL users and user groups

CAT/ETC/PASSWD View user list Cat/etc/group  View user Groups list

If not, create

Groupadd mysqluseradd-g MySQL MySQL

Modify/usr/local/mysql Permissions

Chown-r Mysql:mysql/usr/local/mysql

Modify/usr/local/mysql Permissions

Initialize configuration

Go to installation path

Cd/usr/local/mysql

Enter the installation path, execute the initialization configuration script, create the system's own database and table

scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data--user=mysql

Note: When starting the MySQL service, will be in a certain order to search my.cnf, first in the/etc directory, find will search "$basedir/my.cnf", in this case is/usr/local/mysql/ MY.CNF, this is the default location for the new MySQL configuration file! Note: After the minimum installation of the CentOS version 6.4 operating system, there will be a my.cnf in the/etc directory, which will need to be renamed to a different name, such as:/etc/ My.cnf.bak, otherwise, the file will interfere with the correct configuration of the source installed MySQL, resulting in the inability to start.

If startup is unsuccessful after installing MySQL, the following error is prompted

Starting MySQL. error! The server quit without updating PID file (/var/lib/mysql/localhost.pid).

Workaround:

1. Setting up users and permissions for the MySQL installation directory

chmod 0777/usr/local/mysql-r

2. Initialize MySQL table

/usr/local/mysql/scripts/mysql_install_db--user=mysql

If not, manually establish the directory/var/lib/mysql/and set the permissions to 0777

At the start of MySQL should be ready

Start MySQL

Add services, Copy service scripts to the INIT.D directory, and set boot boot

CP support-files/mysql.server/etc/init.d/mysqlchkconfig MySQL onservice mysql start  --Start MySQL
Configure users

After MySQL starts successfully, Root does not have a password, we need to set the root password.

Before setting, we need to set path, or we can't call MySQL directly

Modify the/etc/profile file to add at the end of the file

Path=/usr/local/mysql/bin: $PATHexport PATH

Close the file, run the following command, and let the configuration take effect immediately

Source/etc/profile

Now, we can enter MySQL in the terminal directly into the MySQL environment

Execute the following command to modify the root password

Mysql-uroot  mysql> SET PASSWORD = PASSWORD (' 123456 ');

To set the root user to have remote access, perform

Mysql> GRANT All privileges on * * to ' root ' @ ' 172.16.% ' identified by ' password ' with GRANT OPTION;

When the red password is remote access, the root user's password can be different from the local.

Configuring firewalls

Firewall 3306 port is not enabled by default, to remote access, you need to open this port

Open/etc/sysconfig/iptables

Under "-A input–m State--state new–m tcp–p–dport 22–j ACCEPT", add:

-A input-m state--state new-m tcp-p-dport 3306-j ACCEPT

Then save and close the file, run the following command in the terminal and refresh the firewall configuration:

Service Iptables Restart
OK, all configured, you can access your MySQL ~

Source: >  

To this, MySQL installation is complete!

Five, install Nginx

Groupadd www #添加运行www组

Useradd-g www www-s/bin/false #创建nginx运行账户www并加入到www组, www users are not allowed to log in directly to the system

Cd/usr/local/src

Tar zxvf nginx-1.0.15.tar.gz

CD nginx-1.0.15

./configure--prefix=/usr/local/nginx--without-http_memcached_module--user=www--group=www--with-http_stub_ Status_module--with-openssl=/usr/--with-pcre=/usr/local/src/pcre-8.30

Note:--with-pcre=/usr/local/src/pcre-8.30 points to the source package decompression path, not the installation path, otherwise it will be an error

System operation and maintenance www.osyunwei.com warm reminder: qihang01 original content copyright, reproduced please indicate the source and the original link

Make #编译

Make install #安装

/usr/local/nginx/sbin/nginx #启动nginx

Set Nginx on Start

Vi/etc/rc.d/init.d/nginx #编辑启动文件添加下面内容

=======================================================

#!/bin/bash

# nginx Startup script for the Nginx HTTP Server

# it is v.0.0.2version.

# 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:nginx

# Pidfile:/var/run/nginx.pid

# config:/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 are 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 "$" 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

System operation and maintenance www.osyunwei.com warm reminder: qihang01 original content copyright, reproduced please indicate the source and the original link

=======================================================

: wq! #保存退出

chmod 775/etc/rc.d/init.d/nginx #赋予文件执行权限

Chkconfig Nginx on #设置开机启动

/etc/rc.d/init.d/nginx Restart #重启nginx

Service Nginx Restart #重启nginx

=======================================================

Vi. Installation of PHP

Cd/usr/local/src

TAR-ZVXF php-5.3.10.tar.gz

CD php-5.3.10

Mkdir-p/USR/LOCAL/PHP5 #建立php安装目录

./configure--PREFIX=/USR/LOCAL/PHP5--with-config-file-path=/usr/local/php5/etc--with-mysql=/usr/local/mysql--  With-mysqli=/usr/local/mysql/bin/mysql_config--with-mysql-sock=/tmp/mysql.sock--with-gd--with-iconv--with-zlib --enable-xml--enable-magic-quotes--enable-safe-mode--enable-bcmath--enable-shmop--enable-sysvsem-- Enable-inline-optimization--with-curlwrappers--enable-mbregex--enable-fpm--enable-mbstring--enable-ftp-- Enable-gd-native-ttf--with-openssl--enable-pcntl--enable-sockets--with-xmlrpc--enable-zip--enable-soap-- Without-pear--with-gettext--enable-session--with-mcrypt--with-curl #配置

Make #编译

Make install #安装

CP Php.ini-production/usr/local/php5/etc/php.ini #复制php配置文件到安装目录

Rm-rf/etc/php.ini #删除系统自带配置文件

Ln-s/usr/local/php5/etc/php.ini/etc/php.ini #添加软链接

cp/usr/local/php5/etc/php-fpm.conf.default/usr/local/php5/etc/php-fpm.conf #拷贝模板文件为php-fpm configuration file

Vi/usr/local/php5/etc/php-fpm.conf #编辑

user = www #设置php-fpm run account is www

Group = www #设置php-fpm run Group is www

PID = Run/php-fpm.pid #取消前面的分号

Set PHP-FPM boot up

CP/USR/LOCAL/SRC/PHP-5.3.10/SAPI/FPM/INIT.D.PHP-FPM/ETC/RC.D/INIT.D/PHP-FPM #拷贝php-fpm to startup directory

chmod +x/etc/rc.d/init.d/php-fpm #添加执行权限

Chkconfig PHP-FPM on #设置开机启动

Vi/usr/local/php5/etc/php.ini #编辑配置文件

Found in:; Open_basedir =

Modified to: Open_basedir =.:/ tmp/#防止php木马跨站, Important!! Note: If the program does not install after the setup, there are blank pages and other errors (such as discuz_x2.5), you can cancel the settings, after the installation is complete and then set to take effect)

Found: Disable_functions =

Modified to: Disable_functions = Passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini _alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server, Escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space, POSIX_CTERMID,POSIX_GET_LAST_ERROR,POSIX_GETCWD, Posix_getegid,posix_geteuid,posix_getgid, Posix_getgrgid,posix_ Getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, Posix_getppid,posix_getpwnam, Posix_getpwuid, Posix_getrlimit, Posix_getsid,posix_getuid,posix_isatty, Posix_kill,posix_mkfifo,posix_setegid, Posix_seteuid,posix_setgid, Posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname, Posix_uname

#列出PHP可以禁用的函数, if some programs need to use this function, you can delete, cancel disable.

Found:;d Ate.timezone =

Modified to: Date.timezone = PRC #设置时区, PRC on behalf of China

Found: expose_php = On

Modified to: expose_php = OFF #禁止显示php版本的信息

System operation and maintenance www.osyunwei.com warm reminder: qihang01 original content copyright, reproduced please indicate the source and the original link

Seven, configuration nginx support PHP

Vi/usr/local/nginx/conf/nginx.conf #修改配置文件

User www www; #首行user去掉注释, modify the Nginx run group to www www; must be the same as the User,group configuration in/usr/local/php5/etc/php-fpm.conf, or PHP will run in error

Index index.php index.html index.htm; #添加index. php

# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

Location ~ \.php$ {

root HTML;

Fastcgi_pass 127.0.0.1:9000;

Fastcgi_index index.php;

Fastcgi_param Script_filename/usr/local/nginx/html$fastcgi_script_name; #指定路径

Include Fastcgi_params;

}

#取消FastCGI the comment for the server section location, and note the parameters of the Fastcgi_param row, change to $document_root$fastcgi_script_name, or use the Site Directory absolute path

/etc/init.d/nginx Restart #重启nginx

Viii. Configuring PHP support Zend Guard

System operation and maintenance www.osyunwei.com warm reminder: qihang01 original content copyright, reproduced please indicate the source and the original link

Installing Zend Guard

Cd/usr/local/src

Mkdir/usr/local/zend #建立Zend安装目录

Tar xvfz zendguardloader-php-5.3-linux-glibc23-i386.tar.gz #解压安装文件

CP zendguardloader-php-5.3-linux-glibc23-i386/php-5.3.x/zendguardloader.so/usr/local/zend/#拷贝文件到安装目录

Vi/usr/local/php5/etc/php.ini #编辑文件

Add the following at the last location

[Zend Guard]

Zend_extension=/usr/local/zend/zendguardloader.so

Zend_loader.enable=1

Zend_loader.disable_licensing=0

Zend_loader.obfuscation_level_support=3

Zend_loader.license_path=

Test article

cd/usr/local/nginx/html/#进入nginx默认网站根目录

rm-rf/usr/local/nginx/html/* #删除默认测试页

VI index.php #新建index. php file

<?php

Phpinfo ();

?>

: wq! #保存

Chown www.www/usr/local/nginx/html/-R #设置目录所有者

chmod 700/usr/local/nginx/html/-R #设置目录权限

Shutdown-r now #重启

In the client browser enter the server IP address, you can see the relevant configuration information!

Service Nginx Restart #重启nginx

Service mysqld Restart #重启mysql

/USR/LOCAL/PHP5/SBIN/PHP-FPM #启动php-FPM

/ETC/RC.D/INIT.D/PHP-FPM Restart #重启php-fpm

/ETC/RC.D/INIT.D/PHP-FPM Stop #停止php-FPM

/ETC/RC.D/INIT.D/PHP-FPM Start #启动php-fpm

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

Note:

Nginx Default Site Directory is:/usr/local/nginx/html/

Permission settings: Chown www.www/usr/local/nginx/html/-R

MySQL database directory is:/data/mysql

Permission settings: Chown mysql.mysql-r/data/mysql

Now centos5.5 under installation LNMP operating environment to complete the construction

CentOS 5.5 Compile and install Lnmp

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.