LNMP-2014.8.18.LNMP environment setup (continuous update)

Source: Internet
Author: User

1.1 System Environment
The experimental environment is centos 6.5 x86_64. The virtual machine has two IP addresses, one of which is connected to the Internet. Yum allows you to install the required software package over the network. The main software, such as nginx, MySQL, and PHP, is installed through the source code. The related information is as follows:
1) The official nginx website is http://nginx.org/. use the latest and stable version nginx-1.6.1.tar.gz.
2) the MySQL official website is http://www.mysql.com/. use the latest 5.5 stable version mysql-5.5.39.tar.gz.
3) the PHP official website is http://www.php.org/. use 5.3366php-5.3.28.tar.gz here.

1.2 install lnmp
1.2.1 install the required RPM Software Package
This experiment downloads and installs the epel source to solve the software package dependency problem during lnmp installation:

[[email protected] src]# rpm -ivh http://ftp.sjtu.edu.cn/fedora/epel/6Server/x86_64/epel-release-6-8.noarch.rpm[[email protected] src]# yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel pcre pcre-devel openssl openssl-devel ncurses ncurses-devel bison bison-devel libxml2 libxml2-devel libjpeg-turbo libjpeg-turbo-devel libpng libpng-devel freetype freetype-devel freetype freetype-devel


1.2.2 install and set nginx

[[email protected] src]# groupadd www[[email protected] src]# useradd -g www -s /sbin/nologin www[[email protected] src]# tar zxf nginx-1.6.1.tar.gz[[email protected] nginx-1.6.1]# ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module…Configuration summary  + using system PCRE library  + using system OpenSSL library  + md5: using OpenSSL library  + sha1: using OpenSSL library  + using system zlib library…[[email protected] nginx-1.6.1]# make && make install[[email protected] nginx-1.6.1]# cd /usr/local/nginx/conf/[[email protected] conf]# cp nginx.conf{,.bak}[[email protected] conf]# vi nginx.confuser  www www;worker_processes  1;error_log  /home/wwwlogs/nginx_error.log  crit;pid       /usr/local/nginx/logs/nginx.pid;worker_rlimit_nofile  51200;events {    use  epoll;    worker_connections  51200;}http {    include       mime.types;    default_type  application/octet-stream;    log_format  access  ‘$remote_addr - $remote_user [$time_local] "$request" ‘                        ‘$status $body_bytes_sent "$http_referer" ‘                        ‘"$http_user_agent" $http_x_forwarded_for‘;    access_log  /usr/local/nginx/logs/access.log  access;    server_names_hash_bucket_size 128;    client_header_buffer_size 32k;    large_client_header_buffers 4 32k;    client_max_body_size 50m;    sendfile            on;    tcp_nopush          on;    tcp_nodelay         on;    keepalive_timeout 60;    client_header_timeout 10;    client_body_timeout 10;    send_timeout 10;    fastcgi_connect_timeout 300;    fastcgi_send_timeout 300;    fastcgi_read_timeout 300;    fastcgi_buffer_size 64k;    fastcgi_buffers 4 64k;    fastcgi_busy_buffers_size 128k;    fastcgi_temp_file_write_size 128k;gzip                on;gzip_min_length     1k;    gzip_buffers        4 16k;    gzip_comp_level     2;    gzip_types          text/plain application/x-javascript text/css application/xml;    gzip_vary           on;    server {        listen          80;        server_name     localhost;        index index.html index.htm index.php;        root /home/wwwroot;        location ~ .*\.(php|php5)?$ {            fastcgi_pass 127.0.0.1:9000;            fastcgi_index index.php;            include fastcgi_params;        }        location /status {            stub_status on;            access_log   off;        }        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {            expires      30d;        }        location ~ .*\.(js|css)?$ {            expires      12h;        }        error_page  500 502 503 504  /50x.html;        location = /50x.html {             root html;        }    }}[[email protected] conf]# vi fastcgi_params…fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;[[email protected] conf]# mkdir /home/wwwroot[[email protected] conf]# mkdir /home/wwwlogs[[email protected] conf]# chmod 777 /home/wwwlogs/[[email protected] conf]# /usr/local/nginx/sbin/nginx -tnginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful[[email protected] conf]# vi /etc/init.d/nginx#!/bin/bash# nginx Startup script for the Nginx HTTP Server## 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: /usr/local/nginx/logs/nginx.pid# config: /usr/local/nginx/conf/nginx.confnginxd=/usr/local/nginx/sbin/nginxnginx_config=/usr/local/nginx/conf/nginx.confnginx_pid=/usr/local/nginx/logs/nginx.pidRETVAL=0prog="nginx"# Source function library.. /etc/rc.d/init.d/functions# Source networking configuration.. /etc/sysconfig/network# Check that networking is up.[ ${NETWORKING} = "no" ] && exit 0[ -x $nginxd ] || exit 0# Start nginx daemons functions.start() {if [ -e $nginx_pid ];then  echo "nginx already running...."  exit 1fi  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 nginx service functions.reload() {  echo -n $"Reloading $prog: "  killproc $nginxd -HUP  RETVAL=$?  echo}# See how we were called.case "$1" instart)  start  ;;stop)  stop  ;;reload)  reload  ;;restart)  stop  start  ;;status)  status $prog  RETVAL=$?  ;;*)  echo $"Usage: $prog {start|stop|restart|reload|status|help}"  exit 1esacexit $RETVAL[[email protected] conf]# chmod u+x /etc/init.d/nginx[[email protected] conf]# chkconfig --add nginx[[email protected] conf]# chkconfig nginx on[[email protected] conf]# chkconfig --list nginxnginx           0:off   1:off   2:on    3:on    4:on    5:on    6:off


1.2.3 install and set MySQL

[[email protected] src]# wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz[[email protected] src]# tar zxf cmake-2.8.12.2.tar.gz[[email protected] src]# cd cmake-2.8.12.2[[email protected] cmake-2.8.12.2]# ./configure && make && make install[[email protected] src]# groupadd mysql[[email protected] src]# useradd -g mysql mysql[[email protected] src]# tar zxf mysql-5.5.39.tar.gz[[email protected] src]# cd mysql-5.5.39[[email protected] mysql-5.5.39]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/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 -DWITH_INNOBASE_STORAGE_ENGINE=1[[email protected] mysql-5.5.39]# make && make install[[email protected] mysql-5.5.39]# cp support-files/my-medium.cnf /usr/local/mysql/my.cnf[[email protected] mysql-5.5.39]# cd /usr/local/mysql/[[email protected] mysql]# vi my.cnf[mysqld]…basedir = /usr/local/mysqldatadir = /usr/local/mysql/data[[email protected] mysql]# chown -R mysql.mysql data[[email protected] mysql]# scripts/mysql_install_db --defaults-file=./my.cnf --user=mysql[[email protected] mysql]# cp /usr/local/src/mysql-5.5.39/support-files/mysql.server /etc/init.d/mysqld[[email protected] mysql]# chmod u+x /etc/init.d/mysqld[[email protected] mysql]# chkconfig --add mysqld[[email protected] mysql]# chkconfig mysqld on[[email protected] mysql]# chkconfig --list mysqldmysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off


1.2.4 install and set PHP

[[email protected] src]# tar zxf php-5.3.28.tar.gz[[email protected] src]# cd php-5.3.28[[email protected] php-5.3.28]# ln -s /usr/lib64/libltdl.so.3.1.4 /usr/lib64/libltdl.so[[email protected] php-5.3.28]# ./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 --enable-fpm --with-mcrypt --with-mhash --enable-mbstring --with-gettext --with-gd --with-gettext --with-jpeg-dir --with-freetype-dir --enable-bcmath --enable-sockets[[email protected] php-5.3.28]# make && make install[[email protected] php-5.3.28]# cp php.ini-production /usr/local/php/etc/php.ini[[email protected] php-5.3.28]# cd /usr/local/php/etc[[email protected] etc]# cp php-fpm.conf.default php-fpm.conf[[email protected] etc]# vi php-fpm.confuser = wwwgroup = www[[email protected] etc]# cp /usr/local/src/php-5.3.28/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm[[email protected] etc]# chmod u+x /etc/init.d/php-fpm[[email protected] etc]# chkconfig --add php-fpm[[email protected] etc]# chkconfig php-fpm on[[email protected] etc]# chkconfig --list php-fpmphp-fpm         0:off   1:off   2:on    3:on    4:on    5:on    6:off


1.2.5 start various services and create a test page

[[email protected] ~]# /etc/init.d/nginx start[[email protected] ~]# /etc/init.d/mysqld start[[email protected] ~]# /etc/init.d/php-fpm start[[email protected] etc]# echo "<?php phpinfo(); ?>" > /home/wwwroot/phpinfo.php


1.2.6 install phpMyAdmin

[[email protected] src]# tar zxf phpMyAdmin-4.2.7.1-all-languages.tar.gz[[email protected] src]# cp -rf phpMyAdmin-4.2.7.1-all-languages /home/wwwroot/phpmyadmin[[email protected] src]# /usr/local/mysql/bin/mysqladmin -u root password ‘iforgot‘






LNMP-2014.8.18.LNMP environment setup (continuous update)

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.