使用Lnmp架构搭建论坛
一、源码安装mysql数据库
tar zxf mysql-boost-5.7.11.tar.gz
[root@server1 ~]# cd mysql-5.7.11/
[root@server1 mysql-5.7.11]# less INSTALL-SOURCE #查看安装步骤
[root@server1 ~]# yum install cmake-2.8.12.2-4.el6.x86_64.rpm -y #安装编译软件
软件包依赖性:
yum install -y gcc gcc-c++ make ncurses-devel bison openssl-devel zlib-devel
[[email protected]]#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 \ #Unix socket 文件路径
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \ #安装 innodb 存储引擎
> -DWITH_MYISAM_STORAGE_ENGINE=1 \ #安装 myisam 存储引擎
> -DDEFAULT_CHARSET=utf8 \ #使用 utf8 字符
> -DDEFAULT_COLLATION=utf8_general_ci \ #校验字符
> -DEXTRA_CHARSETS=all \ #安装所有扩展字符集
> -DWITH_BOOST=/root/mysql-5.7.11/boost/boost_1_59_0/
[root@server1 mysql-5.7.11]# rm -fr CMakeCache.txt #编译出错后,此时重新编译时,必须删除该文件后再编译
[root@server1 mysql-5.7.11]# make && make install
[root@server1 mysql-5.7.11]# groupadd -g 27 mysql #创建组
[root@server1 mysql-5.7.11]# useradd -u 27 -g 27 -M -d /usr/local/lnmp/mysql/ mysql
[root@server1 mysql-5.7.11]# usermod -s /sbin/nologin mysql #禁止用户交互式登陆
[root@server1 mysql]# chown mysql.mysql . -R
[root@server1 mysql]# vim /etc/my.cnf
[root@server1 support-files]# pwd
/usr/local/lnmp/mysql/support-files
[root@server1 support-files]# ls
magic my-default.cnf mysqld_multi.server mysql-log-rotate mysql.server
[root@server1 support-files]# cp mysql.server /etc/init.d/mysqld
[root@server1 support-files]#
[root@server1 ~]# vim .bash_profile
PATH=$PATH:/usr/local/lnmp/mysql/bin
[root@server1 ~]# source .bash_profile ##使之生效
[root@server1 ~]# mysqld --initialize --user=mysql #初始化mysql
[root@server1 ~]# /etc/init.d/mysqld start #启动mysql
[root@server1 ~]# cd /usr/local/lnmp/mysql
[root@server1 mysql]# chown root . -R
[root@server1 mysql]# chown mysql data -R
[root@server1 mysql]# mysql -p"=f;s8_K5Q.VQ" #登陆查看
[root@server1 mysql]# mysql_secure_installation #修改密码,需要用到初始化生成的密码
修改后登陆
至此,数据库安装配置完成
二、php源码 安装
lftp 172.25.27.250:/pub/docs/lamp> get php-5.6.20.tar.bz2
[root@server1 ~]# tar jxf php-5.6.20.tar.bz2
[root@server1 php-5.6.20]# ./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
需要解决的依赖性软件
yum install openssl-devel -y
yum install libxml2-devel -y
yum install libcurl-devel -y
yum provides */jpeglib.h
yum install -y libjpeg-turbo-devel-1.2.1-1.el6.x86_64
yum provides */png.h
yum install -y libpng-devel-1.2.49-1.el6_2.x86_64
yum provides */freetype-config
yum install -y freetype-devel-2.3.11-14.el6_3.1.x86_64
yum provides */gmp.h
yum install gmp-devel-4.3.1-7
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
[root@server1 php-5.6.20]# make &&make install
[root@server1 etc]# cd /usr/local/lnmp/php/etc/
[root@server1 etc]# cp php-fpm.conf.default php-fpm.conf
[root@server1 php-5.6.20]# cp php.ini-production /usr/local/lnmp/php/etc/php.ini
[root@server1 fpm]# cd /root/php-5.6.20/sapi/fpm
[root@server1 fpm]# cp init.d.php-fpm /etc/init.d/php-fpm
[root@server1 fpm]# chmod +x /etc/init.d/php-fpm
[root@server1 fpm]# cd /usr/local/lnmp/php/etc/
[root@server1 etc]# vim php-fpm.conf
pid = run/php-fpm.pid
[root@server1 etc]# vim php.ini
date.timezone = Asia/Shanghai #设置时区
[root@server1 etc]# useradd -u 800 -M -d /usr/local/lnmp/nginx nginx
[root@server1 etc]# /etc/init.d/php-fpm start
[root@server1 etc]# chkconfig php-fpm on #设置开机自启动
[root@server1 ~]# vim ~/.bash_profile
PATH=$PATH:/usr/local/lnmp/mysql/bin:/usr/local/lnmp/php/bin
[root@server1 ~]# source ~/.bash_profile #立即生效
三、源码安装nginx
[root@server1 ~]# tar zxvf nginx-1.10.1.tar.gz
[root@server1 nginx-1.10.1]# cd nginx-1.10.1
[root@server1 nginx-1.10.1]# vim auto/cc/gcc
#CFLAGS="$CFLAGS -g" (注释掉这行,去掉 debug 模式编译,编译以后程序只有几百 k)
[root@server1 nginx-1.10.1]# yum install pcre-devel -y
[root@server1 nginx-1.10.1]# ./configure --prefix=/usr/local/lnmp/nginx --with-http_ssl_module --with-http_stub_status_module --with-file-aio --with-threads --user=nginx --group=nginx
[root@server1 nginx-1.10.1]# make && make install
[root@server1 nginx-1.10.1]# ln -s /usr/local/lnmp/nginx/sbin/nginx /usr/local/sbin/
[root@server1 nginx-1.10.1]# cd /usr/local/lnmp/nginx/conf/
[root@server1 conf]# vim nginx.conf
nginx -t #检测语法
nginx #运行 nginx
nginx -s reload #重载主配置文件
nginx -s stop #关闭 nginx
[root@server1 conf]# nginx
[root@server1 conf]# nginx -s reload
[root@server1 conf]# cd /usr/local/lnmp/nginx/html/
[root@server1 html]# vim index.php #编写测试页面
[root@server1 conf]# vim /usr/local/lnmp/nginx/conf/nginx.conf
测试php:
四、开始搭建论坛
[root@server1 php]# vim etc/php.ini #添加数据库目录
[root@server1 php]# /etc/init.d/php-fpm reload
[root@server1 bbs]# unzip Discuz_X3.2_SC_UTF8.zip
[root@server1 bbs]# mv upload/ /bbs
[root@server1 bbs]# vim /usr/local/lnmp/nginx/conf/nginx.conf
[root@server1 conf]# nginx -s reload
[root@server1 bbs]# chmod 777 config/ data
[root@server1 bbs]# chmod 777 config/ data -R
[root@server1 bbs]# chmod 777 uc_client/ uc_server/ -R
[root@server1 bbs]# cd /usr/local/lnmp/mysql/
[root@server1 mysql]# chmod 755 data/
安装完成
[root@server1 mysql]# rm -fr /bbs/install/index.php #防止下次访问时再次安装
本地访问数据库,查看数据
至此,基于lnmp架构的论坛已经成功搭建