1:数据库编译
依赖包
yum install -y gcc gcc-c++ make ncurses-devel bison openssl-devel zlib-devel
yum cmake(系统自带版本太低) cmake-2.8.12.2-4.el6.x86_64.rpm
解压源码包
tar zxf mysql-boost-5.7.17.tar.gz
cd mysql-5.7.17/
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ #安装目录
-DMYSQL_DATADIR=/usr/local/mysql/data \ #数据库存放目录
-DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock \ #Unix socket 文件路径
-DWITH_MYISAM_STORAGE_ENGINE=1 \ #安装 myisam 存储引擎
-DWITH_INNOBASE_STORAGE_ENGINE=1 \ #安装 innodb 存储引擎
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \ #安装 archive 存储引擎
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ #安装 blackhole 存储引擎
-DWITH_PARTITION_STORAGE_ENGINE=1 \ #安装数据库分区
-DENABLED_LOCAL_INFILE=1 \ #允许从本地导入数据
-DWITH_READLINE=1 \ #快捷键功能
-DWITH_SSL=yes \ #支持 SSL
-DDEFAULT_CHARSET=utf8 \ #使用 utf8 字符
-DDEFAULT_COLLATION=utf8_general_ci \ #校验字符
-DEXTRA_CHARSETS=all \ #安装所有扩展字符集
-DMYSQL_TCP_PORT=3306 \ #MySQL 监听端口
编译执行
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql \
-DMYSQL_DATADIR=/usr/local/lnmp/mysql/data \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all
在编译的过程中需要解决依赖性问题
gcc gcc-c++ ncurses-devel bison
指定-DWITH_BOOST=boost/boost_1_59_0
rm -f CMakeCache.txt #清楚缓存文件
重新编译时,需要清除旧的对象文件和缓存信息
rm -f CmakeCache.txt
groupadd -g 27 mysql
useradd -u 27 -g 27 -M -d /usr/local/lnmp/mysql/ -s /sbin/nologin mysql
cd /usr/local/lnmp/mysql/
chown mysql.mysql . -R
vim .bash_profile
10 PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin
source .bash_profile
vim /etc/my.cnf
[root@server1 mysql]# cat /etc/my.cnf
[mysqld]
datadir=/usr/local/lnmp/mysql/data
socket=/usr/local/lnmp/mysql/data/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
cd /usr/local/mysql/support-files/
vim my-default.cnf
cp my-default.cnf /etc/my.cnf
vim /etc/my.cnf
17 # These are commonly set, remove the # and set as required.
18 basedir =/usr/local/lnmp/mysql
19 datadir = /usr/local/lnmp/mysql/data
20 port = 3306
21 # server_id = .....
22 socket = /usr/local/lnmp/mysql/data/mysql.sock
cd mysql-5.7.11/support-files/
cp mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
mysqld --initialize --user=mysql #初始化,下面会有生成的用户密码
cd /usr/local/lnmp/mysql
chown root . -R
chown mysql data -R
mysql_secure_installation #修改密码,原始密码在初始化的时候系统会给
[root@server1 mysql]# ll
total 60
drwxr-xr-x 2 root mysql 4096 Jan 25 16:23 bin
-rw-r--r-- 1 root mysql 17987 Feb 2 2016 COPYING
drwxr-x--- 5 mysql mysql 4096 Jan 25 17:37 data #初始化产生
drwxr-xr-x 2 root mysql 4096 Jan 25 16:22 docs
drwxr-xr-x 3 root mysql 4096 Jan 25 16:22 include
drwxr-xr-x 4 root mysql 4096 Jan 25 16:23 lib
drwxr-xr-x 4 root mysql 4096 Jan 25 16:22 man
drwxr-xr-x 10 root mysql 4096 Jan 25 16:24 mysql-test
-rw-r--r-- 1 root mysql 2478 Feb 2 2016 README
drwxr-xr-x 28 root mysql 4096 Jan 25 16:24 share
drwxr-xr-x 2 root mysql 4096 Jan 25 16:24 support-files
2:php 安装
解压
tar jxf php-5.6.20.tar.bz2
编译
./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-mysql=mysqlnd --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-pear --with-gettext --with-gmp --enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mnstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash --with-gd
./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --enable-mysqlnd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-snmp --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-pear --with-gettext --with-gmp --enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash --with-gd
#安装需要的依赖性
yum install -y gcc
yum install -y libxml2-devel
yum install -y openssl-devel
yum install -y curl-devel
yum install -y gd-devel-2.0.35-11.el6.x86_64.rpm
yum install -y gmp-devel
yum install -y libmcrypt-devel-2.5.8-9.el6.x86_64.rpm libmcrypt-2.5.8-9.el6.x86_64.rpm
yum install -y net-snmp-devel
make && make install
cd /usr/local/lnmp/php/etc/
cp php-fpm.conf.default php-fpm.conf
cd php-5.6.20
cp php.ini-production /usr/local/lnmp/php/etc/php.ini
cd php-5.6.20/sapi/fpm/
cp init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
cd /usr/local/lnmp/php/etc/
vim php.ini
925 date.timezone = Asia/Shanghai
#将php和mysql联系起来
1001 pdo_mysql.default_socket=/usr/local/lnmp/mysql/data/mysql.sock
1150 mysql.default_socket = /usr/local/lnmp/mysql/data/mysql.sock
1209 mysqli.default_socket = /usr/local/lnmp/mysql/data/mysql.sock
vim php-fpm.conf
25 pid = run/php-fpm.pid
useradd -M -d /usr/local/lnmp/nginx -s /sbin/nologin nginx
/etc/init.d/php-fpm start
3:nginx 源码安装
http://blog.csdn.net/u010489158/article/details/81330039
tar zxf nginx-1.10.1.tar.gz
取消nginx的版本显示
(防止有人知道这个版本的漏洞而进行针对性攻击,因此不对外显示,比较安全)
/root/nginx-1.10.1/src/core
14 #define NGINX_VER "nginx/"
取消debug模式,装的包比较小
/root/nginx-1.10.1/auto/cc
178 # debug
179 #CFLAGS="$CFLAGS -g"
将这两行注释掉
安装它的依赖性
yum install -y pcre-devel openssl-devel zlib-devel
编译安装
./configure --prefix=/usr/local/lnmp/nginx --with-http_ssl_module --with-http_ssl_module --with-http_stub_status_module --user=nginx --group=threads --with-file-aio
make
make install
ln -s /usr/local/lnmp/nginx/sbin/nginx /usr/local/sbin/
useradd -u 800 -M -d /usr/local/lnmp/nginx/ nginx
vim index.php #编写php的发布页面
<?php
phpinfo()
?>
vim /usr/local/lnmp/nginx/conf/nginx.conf
27 sendfile on;
28 tcp_nopush on;
29 tcp_nodelay on;
30
31 #keepalive_timeout 0;
32 keepalive_timeout 65;
33
34 gzip on;
46 index index.php index.html index.htm;
66 location ~ \.php$ {
67 root html;
68 fastcgi_pass 127.0.0.1:9000;
69 fastcgi_index index.php;
70 # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
71 include fastcgi.conf;
nginx #启动
nginx -s reload #重新加载
nginx -s stop #关闭
nginx -t #检测配置文件
论坛搭建
unzip Discuz_X3.2_SC_UTF8.zip
mv upload/ /bbs
cat /usr/local/lnmp/nginx/conf/nginx.conf
server {
listen 80;
server_name bbs.westos.org;
location / {
root /bbs;
index index.php;
}
location ~ \.php$ {
root /bbs;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
}
chmod 777 config/ data/ uc_server uc_client/ -R
chmod 755 data/
/bbs/install
[root@server2 install]# rm -fr index.php #防止重复安装
memcache
php加memcache
server1
vim ~/.bash_profile
10 PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin:/usr/local/lnmp/php/bin
source ~/.bash_profile
tar zxf memcache-2.2.5.tgz
cd memcache-2.2.5
phpize #~/.bash_profile生成此命令
./configure --prefix=/usr/local/lnmp/php/memcache
make && make install
cd /usr/local/lnmp/php/lib/php/extensions/no-debug-non-zts-20131226/ls
vim /usr/local/lnmp/php/etc/php.ini
862 extension=memcache.so
/etc/init.d/php-fpm reload
cd memcache-2.2.5
cp memcache.php /usr/local/lnmp/nginx/html/
cp example.php /usr/local/lnmp/nginx/html/
vim example.php
3 $memcache = memcache_connect('172.25.200.3', 11211);
vim memcache.php
$VERSION='$Id: memcache.php,v 1.2 2008/09/11 19:21:06 mikl Exp $';
define('ADMIN_USERNAME','memcache'); // Admin Username
define('ADMIN_PASSWORD','westos'); // Admin Password
define('DATE_FORMAT','Y/m/d H:i:s');
define('GRAPH_SIZE',200);
define('MAX_ITEM_DUMP',50);
$MEMCACHE_SERVERS[] = '172.25.200.3:11211'; // add more as an array
#$MEMCACHE_SERVERS[] = 'mymemcache-server2:11211'; // add more as an array
/etc/init.d/php-fpm reload
nginx -s reload
server4
yum install -y memcached
yum install -y telnet
/etc/init.d/memcached start
nginx加memcache
tar zxf openresty-1.13.6.1.tar.gz
cd openresty-1.13.6.1
./configure
gmake
gmake install
nginx -s stop
vim /usr/local/openresty/nginx/conf/nginx.conf
2 user nginx;
65 location ~ \.php$ {
66 root html;
67 fastcgi_pass 127.0.0.1:9000;
68 fastcgi_index index.php;
69 # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_sc ript_name;
70 include fastcgi.conf;
71 }
cd /usr/local/openresty/nginx/sbin/
./nginx
压测ab -c 100 -n 5000 http://172.25.12.2/index.php
ab -c 100 -n 5000 http://172.25.12.2/example.php