Linux environment to build LNMP

[MySQL installation]

1. Download mysql to / usr / local / src /

cd /usr/local/src/

wget http://syslab.comsenz.com/downloads/linux/mysql-5.0.86-linux-i686-icc-glibc23.tar.gz

2. Extract

tar zxvf /usr/local/src/ mysql-5.0.86-linux-i686-icc-glibc23.tar.gz

3. After the decompressed data is moved to / usr / local / mysql

mv mysql-5.0.86-linux-i686-ii-glibc23 /usr/local/mysql

4. Create mysql user

useradd mysql

5. initialize the database

cd /usr/local/mysql

mkdir /data/mysql ; chown -R mysql:mysql /data/mysql

./scripts/mysql_install_db --user=mysql --datadir=/data/mysql

--User belongs to the main database definition, - datadir defined where to install the database, it is recommended put on the partition large space, this directory need to create your own.

6. copy of the configuration file

cp support-files/my-large.cnf /etc/my.cnf

7. A copy of the startup script file and modify its properties

cp support-files/mysql.server  /etc/init.d/mysqld

chmod 755 /etc/init.d/mysqld

8. Modify the startup script

vim /etc/init.d/mysqld

Where there is need to modify datadir = / data / mysql (defined for the previous directory database initialization)

9. The system startup scripts added service items, and set the boot, start mysql

chkconfig --add mysqld

chkconfig mysqld on

service mysqld start

If you can not start, please view the error log / data / mysql / down, the log format hostname .err.

[ Php installation ]

Here first statement about, Nginx installation of php and php installation for apache for there is a difference, because the Nginx fastcgi php is a way to combine nginx, can be understood as a proxy nginx fastcgi php, and apache is to php as their own modules to call.

useradd www

cd /usr/local/src/

wget http://syslab.comsenz.com/downloads/linux/php-5.2.10.tar.gz

wget http://syslab.comsenz.com/downloads/linux/php-5.2.10-fpm-0.5.13.diff.gz

Download the second package php-5.2.10-fpm-0.5.13.diff.gz is used to patch php, by default, php is not compile out of fastcgi.

tar zxvf php-5.2.10.tar.gz

gzip -cd php-5.2.10-fpm-0.5.13.diff.gz | patch -d php-5.2.10 -p1

cd php-5.2.10

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysql-sock=/tmp --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt=/usr/local/libmcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --enable-zend-multibyte --disable-ipv6 --enable-fastcgi --enable-fpm

make && make install

mkdir /usr/local/php/etc

cp php.ini-dist /usr/local/php/etc/php.ini  

vim /usr/local/php/etc/php-fpm.conf

<value name = "listen_address"> / tmp / php-fcgi.sock </ value> to this line into this, here modified so that later, the configuration nginx when the need to pay attention to this path.
Modify the user and group name is "www"
remove notes this change:
the Unix User Processes of
                        <value name = "User"> WWW </ value>
                        the Unix Group of Processes
                        <name = value "Group"> WWW </ value >

/usr/local/php/sbin/php-fpm start

Other expansion modules installed on php refer to:

CentOS installation under mysql5.1.57 + php5.2.17 5.5 (FastCGI) + nginx1.0.1 high performance Web server

[ Nginx  installation and configuration ]

1. nginx source installation

cd /usr/local/src/

wget http://syslab.comsenz.com/downloads/linux/nginx-0.9.6.tar.gz

tar zxvf nginx-0.9.6.tar.gz

cd nginx-0.9.6

./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/usr/local/nginx/logs/error.log --http-log-path=/usr/local/nginx/logs/access.log --pid-path=/usr/local/nginx/var/nginx.pid --lock-path=/usr/local/nginx/var/nginx.lock --http-client-body-temp-path=/dev/shm/nginx_temp/client_body --http-proxy-temp-path=/dev/shm/nginx_temp/proxy --http-fastcgi-temp-path=/dev/shm/nginx_temp/fastcgi --user=www --group=www --with-cpu-opt=pentium4F --without-select_module --without-poll_module --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --without-http_ssi_module --without-http_userid_module --without-http_geo_module --without-http_memcached_module --without-http_map_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-pcre

make && make install

mkdir / dev / shm / nginx_temp

Pcre because the compiler is not the past, we need to modify some nginx version of the compiler when it --with-pcre = / usr / local / src / pcre-7.8, provided that the source package has been downloaded pcre pcre-7.8.tar.gz, and extract to /usr/local/src/pcre-7.8, not need to compile pcre

2.  write nginx startup script and add system services

vi /etc/init.d/nginx writes the following:

#!/bin/bash
# chkconfig: - 30 21
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings
NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/var/nginx.pid"
RETVAL=0
prog="Nginx"
start() {
        echo -n $"Starting $prog: "
        mkdir -p /dev/shm/nginx_temp
        daemon $NGINX_SBIN -c $NGINX_CONF
        RETVAL=$?
        echo
        return $RETVAL
}
stop() {
        echo -n $"Stopping $prog: "
        killproc -p $NGINX_PID $NGINX_SBIN -TERM
        rm -rf /dev/shm/nginx_temp
        RETVAL=$?
        echo
        return $RETVAL
}
reload(){
        echo -n $"Reloading $prog: "
        killproc -p $NGINX_PID $NGINX_SBIN -HUP
        RETVAL=$?
        echo
        return $RETVAL
}
restart(){
        stop
        start
}
configtest(){
    $NGINX_SBIN -c $NGINX_CONF -t
    return 0
}
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  reload)
        reload
        ;;
  restart)
        restart
        ;;
  configtest)
        configtest
        ;;
  *)
        echo $"Usage: $0 {start|stop|reload|restart|configtest}"
        RETVAL=1
esac

exit $RETVAL

After you save, change the permissions of /etc/init.d/nginx

chmod 755 /etc/init.d/nginx

chkconfig --add nginx

chkconfig nginx on

3. nginx configuration

vim /usr/local/nginx/conf/nginx.conf

Empty the original file, and then paste the following:

user www www;

worker_processes 2;

error_log /usr/local/nginx/logs/nginx_error.log crit;

pid /usr/local/nginx/var/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.

worker_rlimit_nofile 51200;

events

{

use epoll;

worker_connections 6000;

}

http

{

include mime.types;

default_type application/octet-stream;

server_names_hash_bucket_size 2048;

server_names_hash_max_size 4096;

log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local] '

'$host "$request_uri" $status '

'"$http_referer" "$http_user_agent"';

sendfile on;

tcp_nopush on;

keepalive_timeout 30;

client_header_timeout 3m;

client_body_timeout 3m;

send_timeout 3m;

connection_pool_size 256;

client_header_buffer_size 1k;

large_client_header_buffers 8 4k;

request_pool_size 4k;

output_buffers 4 32k;

postpone_output 1460;

client_max_body_size 10m;

client_body_buffer_size 256k;

client_body_temp_path /usr/local/nginx/client_body_temp;

proxy_temp_path /usr/local/nginx/proxy_temp;

fastcgi_temp_path /usr/local/nginx/fastcgi_temp;

fastcgi_intercept_errors on;

tcp_nodelay on;

gzip on;

gzip_min_length 1k;

gzip_buffers 4 8k;

gzip_comp_level 5;

gzip_http_version 1.1;

gzip_types text/plain application/x-javascript text/css text/htm application/xml;

server

{

listen 80;

server_name www.example.com;

index index.html index.htm index.php;

root /data/www;

location ~ \.php$ {

include fastcgi_params;

fastcgi_pass unix:/ php-fcgi.sock;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;

}

}

After the start nginx can save a good idea to check whether there is a problem before restarting the

/ usr / local / nginx / sbin / nginx -t if such information "syntax is ok and nginx.conf was tested successfully" display, you Description configuration is no problem, otherwise you need to modify the prompts.
service nginx start

If you can not start, please view the / usr / local / nginx / logs / directory nginx_ error.log log file. If there is no log file, chances are that the directory does not have write permissions for

chmod + w / usr / local / nginx / logs /
Service nginx restart

[ Test whether parse php files ]

 

vim /data/www/1.php

Write the following:

<?php
phpinfo();
?>

Then set the hosts file, visit www. ***. Com / 1.php see if you can parse out this page.

Guess you like

Origin www.cnblogs.com/pgh777/p/11692508.html