1: Environment Preparation
Useradd nginx-s/sbin/nologin-m
Useradd mysql-s/sbin/nologin-m
Nginx:nginx-1.8.1.tar.gz
Http://nginx.org/download/nginx-1.8.1.tar.gz
Cmake-2.8.10.2.tar.gz
http://download.chinaunix.net/download.php?id=45213&ResourceID=1605
Mysql-5.5.13.tar.gz
Http://www.mysql.com/downloads/mysql
PHP Extension Library
Mhash-0.9.9.9.tar.gz
Libiconv-1.13.tar.gz
Libmcrypt-2.5.8.tar.gz
Php-5.4.9.tar.gz
Yum-y install vim-enhanced ncurses-devel elinks gcc gcc-c++ Flex bison autoconf automake gzip net-snmp-devel net-snmp \
Ncurses-devel pcre pcre-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel libXpm-devel \
Gettext-devel pam-devel libtool libtool-ltdl OpenSSL openssl-devel fontconfig-devel \
Libxml2-devel curl-devel libicu libicu-devel libmcrypt libmcrypt-devel libmhash libmhash-devel
2: Install Nginx
TAR-ZXF nginx-1.8.1.tar.gz
CD nginx-1.8.1
Detailed compilation parameters See: http://blog.csdn.net/eric1012/article/details/6052154
./configure--prefix=/usr/local/nginx--pid-path=/usr/local/nginx/nginx.pid--user=nginx--group=nginx \
--with-http_ssl_module--with-http_flv_module--with-http_stub_status_module--with-http_gzip_static_module-- Http-client-body-temp-path=/usr/local/nginx/client \
--http-proxy-temp-path=/usr/local/nginx/proxy--http-fastcgi-temp-path=/usr/local/nginx/fcgi-- Http-uwsgi-temp-path=/usr/local/nginx/uwsgi--http-scgi-temp-path=/usr/local/nginx/scgi--with-pcre
Make && make install
2.1: Start Nginx
Check syntax
/usr/local/nginx/sbin/nginx-t
Start Nginx
/usr/local/nginx/sbin/nginx
2.2: Test
NETSTAT-NTLP | grep nginx
Browser test: http:/192.168.110.130
Command-line test: ELinks--dump http://192.168.110.130
3: Install MySQL (cmake installation or binary file mode installation)
3.1: Install CMake
TAR-ZXF cmake-2.8.10.2.tar.gz
CD cmake-2.8.10.2
./bootstrap--prefix=/usr/local/cmake
Make && make install
3.2: Install MySQL
TAR-ZXF mysql-5.5.13.tar.gz
CD mysql-5.5.13
Compilation parameters: Http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html
/usr/local/cmake/bin/cmake-dcmake_install_prefix=/usr/local/mysql-dsysconfdir=/etc-dmysql_datadir=/usr/local/m Ysql/data \
-dmysql_tcp_port=3306-dmysql_unix_addr=/tmp/mysqld.sock-dmysql_user=mysql \
-dextra_charsets=all-dwith_readline=1-dwith_ssl=system-dwith_embedded_server=1-denabled_local_infile=1-dwit H_innobase_storage_engine=1
Make
Make install (do not write this here do && make install)
3.3: Initialize the database and set up the master configuration file
/usr/local/mysql/scripts/mysql_install_db--user=mysql
Cp-p/usr/local/src/mysql-5.5.13/support-files/my-medium.cnf/etc/my.cnf
Ln-s/usr/local/mysql/bin/*/usr/sbin/
3.4: Start the database and set the password test
/usr/local/mysql/bin/mysqld_safe--user=mysql &
netstat-ntlp| grep MySQL
Mysqladmin-hlocalhost-uroot password "Testpass"
Mysql-uroot-hlocalhost-ptestpass
4: Install PHP
4.1:php Installing the Extension library
Libmcrypt #动态内容的加载, adding and removing algorithms
Mhash #mhash为php提供了多种哈希算法 (Common MD5)
MCrypt #mcrypt加密和mhash结合使用对PHP加密 (20 algorithms, 8 encryption modes)
TAR-ZXF mhash-0.9.9.9.tar.gz
CD mhash-0.9.9.9
./configure
Make && make install
TAR-ZXF libiconv-1.13.tar.gz
CD libiconv-1.13
./configure
Make && make install
TAR-ZXF libmcrypt-2.5.8.tar.gz
CD libmcrypt-2.5.8
./configure
Make && make install
CD libltdl/
./configure--with-gmetad--enable-gexec--enable-ltdl-install
Make && make install
4.2: Install PHP
Environment preparation
Vim/etc/ld.so.conf
Include ld.so.conf.d/*.conf
/usr/local/mysql/lib/
/usr/local/mysql/include/
ln-sv/usr/local/lib/libmcrypt*/usr/lib/
ln-sv/usr/local/lib/libmhash.*/usr/lib/
ln-sv/usr/local/lib/libiconv.*/usr/lib/
Ldconfig
TAR-ZXF php-5.4.9.tar.gz
CD php-5.4.9
Detailed compilation parameters See: http://wanwentao.blog.51cto.com/2406488/647585
./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc \
--with-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-iconv-dir=/usr/local-- With-freetype-dir--with-jpeg-dir--with-png-dir \
--with-zlib--with-libxml-dir=/usr--enable-xml--disable-rpath--enable-bcmath--enable-shmop--enable-sysvsem- -enable-inline-optimization \
--with-curl--with-curlwrappers--enable-mbregex--enable-fpm--enable-mbstring--with-mcrypt--with-gd--enab Le-gd-native-ttf--with-openssl \
--with-mhash--enable-pcntl--enable-sockets--with-ldap--with-ldap-sasl--with-xmlrpc--enable-zip--enable-s Oap
Make zend_extra_libs= '-liconv '
Make install
4.3: Setting up the master configuration file
Cp/usr/local/src/php-5.4.9/php.ini-production/usr/local/php5nginx/etc/php.ini
vim/usr/local/nginx/html/test.php
4.4: Install configure FPM and start service
Cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
cd/usr/local/src/php-5.4.9/sapi/fpm
CP INIT.D.PHP-FPM/ETC/INIT.D/PHP-FPM
chmod +x/etc/init.d/php-fpm
/ETC/INIT.D/PHP-FPM start
Netstat-ntlp|grep PHP
5: Modify Nginx configuration so that it can parse PHP
Vim nginx.conf
HTTP {
server {
Location/{
root HTML;
Index index.php index.html;
}
Location ~ \.php$ {
root HTML;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param Script_filename/scripts$fastcgi_script_name;
Include Fastcgi_params;
}
}
}
Vim Fastcgi_params
Fastcgi_param script_filename $document _root$fastcgi_script_name;
5.1: Reload Nginx (The following two ways to smooth start)
Kill-hup ' Cat/usr/local/ngin/logs/nginx.pid '
/usr/local/nginx/sbin/nginx-s Reload
6: Test if PHP can connect to MySQL
VI index.php
<?php
$linkdb =mysql_connect ("localhost", "root", "Testpass");
if ($LINKDB) {
echo "OK";
}else{
echo "No";
};
?>
ELinks--dump http://192.168.110.130/index.php
LNMP Platform Construction