1.安装Mysql
从第三方库下载mysql-boost-5.7.17.tar.gz,cmake-2.8.12.2-4.el6.x86_64.rpm -y
# 解压
[root@server5 ~]# tar zxf mysql-boost-5.7.17.tar.gz
# 安装cmake
[root@server5 ~]# yum install cmake-2.8.12.2-4.el6.x86_64.rpm -y
# 解决依赖性
[root@server5 mysql-5.7.17]# yum install gcc gcc-c++ -y
源码编译
[root@server5 mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/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
# 会有报错,按提示,删除缓存文件
[root@server5 mysql-5.7.17]# rm -f CMakeCache.txt
[root@server5 mysql-5.7.17]# yum install ncurses-devel -y
# 再次编译
[root@server5 mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/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 -DWITH_BOOST=boost/boost_1_59_0/
# 编译时间较长,编译完之后安装
[root@server5 mysql-5.7.17]# make
[root@server5 mysql-5.7.17]# make install
安装完成的页面
mysql配置
[root@server5 mysql-5.7.17]# cd /usr/local/lnmp/mysql/
[root@server5 mysql]# ls
[root@server5 mysql]# cd support-files/
[root@server5 support-files]# cp my-default.cnf /etc/my.cnf
# 指定路径
[root@server5 support-files]# vim /etc/my.cnf
basedir = /usr/local/lnmp/mysql
datadir = /usr/local/lnmp/mysql/data
port = 3306
# server_id = .....
socket = /usr/local/lnmp/mysql/data/mysql.sock
文件更改的内容
# 拷贝启动脚本
[root@server5 support-files]# cp mysql.server /etc/init.d/mysqld
[root@server5 support-files]# ll /etc/init.d/mysqld
[root@server5 support-files]# cd ..
# 建立用户和用户组
[root@server5 mysql]# groupadd -g 27 mysql
[root@server5 mysql]# useradd -u 27 -g 27 -M -d /usr/local/lnmp/mysql/data -s /sbin/nologin mysql
[root@server5 mysql]# id mysql
[root@server5 mysql]# cd bin/
[root@server5 bin]# ls
[root@server5 bin]# cd
# 设置环境变量
[root@server5 ~]# vim .bash_profile
PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin
[root@server5 ~]# source .bash_profile
[root@server5 ~]# cd /usr/local/lnmp/mysql/
[root@server5 mysql]# ll
# 更改文件用户所有人和所有组
[root@server5 mysql]# chown mysql.mysql . -R
# 以mysql用户身份进行初始化
[root@server5 mysql]# mysqld --initialize --user=mysql
# 再更改文件用户所有人和所有组
[root@server5 mysql]# chown root.root . -R
[root@server5 mysql]# chown mysql data/ -R
# 启动服务
[root@server5 mysql]# /etc/init.d/mysqld start
# 初始化安全设置
[root@server5 mysql]# mysql_secure_installation
2.安装php
从第三方库下载php-5.6.35.tar.bz2,解压
[root@server5 ~]# tar jxf php-5.6.35.tar.bz2
解决依赖性
libmcrypt-2.5.8-9.el6.x86_64.rpm
libmcrypt-devel-2.5.8-9.el6.x86_64.rpm
re2c-0.13.5-1.el6.x86_64.rpm
gd-devel-2.0.35-11.el6.x86_64.rpm需要从第三方库下载,其余的可以从系统直接安装
[root@server5 ~]# yum install libmcrypt-*
[root@server5 ~]# rpm -ivh re2c-0.13.5-1.el6.x86_64.rpm
[root@server5 ~]# yum install -y gd-devel-2.0.35-11.el6.x86_64.rpm
[root@server5 ~]# yum install -y net-snmp-devel
[root@server5 ~]# yum install -y gmp-devel
[root@server5 ~]# yum install -y curl-devel
[root@server5 ~]# yum install -y openssl-devel
[root@server5 ~]# yum install -y libxml2-devel
# 源码编译三部曲
[root@server5 ~]# cd php-5.6.35/
[root@server5 php-5.6.35]# ./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-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-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash
# 耐心等待编译完之后安装
[root@server5 php-5.6.35]# make && make install
安装完成
php配置
[root@server5 ~]# cd /usr/local/lnmp/php/
[root@server5 php]# cd etc/
[root@server5 etc]# cp php-fpm.conf.default php-fpm.conf
[root@server5 etc]# ls
pear.conf php-fpm.conf php-fpm.conf.default
[root@server5 etc]# cd ..
[root@server5 php]# cd /root/php-5.6.35
[root@server5 php-5.6.35]# cp php.ini-production /usr/local/lnmp/php/etc/php.ini
[root@server5 php-5.6.35]# cd /usr/local/lnmp/php/etc/
# 设置时区
[root@server5 etc]# vim php.ini
date.timezone = Asia/Shangdhai
[root@server5 etc]# vim php-fpm.conf
pid = run/php-fpm.pid
php.ini文件
php-fpm.conf文件
[root@server5 etc]# cd /root/php-5.6.35/sapi/fpm/
# 拷贝一个启动脚本
[root@server5 fpm]# cp init.d.php-fpm /etc/init.d/php-fpm
# 建立用户
[root@server5 fpm]# useradd -M -d /usr/local/lnmp/nginx -s /sbin/nologin nginx
# 启动服务
[root@server5 fpm]# /etc/init.d/php-fpm start
3.安装nginx
从第三方库下载nginx-sticky-module-ng.tar.gz和nginx-1.10.1.tar.gz,解压
[root@server5 ~]# tar zxf nginx-sticky-module-ng.tar.gz
[root@server5 ~]# tar zxf nginx-1.10.1.tar.gz
[root@server5 ~]# vim /root/nginx-1.10.1/auto/cc/gcc
# debug
#CFLAGS="$CFLAGS -g" #注释掉
[root@server5 ~]# vim /root/nginx-1.10.1/src/core/nginx.h
#define NGINX_VER "nginx/" #删除版本号
[root@server5 ~]# cd nginx-1.10.1
/root/nginx-1.10.1/auto/cc/gcc文件
/root/nginx-1.10.1/src/core/nginx.h文件
# 解决依赖性
[root@server5 nginx-1.10.1]# yum install pcre-devel -y
# 源码编译三部曲
[root@server5 nginx-1.10.1]# ./configure --prefix=/usr/local/lnmp/nginx --with-http_ssl_module --with-http_stub_status_module --user=nginx --group=nginx --with-threads --with-file-aio --add-module=/root/nginx-sticky-module-ng
# 安装
[root@server5 nginx-1.10.1]# make && make install
配置nignx
[root@server5 nginx-1.10.1]# cd /usr/local/lnmp/nginx/conf/
# 更改主配置文件
[root@server5 conf]# vim nginx.conf
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi.conf;
}
[root@server5 conf]# vim /etc/security/limits.conf
nginx - nofile 65535
[root@server5 conf]# cd
# 添加环境变量
[root@server5 ~]# vim .bash_profile
PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin:/usr/local/lnmp/nginx/sbin
[root@server5 ~]# source .bash_profile
/usr/local/lnmp/nginx/conf/nginx.conf文件
/etc/security/limits.conf文件
.bash_profile文件
# 访问主机ip地址时默认访问index.php
[root@server5 ~]# vim /usr/local/lnmp/nginx/conf/nginx.conf
index index.php index.html index.htm;
# 启动服务
[root@server5 sbin]# nginx -t
[root@server5 sbin]# nginx
# 编写默认发布文件
[root@server5 sbin]# vim /usr/local/lnmp/nginx/html/index.php
<?php
phpinfo()
?>
# 重新加载服务
[root@server5 sbin]# nginx -s reload
/usr/local/lnmp/nginx/conf/nginx.conf文件
/usr/local/lnmp/nginx/html/index.php文件
4.安装论坛
第三方下载Discuz_X3.2_SC_UTF8.zip,解压到/usr/local/lnmp/nginx/html/
[root@server5 ~]# yum install unzip -y
[root@server5 ~]# unzip Discuz_X3.2_SC_UTF8.zip -d /usr/local/lnmp/nginx/html/
[root@server5 ~]# cd /usr/local/lnmp/nginx/html/
# 重命名
[root@server5 html]# mv upload/ bbs
[root@server5 html]# ls
50x.html bbs index.html index.php readme utility
访问172.25.25.5/bbs
浏览器访问172.25.25.5/bbs
权限不够
# 更改权限
[root@server5 html]# cd bbs/
[root@server5 bbs]# chmod 777 config/ data/ uc_server/ uc_client/ -R
刷新网页
# 指定路径
[root@server5 bbs]# vim /usr/local/lnmp/php/etc/php.ini
pdo_mysql.default_socket=/usr/local/lnmp/mysql/data/mysql.sock
mysql.default_socket =/usr/local/lnmp/mysql/data/mysql.sock
mysqli.default_socket =/usr/local/lnmp/mysql/data/mysql.sock
# 重新加载
[root@server5 bbs]# /etc/init.d/php-fpm reload
Reload service php-fpm done
[root@server5 bbs]# cd /usr/local/lnmp/mysql/
刷新网页
# 更改权限
[root@server5 mysql]# chmod 755 data/
[root@server5 mysql]# ll
刷新网页
[root@server5 mysql]# cd /usr/local/lnmp/nginx/html/bbs/install/
[root@server5 install]# rm -f index.php
5.php+memcache
第三方下载memcache-2.2.5.tgz,解压
[root@server5 ~]# tar zxf memcache-2.2.5.tgz
[root@server5 ~]# cd /usr/local/lnmp/php/bin/
[root@server5 bin]# ls
# 添加环境变量
[root@server5 ~]# vim .bash_profile
[root@server5 ~]# source .bash_profile
[root@server5 ~]# cd memcache-2.2.5
[root@server5 memcache-2.2.5]# ls
[root@server5 memcache-2.2.5]# phpize
# 编译
[root@server5 memcache-2.2.5]# ./configure
添加环境变量
Make make install
[root@server5 no-debug-non-zts-20131226]# cd /usr/local/lnmp/php/
[root@server5 php]# cd etc/
[root@server5 etc]# vim php.ini
# 重新加载
[root@server5 etc]# /etc/init.d/php-fpm reload
Reload service php-fpm done
[root@server5 etc]# php -m | grep memcache
Memcache
php.ini文件
# 安装服务
[root@server5 etc]# yum install -y memcached
[root@server5 etc]# cd
[root@server5 ~]# cd memcache-2.2.5
[root@server5 memcache-2.2.5]# ls
[root@server5 memcache-2.2.5]# cp memcache.php example.php /usr/local/lnmp/nginx/html/
[root@server5 memcache-2.2.5]# php -m |grep memcache
Memcache
# 重新加载
[root@server5 memcache-2.2.5]# /etc/init.d/php-fpm reload
Reload service php-fpm done
# 启动服务
[root@server5 memcache-2.2.5]# /etc/init.d/memcached start
Starting memcached: [ OK ]
[root@server5 memcache-2.2.5]# cd /usr/local/lnmp/nginx/html/
[root@server5 html]# vim memcache.php
[root@server5 html]# cd
/usr/local/lnmp/nginx/html/memcache.php
浏览器测试
172.25.25.5/memcache.php
172.25.25.5/example.php
在物理主机测试:
6.Nginx+openresty
第三方下载openresty-1.13.6.1.tar.gz
[root@server5 ~]# tar zxf openresty-1.13.6.1.tar.gz
[root@server5 ~]# cd openresty-1.13.6.1
# 编译
[root@server5 openresty-1.13.6.1]# ./configure --prefix=/usr/local/lnmp/openresty --with-http_ssl_module --with-http_stub_status_module --user=nginx --group=nginx --with-threads --with-file-aio
gmake&&gmake install
编译
gmake
安装
[root@server5 openresty-1.13.6.1]# cd /usr/local/lnmp/openresty/nginx/conf
# 更改配置文件
[root@server5 conf]# vim nginx.conf
[root@server5 conf]# /usr/local/lnmp/openresty/nginx/sbin/nginx -t
# 关闭原来的服务
[root@server5 conf]# nginx -s stop
# 启动服务
[root@server5 conf]# /usr/local/lnmp/openresty/nginx/sbin/nginx
[root@server5 conf]# cd ..
[root@server5 nginx]# cd html/
[root@server5 html]# cp /usr/local/lnmp/nginx/html/example.php .
[root@server5 html]# cp /usr/local/lnmp/nginx/html/index.php .
更改的内容
浏览器测试
物理主机测试:明显比php+mencache提高了许多