RHCE,CCNA,熟悉shell脚本
分类: 系统运维
2014-10-11 11:51:34
LNMP-install
CENTOS_6.5_X86_64
/boot 128--200MB
/home 20G
/var 20G
swap 4G
/ 余下
[root@localhost ~]# yum -y install gcc gcc-c++ automake autoconf make 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 pcre pcre-devel libevent libevent-devel cmake cmake-gui bison
mysql-5.7.5-m15
http://dev.mysql.com/downloads/mysql/
[root@localhost mysql-5.7.5-m15]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mysql/data -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/root/mysql-5.7.5-m15/cmake/ && make && make install
[root@localhost ~]# useradd -g mysql mysql -s /usr/sbin/nologin
[root@localhost mysql]# cp /usr/local/mysql/support-files/my-default.cnf /usr/local/mysql/my.cnf
[root@localhost ~]# chown mysql. /usr/local/mysql/ -R
[root@localhost /]# chown mysql. /mysql/ -R
[root@localhost mysql]# vi /usr/local/mysql/my.cnf
[client]
socket=/mysql/data/mysql.sock
default-character-set=utf8
[mysqld]
basedir = /usr/local/mysql
databdir = /mysql/data
log-error=/mysql/data/log/mysqld.log
socket=/mysql/data/mysql.sock
[root@localhost data]# ln -sf /mysql/data/mysql.sock /tmp/mysql.sock
[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld
[root@localhost support-files]# cat /etc/profile
export PATH=/usr/local/mysql/bin:$PATH
[root@localhost support-files]# source /etc/profile
[root@localhost bin]# /usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/mysql/data/ --user=mysql
[root@localhost bin]# mv /etc/my.cnf /etc/my.cnf.bak
[root@localhost bin]# /etc/init.d/mysqld start
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure && make && make install
tar xf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure --prefix = /usr/local/libmcrypt && make && make install
cd libltdl/
./configure --enable-ltdl-install && make && make install
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure && make && make install
tar xf mcrypt-2.6.8.tar.gz
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
./configure && make && make install
[root@localhost php-5.6.1]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli --enable-embedded-mysqli --with-pdo-mysql=/usr/local/mysql --enable-embedded-mysqli --with-mysql-sock=/mysql/data/mysql.sock --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 --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-soap --enable-ftp --enable-opcache=no && make ZEND_EXTRA_LIBS='-liconv' && make install
[root@localhost php-5.6.1]# cp /root/soft/php-5.6.1/php.ini-production /usr/local/php/etc/php.ini
[root@localhost php-5.6.1]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@localhost php-5.6.1]# vi /usr/local/php/etc/php-fpm.conf
; Note: the default prefix is /usr/local/php/var
pid = run/php-fpm.pid
error_log = log/php-fpm.log
[root@localhost php-5.6.1]# /usr/local/php/sbin/php-fpm
4. 安装Php扩展插件
memcache-3.0.8.tgz
[root@localhost soft]# tar -zxvf memcache-3.0.8.tgz
[root@localhost soft]# cd memcache-3.0.8
[root@localhost soft]# /usr/local/php/bin/phpize ## 有这一步才会有 configure
[root@localhost soft]# ./configure --with-php-config=/usr/local/php/bin/php-config && make && make install
http://www.imagemagick.org/script/download.php
[root@localhost soft]# tar xf ImageMagick-6.8.9-8.tar.gz
[root@localhost soft]# cd ImageMagick-6.8.9-8
[root@localhost ImageMagick-6.8.9-8]# ./configure && make && make install
imagick-3.1.2
[root@localhost soft]# tar zxvf imagick-3.0.1.tgz
[root@localhost soft]# cd imagick-3.1.2/
[root@localhost soft]# /usr/local/php/bin/phpize
[root@localhost soft]# ./configure --with-php-config=/usr/local/php/bin/php-config && make && make install
phpredis-master.zip
[root@test ~]# unzip phpredis-master.zip
[root@test ~]# cd phpredis-master
[root@test ~]# /usr/local/php/bin/phpize
[root@test ~]# ./configure --enable-redis --with-php-config=/usr/local/php/bin/php-config && make && make install
== 如果使用 php 5.4 以上版本,就只能放弃使用 eaccelerator 加速了 =======
用xcache替代eaccelerator
XCache 3.2.0
[root@localhost xcache-3.2.0]# tar xf xcache-3.2.0
[root@localhost xcache-3.2.0]# cd xcache-3.2.0
[root@localhost xcache-3.2.0]# /usr/local/php/bin/phpize
[root@localhost xcache-3.2.0]# ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config && make && make install
配置 xcache,整合php与xcache
[root@test ~]# cd /root/soft/xcache-2.0.1
[root@test xcache-2.0.1]# cat xcache.ini >> /usr/local/php/etc/php.ini
[root@test ~]# vim /usr/local/php/etc/php.ini
找到 zend_extension | 或者 extension 开头的行,修改如下:
[xcache-common]
;##extension = xcache.so
extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/xcache.so
注意:
如果php.ini文件中有多条zend_extension指令行,要确保此新增的行排在第一位。配置完成后,重启php-fpm即生效。
配置php支持需要模块
[root@test ~]# vi /usr/local/php/etc/php.ini
在; extension_dir = ./ 下
添加以下几行
memcache模块
extension = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/memcache.so"
imagick模块
extension = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/imagick.so"
redis模块
extension = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/redis.so"
tar xf memcached-1.4.20.tar.gx
cd memcached-1.4.20
./configure --prefix=/usr/local/memcached && make && make install
[root@localhost bin]# /usr/local/memcached/bin/memcached -d -m 1000 -u root -l 192.168.0.111 -p 11211 -c 1024 -P /tmp/memcached.pid
pcre-8.34 ##nginx-rewrite
[root@localhost soft]# tar xf pcre-8.36.tar.gz
[root@localhost soft]# mv pcre-8.36 /usr/local/pcre
[root@localhost soft]#
nginx
nginx-1.6.2.tar.gz
[root@localhost nginx-1.6.2]# ./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/pcre/ --with-http_stub_status_module --with-http_ssl_module && make && make install
[root@localhost nginx-1.6.2]# vi /usr/local/nginx/conf/nginx.conf
worker_processes 8;
error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;
pid logs/nginx.pid;
location / {
root /usr/local/nginx/html;
index index.php index.html index.htm;
}
location /nginx-status {
stub_status on;
#access_lod off;
allow 127.0.0.1;
allow 192.168.32.0/24;
}
location ~ \.php$ { ###\.php 注意没有空格,不能有空格
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
[root@localhost nginx-1.4.6]# touch /usr/local/nginx/html/favicon.ico
[root@localhost conf]# /usr/local/nginx/sbin/nginx