Centos lnmp 记录

Mysql
http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.56.tar.gz/from/http://ftp.jaist.ac.jp/pub/mysql/
http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.59.tar.gz/from/http://ftp.jaist.ac.jp/pub/mysql/
http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.62.tar.gz/from/http://ftp.jaist.ac.jp/pub/mysql/
http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.62.tar.gz/from/http://ftp.iij.ad.jp/pub/db/mysql/

PHP
http://cn.php.net/get/php-5.3.6.tar.gz/from/this/mirror
http://www.php.net/get/php-5.3.8.tar.gz/from/cn2.php.net/mirror
http://www.php.net/get/php-5.3.10.tar.gz/from/cn.php.net/mirror
http://www.php.net/get/php-5.3.10.tar.gz/from/cn2.php.net/mirror

Zend Guard
http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz

Nginx
http://nginx.org/download/nginx-0.8.54.tar.gz
http://nginx.org/download/nginx-1.0.14.tar.gz

PHPMyadmin
http://soft.vpser.net/datebase/phpmyadmin/phpmyadmin.tar.gz

Pure-ftpd
http://soft.vpser.net/ftp/pure-ftpd/pure-ftpd-1.0.29.tar.gz
http://soft.vpser.net/ftp/pure-ftpd/User_manager_for-PureFTPd_v2.1_CN.zip

http://soft.vpser.net/lnmp/lnmp0.7.tar.gz


yum -y remove httpd
yum -y remove php
yum -y remove mysql-server mysql
yum -y remove php-mysql
yum -y install yum-fastestmirror
yum -y remove httpd

yum -y remove httpd php mysql-server mysql php-mysql 

备注:
如查yum 失败,执行 yum clean all,修改DNS服务器

yum -y install gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg* libpng* gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel gmp-devel pspell-devel unzip libxslt libxslt-devel db4-devel mcrypt mcrypt-devel libmcrypt libmcrypt-devel mhash mhash-devel pcre pcre-devel libpcre libpcre-devel libc-client*;
# mysql
./configure --prefix=/usr/local/mysql --with-extra-charsets=all --enable-thread-safe-client --enable-assembler --with-charset=utf8 --enable-thread-safe-client --with-extra-charsets=all --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=innobase
useradd -s /sbin/nologin mysql
cp support-files/my-medium.cnf /etc/my.cnf
#mkdir -p /var/lib/mysql/
chown mysql.mysql -R /usr/local/mysql
#chown mysql.mysql -R /var/lib/mysql/
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
chmod 700 /etc/init.d/mysql
/usr/local/mysql/bin/mysql_install_db --user=mysql
#ln -s /usr/local/mysql/bin/* /usr/local/bin
重要:
#ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
#ln -s /usr/local/mysql/include/mysql /usr/include/mysql
ln -s /usr/local/mysql/include/mysql/mysql.h /usr/lib
让其它程序能找到mysql库
ln -s /usr/local/mysql/lib/mysql/* /usr/lib
将mysql命令作为系统命令
#ls -s /usr/local/mysql/bin/* /usr/bin
ln -s /usr/local/mysql/bin/mysql /usr/bin/
ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/
ln -s /usr/local/mysql/bin/mysqldump /usr/bin/

#ln -s /usr/local/mysql/bin/mysqld_safe /usr/bin/
#ln -s /usr/local/mysql/bin/mysql_conf /usr/bin/
#ln -s /usr/local/mysql/share/mysql/mysql.server /usr/bin/
64位系统还要执行
ln -s /usr/local/mysql/include/mysql/mysql.h /usr/lib64
ln -s /usr/local/mysql/lib/mysql/* /usr/lib64

作为系统开机服务启动
chkconfig --level 345 mysql on

/etc/init.d/mysql start
/usr/local/mysql/bin/mysqladmin -u root password 123456

系统找不到mysql.sock
如mysql.sock在 /var/lib/mysql/mysql.sock
ln -s /var/lib/mysql/mysql.sock  /tmp/mysql.sock
如mysql.sock在 /tmp/mysql.sock
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock

参数配置:
mkdir -p /usr/local/mysql/pid
vim /etc/my.cnf
[mysqld]
port            = 3306
socket          = /tmp/mysql.sock
pid-file        = /usr/local/mysql/pid/mysql.pid
log             = /usr/local/mysql/pid/mysql.err
datadir         = /usr/local/mysql/var
skip-locking
#key_buffer_size = 16M
#max_allowed_packet = 1M
table_open_cache = 64
#sort_buffer_size = 512K
#net_buffer_length = 8K
#read_buffer_size = 256K
#read_rnd_buffer_size = 512K
#myisam_sort_buffer_size = 8M
key_buffer_size = 128M
max_allowed_packet = 10M
sort_buffer_size = 6M
net_buffer_length = 10M
read_buffer_size = 5M
read_rnd_buffer_size = 10M
myisam_sort_buffer_size = 768M
wait_timeout = 100
interactive_timeout = 100

innodb_file_per_table=1


# php-5.3.x
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-magic-quotes --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 --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --with-mime-magic --enable-suhosin --enable-zip --with-imap --with-imap-ssl --with-kerberos --enable-zend-multibyte

cp php.ini-production /usr/local/php/etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
useradd -s /sbin/nologin www
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 700 /etc/init.d/php-fpm
编辑/usr/local/php/etc/php-fpm.conf,去掉以下内容中前面的#注视符即可
[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
log_level = notice
[www]
listen = 127.0.0.1:9000
user = www
group = www
pm = dynamic
pm.max_children = 50   #此参数是pm=static才有效,永久线程数
pm.start_servers = 20   #此参数是pm=dynamic有效,启动时的线程数
pm.min_spare_servers = 5   #此参数是pm=dynamic有效,允许最小的线程数
pm.max_spare_servers = 50  #此参数是pm=dynamic有效,允许最大的线程数

# Zend Guard
tar -zxvf ZendGuard.tar.gz
mkdir /usr/local/zendguard
cd ZendGuardLoader-php-5.3-linux-glibc23-x86_64
cp php-5.3.x/ZendGuardLoader.so /usr/local/zendguard

vim /usr/local/php/etc/php.ini
复制下面内容到php.ini底部
[Zend Guard]
zend_extension=/usr/local/zendguard/ZendGuardLoader.so
zend_loader.enable = 1
zend_loader.disable_licensing = 0
zend_loader.obfuscation_level_support = 3
zend_loader.license_path=

测试:
/usr/local/php/bin/php -v
看到 with Zend Guard Loader 即正常

# nginx 字符替换 substitutions_filter
yum -y install subversion
svn checkout http://substitutions4nginx.googlecode.com/svn/trunk/ /root/software/substitutions4nginx-read-only

# nginx
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6 --add-module=/root/software/substitutions4nginx-read-only

make install

/************************************
./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 --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=/usr/local/src/pcre-8.12
*************************************/

mkdir /usr/local/nginx/conf/vhost
mkdir /usr/local/nginx/conf/proxy
mkdir /var/log/nginx

vim /usr/local/nginx/conf/nginx.conf
user www
在http里加上:
log_format logstring '$remote_addr - $remote_user [$time_local]  '
                '"$request" $status $bytes_sent '
                '"$http_referer" "$http_user_agent" "$gzip_ratio"';
在http 内的最后加上
include vhost/*.conf;
include proxy/*.conf;

#pureftpd
./configure --prefix=/usr/local/pureftpd CFLAGS=-O2 \
--with-mysql=/usr/local/mysql \
--with-quotas \
--with-cookie \
--with-virtualhosts \
--with-virtualroot \
--with-diraliases \
--with-sysquotas \
--with-ratios \
--with-altlog \
--with-paranoidmsg \
--with-shadow \
--with-welcomemsg  \
--with-throttling \
--with-uploadscript \
--with-language=simplified-chinese

cp configuration-file/pure-config.pl /usr/local/pureftpd/sbin/
chmod 700 /usr/local/pureftpd/sbin/pure-config.pl
cp configuration-file/pure-ftpd.conf /usr/local/pureftpd/
cp pureftpd-mysql.conf /usr/local/pureftpd/

vim /usr/local/pureftpd/pure-ftpd.conf
去掉前面注释,修改后面的路径
MySQLConfigFile                /usr/local/pureftpd/pureftpd-mysql.conf
AllowUserFXP yes   #仅运行用户进行FXP传输,设置yes,服务器之间对传。
NoAnonymous                 yes #关闭匿名链接
最后面加上
AllowOverwrite on
AllowStoreRestart on

vim /usr/local/pureftpd/pureftpd-mysql.conf
修改数据库连接帐号
修改成md5
MYSQLCrypt     md5

vim /etc/init.d/pureftpd
chmod 700 /etc/init.d/pureftpd
########################################
#!/bin/bash
#
# chkconfig: 2345 85 15
# description: Pure-FTPd is an FTP server daemon based upon Troll-FTPd
# processname: pure-ftpd
### BEGIN INIT INFO
# Provides:          pureftpd
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts pureftpd server
# Description:       starts pureftpd server
### END INIT INFO
# Author:   licess
# website:  http://lnmp.org
# Pure-FTPd Settings
PURE_PERL="/usr/local/pureftpd/sbin/pure-config.pl"
PURE_CONF="/usr/local/pureftpd/pure-ftpd.conf"
PURE_PID="/var/run/pure-ftpd.pid"
RETVAL=0
prog="Pure-FTPd"
start() {
        echo -n $"Starting $prog: "
        $PURE_PERL $PURE_CONF --daemonize
        RETVAL=$?
        echo
        return $RETVAL
}
stop() {
        echo -n $"Stopping $prog: "
        if [ -e $PURE_PID ]; then
                kill `cat $PURE_PID`
        else
                echo -n $"$prog is not running."
        fi
        RETVAL=$?
        echo
        return $RETVAL
}
restart(){
        echo -n $"Restarting $prog: "
        stop
        start
}
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        restart
        ;;
  *)
        echo $"Usage: pureftpd {start|stop|restart}"
        RETVAL=1
esac
exit $RETVA
########################################

执行:
chmod 700 /etc/init.d/pureftpd

pureftpd 的 PHP 管理端要开启 short_open_tag = on

wget -c http://soft.vpser.net/ftp/pure-ftpd/pure-ftpd-1.0.29.tar.gz
wget -c http://soft.vpser.net/ftp/pure-ftpd/User_manager_for-PureFTPd_v2.1_CN.zip

#开机启动
vim /etc/rc.local
/usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php.ini &
/etc/init.d/mysql start
/usr/local/nginx/sbin/nginx
#/root/pureftpd start
/etc/init.d/pureftpd start
#/etc/init.d/vsftpd start

vim /usr/local/php/etc/php.ini
expose_php = Off

nginx无法运行php-cgi的问题
fastcgi.conf或fastcgi_params里加一句:
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

PHP $_SERVER["SERVER_NAME"] 只获得nginx的第一个域名解决方法:
在 fastcgi_params最后加一句:
fastcgi_param  SERVER_NAME    $host;

   sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    gzip  on;
    gzip_min_length  1000;
#    gzip_buffers     4 8k;
    gzip_buffers 16 64k;
    gzip_http_version 1.1;
    gzip_comp_level 6;
    gzip_types       text/plain text/htm text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    gzip_vary on;
server_tokens off;
fastcgi_connect_timeout 1800;
fastcgi_send_timeout 1800;
fastcgi_read_timeout 1800;
fastcgi_buffer_size 5120k;#256
fastcgi_buffers 16 5120k;
fastcgi_busy_buffers_size 10240k;
fastcgi_temp_file_write_size 10240k;
fastcgi_intercept_errors on;

server  {
                listen       80;
                server_name domain.name;
                index index.html index.htm index.php default.html default.htm default.php;
                root  /var/www/path;

# location / {
# deny 192.168.1.1;
# allow 183.16.193.255;
# allow 183.16.61.43;
# allow 58.61.39.9;
# deny all;
# }
                location ~ .*\.(php|php5)?$ {
                        include fastcgi_params;
                        fastcgi_pass  127.0.0.1:9000;
                        fastcgi_index index.php;
                }
                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
                        expires      30d;
                }
                location ~ .*\.(js|css)?$ {
                        expires      12h;
                }
                access_log  /var/log/nginx/domain.access.log  logstring;
                error_log  /var/log/nginx/domain.error.log;
        }



PHP插件安装

ftp://ftp.kddlabs.co.jp/graphics/ImageMagick/ImageMagick-6.6.9-10.tar.gz
http://pecl.php.net/get/imagick-3.0.1.tgz

安装ImageMagick
./configure --prefix=/usr/local/imagemagick
make && make install

安装imagick
cd imagick-xxx目录
运行 /usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-imagick=/usr/local/imagemagick
make && make install

或者 yum -y install ImageMagick ImageMagick-devel
安装imagick
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config

编辑 /usr/local/php/etc/php.ini
添加 extension=imagick.so

安装 OpenCV 和 php-facedetect
http://sourceforge.net/projects/opencvlibrary/
http://www.xarg.org/project/php-facedetect/
https://github.com/infusion/PHP-Facedetect
先安装cmake,OpenCV要用到
yum install cmake

注:若不是centos 6.0,必须得下载 opencv-2.2.0版本,否则安装不上去
yum -y install gtk2 gtk2-devel
yum -y install gstreamer gstreamer-devel
yum -y install gstreamer-plugins-base gstreamer-plugins-base-devel
yum -y install gstreamer-plugins-good gstreamer-plugins-good-devel
yum -y install libtiff libtiff-devel

cd OpenCV-2.2.0/ 
mkdir opencv-build
cd opencv-build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..
make && make intall
http://rpm.pbone.net/index.php3/stat/4/idpl/16612327/dir/centos_6/com/gstreamer-plugins-base-devel-0.10.29-1.el6.i686.rpm.html
http://rpmfind.net/linux/rpm2html/search.php?query=opencv

安装PHP-Facedetect
cd infusion-PHP-Facedetect-75a1d8f
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
编辑 /usr/local/php/etc/php.ini
添加 extension=facedetect.so


substitutions4nginx参数:
例如:subs_filter 源字符 目标字符 [gior]
g(default):替换所有匹配的字符串。
i: 执行不区分大小写的匹配。
o: 只需将第一个。
r: 该模式是作为一个正则表达式处理,默认是固定的字符串。
实际使用:
subs_filter ‘<(no?script.*?)>(.*?)<(\/no?script.*?)>’ ” gi; //替换掉全部的<noscript></noscript>
subs_filter ‘<(s?cript.*?)>(?:\s|\S)*?<(\/s?cript.*?)>’ ” gi; //替换掉全部的<script>包换中间换行</script>
subs_filter ‘<(i?frame.*?)>(.*?)<(\/i?frame.*?)>’ ” gi; //替换<iframe></iframe>
使用范例:
location / {
    subs_filter_types text/html text/css text/xml; #替换的文件类型
    subs_filter st(\d*).example.com $1.example.com ir; #
    subs_filter a.example.com s.example.com;
}
实际测试中sub_filter比subs_filter的速度要快,但如果你开启了nginx的cache速度上可以得到改善的。
测试过程发现对gzip源的内容无法实现替换的问题
可以在server段内加入 proxy_set_header Accept-Encoding "";
如果是替换中文词组则需要将nginx的配置文件保存为utf-8格式!

猜你喜欢

转载自robyang.iteye.com/blog/1995555
今日推荐