In centos 5.3 install nginx0.7.67 + mysql5.1.49 + php5.2.14
Advertisements
System Version: CentOS release 5.3 (Final), installed before the server can determine the network connectivity, or wget, yum and so are unable to use the network command.
Edit / etc / resolv.conf
vim /etc/resolv.conf
In the end add the following content (* Office and fill out your DNS address), restart just fine.
nameserver ***.***.*.**
nameserver ***.***.*.**
For example, the DNS in Beijing as: 202.106.0.20 and 211.161.46.84
Following is a server installation to install all the software versions:
nginx-0.7.67: nginx latest stable version
mysql-5.1.49: MySQL 5.1 series of the latest version
php-5.2.14: PHP5.2 the latest version of the series
php-5.2.14-fpm-0.5.14: compile with FastCGI mode is used when installing the patch PHP5.2.14
libiconv-1.13: Install PHP 5.2.14 build the required support library
libmcrypt-2.5.8: build install PHP 5.2.14 needed to support library
mcrypt-2.6.8: build install PHP 5.2.14 needed to support library
memcache-2.2.5: a high-performance distributed memory cache server
mhash-0.9.9.9: install PHP 5.2.14 build the required support library
pcre-8.01: pcre libraries required to install Nginx
eaccelerator-0.9.6: eAccelerator to speed up PHP
PDO_MYSQL-1.0.2: mysql pdo support
ImageMagick: ImageMagick library
imagick-2.3.0: imagick library
Above are the official closing date 2010.7.30 latest stable version, can be used directly in ssh wget command from the official website at:
wget http://sysoev.ru/nginx/nginx-0.7.67.tar.gz
Download MYSQL:
Into http://www.mysql.com/downloads/mysql/5.1.html page in "Select Platform" select "Source Code", select the list to download the last mysql-5.1.49.tar.gz:
wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.49.tar.gz/from/http://ftp.iij.ad.jp/pub/db/mysql/
wget http://php-fpm.org/downloads/php-5.2.14-fpm-0.5.14.diff.gz
wget http://cn2.php.net/get/php-5.2.14.tar.gz/from/cn.php.net/mirror
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.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://pecl.php.net/get/memcache-2.2.5.tgz
wget " http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0 "
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.01.tar.gz
wget http://bart.eaccelerator.net/source/0.9.6/eaccelerator-0.9.6.tar.bz2
wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
wget http://www.plhwin.com/download/webserver/ImageMagick.tar.gz
wget http://pecl.php.net/get/imagick-2.3.0.tgz
All of the above software I used wget to "/ usr / local / src" directory, to prepare for later installation.
The following are the various directory location I used:
Site directory at: / workspace / wwwroot
Server software installation directory at: / usr / local / webserver
The original installation of the software at: / usr / local / src
Before starting the installation, we strongly recommend replacing the system of open source software out centos mirror source is open source software mirror sites Netease, this time using the yum command to install the software with the maximum download speed.
Replacement process:
cd /etc/yum.repos.d/ mv CentOS-Base.repo CentOS-Base.repo.bak vim CentOS-Base.repo
Fill in the vim editor and save the following:
# CentOS-Base.repo
#
# This file uses a new mirrorlist system developed by Lance Davis for CentOS.
# The mirror system uses the connecting IP address of the client and the
# Update status of each mirror to pick mirrors that are updated to and
# Geographically close to the client. You should use this for CentOS updates
# Unless you are manually picking other mirrors.
#
# If the mirrorlist = does not work for you, as a fall back you can try the
# Remarked out baseurl = line instead.
#
#
[Base]
name = CentOS-$ releasever - Base
# Mirrorlist = http://mirrorlist.centos.org/?release = $ releasever & arch = $ basearch & repo = os
# Baseurl = http://mirror.centos.org/centos/ $ releasever / os / $ basearch /
baseurl = http://mirrors.163.com/centos/ $ releasever / os / $ basearch /
gpgcheck = 1
gpgkey = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
# Released updates
[Updates]
name = CentOS-$ releasever - Updates
# Mirrorlist = http://mirrorlist.centos.org/?release = $ releasever & arch = $ basearch & repo = updates
# Baseurl = http://mirror.centos.org/centos/ $ releasever / updates / $ basearch /
baseurl = http://mirrors.163.com/centos/ $ releasever / updates / $ basearch /
gpgcheck = 1
gpgkey = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
# Packages used / produced in the build but not released
[Addons]
name = CentOS-$ releasever - Addons
# Mirrorlist = http://mirrorlist.centos.org/?release = $ releasever & arch = $ basearch & repo = addons
# Baseurl = http://mirror.centos.org/centos/ $ releasever / addons / $ basearch /
baseurl = http://mirrors.163.com/centos/ $ releasever / addons / $ basearch /
gpgcheck = 1
gpgkey = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
# Additional packages that may be useful
[Extras]
name = CentOS-$ releasever - Extras
# Mirrorlist = http://mirrorlist.centos.org/?release = $ releasever & arch = $ basearch & repo = extras
# Baseurl = http://mirror.centos.org/centos/ $ releasever / extras / $ basearch /
baseurl = http://mirrors.163.com/centos/ $ releasever / extras / $ basearch /
gpgcheck = 1
gpgkey = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
# Additional packages that extend functionality of existing packages
[Centosplus]
name = CentOS-$ releasever - Plus
# Mirrorlist = http://mirrorlist.centos.org/?release = $ releasever & arch = $ basearch & repo = centosplus
# Baseurl = http://mirror.centos.org/centos/ $ releasever / centosplus / $ basearch /
baseurl = http://mirrors.163.com/centos/ $ releasever / centosplus / $ basearch /
gpgcheck = 1
enabled = 0
gpgkey = http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
Preparation before starting the installation
1, all the server environment is installed in / usr / local / webserver directory:
mkdir -p /usr/local/webserver
2, create a web root directory
mkdir -p /workspace/wwwroot
3, CentOS Linux system using yum command that comes with the installation, upgrade the required libraries (RedHat and other Linux distributions can be found from the installation CD in the library of the RPM package to install)
yum-y install gcc gcc-c + + autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
yum-y install gettext
fastcgi installation of PHP will be used, if there is no need to implement package yum command to install
yum-y install patch
Install nginx will use pcre library, if there is no need to implement package yum command to install
yum-y install pcre-devel
2, then began to compile install MYSQL
tar-zxvf mysql-5.1.49.tar.gz
cd mysql-5.1.49
groupadd mysql
useradd-g mysql mysql
. / Configure-prefix = / usr / local / webserver / mysql-with-comment = Source-with-server-suffix =- enterprise-gpl-with-mysqld-user = mysql-without-debug-with-socket-path = / tmp / mysql.sock-with-big-tables-with-charset = utf8-with-collation = utf8_general_ci-with-extra-charsets = all-with-pthread-enable-static-enable-thread-safe-client-with -client-ldflags =- all-static-with-mysqld-ldfags =- all-static-enable-assembler-without-ndb-debug-enable-local-infile-with-readline-with-raid-with-low-memory
make
make install
The entire installation process, MYSQL is the slowest part, so they need a little patience, if you are in the implementation of "make install" time, has been stuck in the "make [4]: Entering directory` / usr / local / src / mysql -5.1.49/mysql-test '", it is because you are too impatient, and so on compiled, and Oh, the card in the time-consuming process of about 20 minutes. Take advantage of this process go a cup of tea.
Compile the installation is complete, start the configuration MYSQL, concrete steps are not explained on the first, can be found online, just need to follow what these steps:
cd /usr/local/webserver/mysql cp /usr/local/webserver/mysql/share/mysql/my-medium.cnf /etc/my.cnf /usr/local/webserver/mysql/bin/mysql_install_db --user=mysql chown -R root /usr/local/webserver/mysql/ chown -R root /usr/local/webserver/mysql/var/ chown -R root /usr/local/webserver/mysql/var/mysql chown -R mysql /usr/local/webserver/mysql/ chown -R mysql /usr/local/webserver/mysql/var/ chown -R mysql /usr/local/webserver/mysql/var/mysql
Increase the MYSQL service at startup:
cp /usr/local/webserver/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysqld chmod 700 /etc/init.d/mysqld chkconfig --add mysqld chkconfig --level 3 mysqld on
Start MYSQL service
service mysqld start
Setting MYSQL password to "111111" (6 1)
/usr/local/webserver/mysql/bin/mysqladmin -u root password 111111
cp /usr/local/webserver/mysql/bin/mysql /sbin/mysql cp /usr/local/webserver/mysql/bin/mysqldump /sbin/mysqldump
Test MYSQL is installed correctly:
Into MYSQL: mysql-uroot-p
See all Database: show databases;
Select a database: use mysql;
Show all under the selected database table name: show tables;
Exit MYSQL: \ q
Third, build the support needed to install PHP 5.2.14 library
tar zxvf libiconv-1.13.tar.gz cd libiconv-1.13/ ./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 tar zxvf mcrypt-2.6.8.tar.gz cd mcrypt-2.6.8/ /sbin/ldconfig ./configure make make install cd ../
Fourth, in order to compile the installation of PHP 5.2.14 FastCGI mode
tar zxvf php-5.2.14.tar.gz
gzip-cd php-5.2.14-fpm-0.5.14.diff.gz | patch-d php-5.2.14-p1
cd php-5.2.14 /
. / Configure-prefix = / usr / local / webserver / php-with-config-file-path = / usr / local / webserver / php / etc-with-mysql = / usr / local / webserver / mysql-with-mysqli = / usr / local / webserver / 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-discard-path-enable-safe-mode-enable-bcmath-enable-shmop-enable-sysvsem-enable-inline-optimization-with-curl-with- curlwrappers-enable-mbregex-enable-fastcgi-enable-fpm-enable-force-cgi-redirect-enable-mbstring-with-mcrypt-with-gd-enable-gd-native-ttf-with-openssl-with-mhash - enable-pcntl-enable-sockets-with-xmlrpc-enable-zip-enable-soap-without-pear
make ZEND_EXTRA_LIBS = '-liconv'
make install
cp php.ini-dist / usr / local / webserver / php / etc / php.ini
cd .. /
5, compile install PHP5 Extension Module
tar zxvf memcache-2.2.5.tgz cd memcache-2.2.5/ /usr/local/webserver/php/bin/phpize ./configure --with-php-config=/usr/local/webserver/php/bin/php-config make make install cd ../ tar jxvf eaccelerator-0.9.6.tar.bz2 cd eaccelerator-0.9.6/ /usr/local/webserver/php/bin/phpize ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/webserver/php/bin/php-config make make install cd ../ tar zxvf PDO_MYSQL-1.0.2.tgz cd PDO_MYSQL-1.0.2/ /usr/local/webserver/php/bin/phpize ./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-pdo-mysql=/usr/local/webserver/mysql make make install cd ../ tar zxvf ImageMagick.tar.gz cd ImageMagick-6.5.1-2/ ./configure make make install cd ../ tar zxvf imagick-2.3.0.tgz cd imagick-2.3.0/ /usr/local/webserver/php/bin/phpize ./configure --with-php-config=/usr/local/webserver/php/bin/php-config make make install cd ../
6, modify the php.ini file
1, hand-modified: Search / usr / local / webserver / php / etc / php.ini the extension_dir = ". /"
vim / usr / local / webserver / php / etc / php.ini
Amended to read extension_dir = "/ usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613 /"
And after this line add the following lines, then save:
extension = "memcache.so"
extension = "pdo_mysql.so"
extension = "imagick.so"
Then find output_buffering = Off
Revised to output_buffering = On
Look again; cgi.fix_pathinfo = 0
Revised cgi.fix_pathinfo = 0, to prevent the file type error parsing vulnerability Nginx.
2, automatic modification: if too troublesome manual changes, perform the following shell command, automatically changes to the php.ini file:
sed-i 's # extension_dir = "./"# extension_dir = "/ usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613 /" \ nextension = "memcache.so" \ nextension = "pdo_mysql.so" \ nextension = "imagick.so" \ n # '/ usr / local / webserver / php / etc / php.ini
sed-i 's # output_buffering = Off # output_buffering = On #' / usr / local / webserver / php / etc / php.ini
sed-i "s #; always_populate_raw_post_data = On # always_populate_raw_post_data = On # g" / usr / local / webserver / php / etc / php.ini
sed-i "s #; cgi.fix_pathinfo = 0 # cgi.fix_pathinfo = 0 # g" / usr / local / webserver / php / etc / php.ini
7, configure eAccelerator accelerated PHP
Create eaccelerator cache directory, and edit php.ini
mkdir -p /usr/local/webserver/eaccelerator_cache vim /usr/local/webserver/php/etc/php.ini
Press shift + g keys jump profile at the very end, add the following configuration information:
[Eaccelerator]
zend_extension = "/ usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size = "64"
eaccelerator.cache_dir = "/ usr / local / webserver / eaccelerator_cache"
eaccelerator.enable = "1"
eaccelerator.optimizer = "1"
eaccelerator.check_mtime = "1"
eaccelerator.debug = "0"
eaccelerator.filter = ""
eaccelerator.shm_max = "0"
eaccelerator.shm_ttl = "3600"
eaccelerator.shm_prune_period = "3600"
eaccelerator.shm_only = "0"
eaccelerator.compress = "1"
eaccelerator.compress_level = "9"
8, create a www user and group, and the use of the directory for the virtual host:
/usr/sbin/groupadd www /usr/sbin/useradd -g www www
Assuming you already have a domain name www.test.com have to point the server IP. You need to add the virtual host site: (If you currently no available domain name, you want to use the IP direct access to, then no need for the following operation. NGINX to be installed after the configuration file can be in nginx.conf)
mkdir -p /workspace/wwwroot/test.com chmod +w /workspace/wwwroot/test.com chown -R www:www /workspace/wwwroot/test.com
Later to add a new virtual host, then repeat the steps above you can run.
9, create php-fpm configuration file (php-fpm is a fight for the PHP FastCGI patch management, you can change the php.ini configuration without the need for a smooth restart php-cgi)
In / usr / local / webserver / php / etc / directory to create php-fpm.conf file:
rm -f /usr/local/webserver/php/etc/php-fpm.conf vim /usr/local/webserver/php/etc/php-fpm.conf
Enter the following (if you install Nginx + PHP for debugging, set the following 0 to 1, to show PHP error messages, otherwise, Nginx will report a blank state of 500 error page):
All relative paths in this config are relative to php's install prefix
Pid file
/ Usr / local / webserver / php / logs / php-fpm.pid
Error log file
/ Usr / local / webserver / php / logs / php-fpm.log
Log level
error
When this amount of php processes exited with SIGSEGV or SIGBUS ...
10
... In a less than this interval of time, a graceful restart will be initiated.
Useful to work around accidental curruptions in accelerator's shared memory.
1m
Time limit on waiting child's reaction on signals from master
5s
Set to 'no' to debug fpm
yes
Name of pool. Used in logs and stats.
default
Address to accept fastcgi requests on.
Valid syntax is 'ip.ad.re.ss: port' or just 'port' or '/ path / to / unix / socket'
/ Tmp / php-cgi.sock
Set listen (2) backlog
-1
Set permissions for unix socket, if one used.
In Linux read / write permissions must be set in order to allow connections from web server.
Many BSD-derrived systems allow connections regardless of permissions.
0666
Additional php.ini defines, specific to this pool of workers.
/ Usr / sbin / sendmail-t-i
0
Unix user of processes
www
Unix group of processes
www
Process manager settings
Sets style of controling worker process count.
Valid values are 'static' and 'apache-like'
static
Sets the limit on the number of simultaneous requests that will be served.
Equivalent to Apache MaxClients directive.
Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi
Used with any pm_style.
128
Settings group for 'apache-like' pm style
Sets the number of server processes created on startup.
Used only when 'apache-like' pm_style is selected
20
Sets the desired minimum number of idle server processes.
Used only when 'apache-like' pm_style is selected
5
Sets the desired maximum number of idle server processes.
Used only when 'apache-like' pm_style is selected
35
The timeout (in seconds) for serving a single request after which the worker process will be terminated
Should be used when 'max_execution_time' ini option does not stop script execution for some reason
'0 S 'means' off'
0s
The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file
'0 S 'means' off'
0s
The log file for slow requests
logs / slow.log
Set open file desc rlimit
65535
Set max core size rlimit
0
Chroot to this directory at the start, absolute path
Chdir to this directory at the start, absolute path
Redirect workers' stdout and stderr into main error log.
If not set, they will be redirected to / dev / null, according to FastCGI specs
yes
How much requests each process should execute before respawn.
Useful to work around memory leaks in 3rd party libraries.
For endless request processing please specify 0
Equivalent to PHP_FCGI_MAX_REQUESTS
102400
Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect.
Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2 +)
Makes sense only with AF_INET listening socket.
127.0.0.1
Pass environment variables like LD_LIBRARY_PATH
All $ VARIABLEs are taken from current environment
$ HOSTNAME
/ Usr / local / bin: / usr / bin: / bin
/ Tmp
/ Tmp
/ Tmp
$ OSTYPE
$ MACHTYPE
2
Php-cgi started the process of monitoring the 9000 127.0.0.1 port, the process number of 128 (if the server memory is less than 3GB, you can only open 64 process), user www:
ulimit -SHn 65535 /usr/local/webserver/php/sbin/php-fpm start
Note: / usr / local / webserver / php / sbin / php-fpm there are other parameters, including: start | stop | quit | restart | reload | logrotate, modify the php.ini does not restart after the php-cgi, re-load the configuration file using the reload.
10, install nginx-0.7.67
tar zxvf nginx-0.7.67.tar.gz
cd nginx-0.7.67 /
. / Configure-user = www-group = www-prefix = / usr / local / webserver / nginx-with-http_stub_status_module-with-http_ssl_module
make & & make install
cd .. /
Create log directory Nginx
mkdir -p /logs/nginx chmod +w /logs/nginx chown -R www:www /logs/nginx
Create Nginx configuration file:
①, in the / usr / local / webserver / nginx / conf / directory to create nginx.conf file:
rm -f /usr/local/webserver/nginx/conf/nginx.conf vim /usr/local/webserver/nginx/conf/nginx.conf
Enter the following:
user www www;
worker_processes 8;
error_log / logs / nginx / nginx_error.log crit;
pid / usr / local / webserver / nginx / nginx.pid;
# Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;
events
(
use epoll;
worker_connections 65535;
)
http
(
include mime.types;
default_type application / octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
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_http_version 1.0;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text / plain application / x-javascript text / css application / xml;
gzip_vary on;
server_name_in_redirect off;
# Limit_zone crawler $ binary_remote_addr 10m;
server
(
listen 80;
server_name www.test.com test.com;
index index.html index.htm index.php;
root / workspace / wwwroot / test.com;
# Limit_conn crawler 20;
location ~ .* \. (php | php5)? $
(
fastcgi_pass unix: / tmp / php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
)
location ~ .* \. (gif | jpg | jpeg | png | bmp | swf) $
(
expires 30d;
)
location ~ .* \. (js | css)? $
(
expires 1h;
)
access_log off;
)
server
(
listen 80;
server_name status.test.com;
location / (
stub_status on;
access_log off;
)
)
)
②, in the / usr / local / webserver / nginx / conf / directory to create fcgi.conf file:
vim /usr/local/webserver/nginx/conf/fcgi.conf
Enter the following:
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $ query_string;
fastcgi_param REQUEST_METHOD $ request_method;
fastcgi_param CONTENT_TYPE $ content_type;
fastcgi_param CONTENT_LENGTH $ content_length;
fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
fastcgi_param SCRIPT_NAME $ fastcgi_script_name;
fastcgi_param REQUEST_URI $ request_uri;
fastcgi_param DOCUMENT_URI $ document_uri;
fastcgi_param DOCUMENT_ROOT $ document_root;
fastcgi_param SERVER_PROTOCOL $ server_protocol;
fastcgi_param REMOTE_ADDR $ remote_addr;
fastcgi_param REMOTE_PORT $ remote_port;
fastcgi_param SERVER_ADDR $ server_addr;
fastcgi_param SERVER_PORT $ server_port;
# Fastcgi_param SERVER_NAME $ server_name;
fastcgi_param SERVER_NAME $ host;
# PHP only, required if PHP was built with-enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
Start Nginx:
ulimit -SHn 65535 /usr/local/webserver/nginx/sbin/nginx
Configuration at startup Nginx + PHP
vim /etc/rc.local
Increase at the end the following:
ulimit-SHn 65535
/ Usr / local / webserver / php / sbin / php-fpm start
/ Usr / local / webserver / nginx / sbin / nginx
Optimized Linux kernel parameters:
vim /etc/sysctl.conf
Increase at the end the following:
net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog = 32768
net.core.somaxconn = 32768
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_tw_recycle = 1
# Net.ipv4.tcp_tw_len = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800
# Net.ipv4.tcp_fin_timeout = 30
# Net.ipv4.tcp_keepalive_time = 120
net.ipv4.ip_local_port_range = 1024 65535
The configuration take effect immediately:
/sbin/sysctl -p
In the non-stop service where Nginx Nginx configuration smooth change
1, modify the / usr / local / webserver / nginx / conf / nginx.conf configuration file, run the following command to check the configuration file is correct:
/usr/local/webserver/nginx/sbin/nginx -t
If the screen displays the following two lines of information on the correct configuration file:
the configuration file / usr / local / webserver / nginx / conf / nginx.conf syntax is ok
the configuration file / usr / local / webserver / nginx / conf / nginx.conf was tested successfully
2, create restart.sh:
vim /usr/local/webserver/nginx/restart.sh
Enter the following content and save:
/ Usr / local / webserver / php / sbin / php-fpm reload
kill-HUP `cat / usr / local / webserver / nginx / nginx.pid`
Change permissions:
chmod 777 /usr/local/webserver/nginx/restart.sh
Later revised nginx.conf, php-fpm.conf, fcgi.conf 3 files in the configuration parameters, only need to run the following shell command to restart the nginx and PHP services:
/usr/local/webserver/nginx/restart.sh
If you want to stop NGINX service, run:
kill -TERM `cat /usr/local/webserver/nginx/nginx.pid`
Preparation time per day cut the log scripts Nginx
1, create a script / usr / local / webserver / nginx / sbin / cut_nginx_log.sh
vim /usr/local/webserver/nginx/sbin/cut_nginx_log.sh
Enter the following:
#! / Bin / bash
# This script run at 00:00
# The Nginx logs path
logs_path = "/ usr / local / webserver / nginx / logs /"
mkdir-p $ (logs_path) $ (date-d "yesterday" + "% Y ")/$( date-d" yesterday "+"% m ") /
mv $ (logs_path) access.log $ (logs_path) $ (date-d "yesterday" + "% Y ")/$( date-d" yesterday "+"% m ") / access_ $ (date-d" yesterday "+"% Y% m% d "). log
kill-USR1 `cat / usr / local / webserver / nginx / nginx.pid`
2, set the crontab, 00:00 am every day access log cutting nginx:
crontab -e
Enter the following and save:
00 00 * * * / bin / bash / usr / local / webserver / nginx / sbin / cut_nginx_log.sh
Note: If you can not run the crontab command, may be due to many vps is not / bin / vi, leading to implementation of the crontab tips / bin / vi error. Workaround is to install the vim and set as the default editor, as follows:
1. Install vim
yum install vim-enhanced
2. Modify / etc / profile file to include
export EDITOR = / usr / bin / vim
3. To / etc / profile file changes take effect immediately, you can use the following command:
. /etc/profile
Note:. And / etc / profile spaces
4. Run crontab-e, there editing interface and success.
This point, basically have been installed throughout the environment is good, no accidents, you can already paid a successful visit to the host before you create the virtual directory "www.test.com", but all have accidents, and if done this everything, you find that your server environment or can not resolve, please take a close look, I would run into this problem. Our step by step to troubleshoot:
The following command to see port:
netstat -ntal
If the 80-port has been at work, probably because of firewall rules blocking the reason:
1, stop the firewall:
service iptables stop
2, stopped to see whether after open website, If so, then determine the reasons for the firewall, we need to re-configure the firewall rules:
vim /etc/sysconfig/iptables
3, add the following and save:
-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
4, open the firewall
service iptables start
If you find access to the secondary directory server when NGINX can not resolve, such as access to "http://www.test.com/test", the server can not resolve to the test directory, and access "http://www.test. com / test / "then everything is normal: just add the following line in nginx.conf can:
server_name_in_redirect off;
Thus, the great merit of basic rolled together. But I configured the server memory for the 3G, CPU is a dual-core, so each performance parameter index configuration are in accordance with this hardware standard to set, in the actual production environment, Yi Shang NGINX and PHP configuration in the hardware for items under good, but most probably a few hundred M memory VPS hosting, or install and configure their own virtual machine environment, so all the configuration parameters need to keep tuning. Next I will talk about what are the NGINX configuration will affect the operation, how the configuration was the most reasonable. Otherwise, it is easy to occur NGINX 504 errors or other mistakes. In fact, all this can not be counted as NGINX's fault, as long as reasonable allocation of the various parameters, such a situation is completely avoidable.
Related Posts of In centos 5.3 install nginx0.7.67 + mysql5.1.49 + php5.2.14
-
bdb: to improve the Berkeley DB for Ruby Bindings
Berkeley DB Are a high-performance database system, which in the 20th century, early 90's development, he is not a SQL database engine driver, but used to store key / value pairs of data. BDB very fast, can be at most of the operating system to u ...
-
fedora8 install ror
Fedora installation of Ruby on Rails Pre-action The following are the action is for the whole process has helped, but not necessarily the way to do. 1. Modify yum server, refer to the server internal I-Shou vi / etc / yum.repos.d / fedora.repo baseur ...
-
ror get openssl error problem under redhat
For a whole day yesterday Playing with Bahrain sqlite -driven, and built my first rails of the wrong time require_frameworks': no such file to load - openssl (RuntimeError I found a line at this mistake a lot of newspapers but rarely resolved, th ...
-
ubuntu lighttpd ruby rails2.2 PeanutHull discuz php fastc
wget http://www.oray.cn/peanuthull/download/phlinux10all.tar.gz
-
Deployment rails ubuntu server
sudo vi / etc / apt / source.list upgrade os install ruby
-
ubuntu install rails environment
Environment: ubuntu 8.04 Software: ruby 1.8.7-p72 gem 1.3.1 rails 2.1.2 The installation process to install ruby Download ruby-1.8.7-p72.tar.gz $ Tar xzvf ruby1.8.7 p72.gz.tar $ Cd ruby1.8.7 p72 $. / Config-prefix = / usr / local / ruby $ Make $ Sudomake
-
Manual configuration in UBUNTU under ruby on rails environment
Careless mistake for the day before yesterday, the sources, the results after 810 error after the upgrade, the loss of response button. On google found a lot of trouble really, lucky point modification under the / etc/X11/xorg.conf to restore both, b ...
-
In the Linux platform to install and configure Ruby on Rails Detailed
ruby on rails recommend the production environment is running Linux / FreeBSD / Unix, or Unix family of operating systems, using lighttpd + FCGI solution. The following will be my Linux operating system, lighttpd + FCGI, MySQL database as an example, comp












