LNMP架构的搭建(nginx+mysql+php源码安装 )+Discuz论坛的搭建

主机环境 redhat6.5 64位

实验环境 服务端 ip172.25.29.1  nginx+mysql+php

安装包   nginx-1.10.1.tar.gz

        mysql-boost-5.7.11.tar.gz

      cmake-2.8.12.2-4.el6.x86_64.rpm

php-5.6.20.tar.bz2

        re2c-0.13.5-1.el6.x86_64.rpm

        libmcrypt-2.5.8-9.el6.x86_64.rpm

        libmcrypt-devel-2.5.8-9.el6.x86_64.rpm

        Discuz_X3.2_SC_UTF8.zip


1. nginx源码安装及配置

  1.安装

[[email protected] mnt]# yum install gcc -y      #安装gcc

[[email protected] mnt]# tar zxf nginx-1.10.1.tar.gz   #解压nginx压缩包

[[email protected] mnt]# ls

nginx-1.10.1  nginx-1.10.1.tar.gz

[[email protected] mnt]# cd nginx-1.10.1

[[email protected] nginx-1.10.1]# vim auto/cc/gcc     #禁止debug调试

178 # debug

179#CFLAGS="$CFLAGS -g"

[[email protected] nginx-1.10.1]# vim src/core/nginx.h   #禁止出现nginx版本号,以保证安全性

14 #defineNGINX_VER          "nginx/"

[[email protected] nginx-1.10.1]# ./configure--prefix=/usr/local/lnmp/nginx --with-http_ssl_module--with-http_stub_status_module

如果出现以下错误

[[email protected] nginx-1.10.1]# yum install pcre-devel -y

重新配置

[[email protected] nginx-1.10.1]# ./configure --prefix=/usr/local/lnmp/nginx--with-http_ssl_module --with-http_stub_status_module

如果出现以下错误

[[email protected] nginx-1.10.1]# yum install openssl-devel -y

重新配置

[[email protected] nginx-1.10.1]# ./configure--prefix=/usr/local/lnmp/nginx --with-http_ssl_module --with-http_stub_status_module

[[email protected] nginx-1.10.1]# make

[[email protected] nginx-1.10.1]# make install

2.将nginx作为系统变量,开启nginx

[[email protected]]# cd /usr/local/lnmp/nginx/

[[email protected] nginx]# ls

conf  html  logs sbin

[[email protected] nginx]# ln -s /usr/local/lnmp/nginx/sbin/nginx/usr/local/sbin/  #作软链接将nginx的启动命令作为系统命令

[[email protected] nginx]# nginx -t     #检测

nginx: the configuration file/usr/local/lnmp/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/lnmp/nginx/conf/nginx.conftest is successful

[[email protected] nginx]# nginx    #打开nginx

2. mysql的源码安装及配置

1.安装

[[email protected] mnt]#tar zxf mysql-boost-5.7.11.tar.gz  #解压gz包

[[email protected] mnt]#yum install cmake-2.8.12.2-4.el6.x86_64.rpm -y #安装cmake

[[email protected] mnt]#cd mysql-5.7.11/

2软件配置

[[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_MYISAM_STORAGE_ENGINE=1 \   #安装 myisam 存储引擎

>-DWITH_INNOBASE_STORAGE_ENGINE=1 \  #安装 innodb 存储引擎

>-DDEFAULT_CHARSET=utf8 \           #使用 utf8 字符

>-DDEFAULT_COLLATION=utf8_general_ci \  #校验字符

>-DEXTRA_CHARSETS=all \     #安装所有扩展字符集

>-DWITH_BOOST=boost/boost_1_59_0/  #boost的指定路径

如果出现如下错误

[[email protected]]# rm -fr CMakeCache.txt   #清空缓存文件

[[email protected]]# yum install ncurses-devel gcc-c++ -y  #安装上图需要的软件包

####注意:一定要清空缓存文件

重新配置

[[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-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/

[[email protected]]# yum install bison -y  #系统可以跳过warning错误,此步骤可有可无

[[email protected] mysql-5.7.11]# make      #编译,链接,生成可执行文件

[[email protected] mysql-5.7.11]# make install   #安装

   

   2.mysql的简单配置

[[email protected] mysql-5.7.11]# cd /usr/local/lnmp/mysql/

[[email protected] mysql]# useradd -u 27  -M -d /usr/local/lnmp/mysql/data -s/sbin/nologin mysql                                    #创建mysql用户

[[email protected] mysql]#groupmod -g 27 mysql

[[email protected] mysql]# id mysql

uid=27(mysql) gid=27(mysql) groups=27(mysql)

[[email protected] mysql]# chown mysql.mysql . -R         #修改mysql目录下文件的权限

[[email protected] mysql]# cp /etc/my.cnf  /mnt/            #备份my.cnf

[[email protected] mysql]# cd support-files/

[[email protected] support-files]# cp my-default.cnf  /etc/my.cnf  #服务器配置文件

cp: overwrite `/etc/my.cnf‘? y

[[email protected] support-files]# cp mysql.server/etc/init.d/mysqld   #添加mysql启动命令

[[email protected] support-files]# cd ..

[[email protected] mysql]# cd bin/

[[email protected] bin]# pwd

/usr/local/lnmp/mysql/bin

[[email protected] bin]# vim /root/.bash_profile     #将mysql添加到系统的环境变量里

10PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin

[[email protected] bin]# source /root/.bash_profile  #刷新环境变量文件

[[email protected] bin]# echo $PATH                  #查看mysql添加到环境变量

/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin:/usr/local/lnmp/mysql/bin

[[email protected] bin]# which mysql        #测试

/usr/local/lnmp/mysql/bin/mysql

[[email protected] ~]# mysqld --initialize --user=mysql    #初始化mysql

[[email protected] bin]# cd /usr/local/lnmp/mysql/

[[email protected] ~]# chown root . -R                #改回权限

[[email protected] mysql]# chown mysql data/ -R

[[email protected] ~]# /etc/init.d/mysqld start       #启动mysql

Starting MySQL. SUCCESS!

[[email protected] ~]# mysql-p          #登陆mysql

Enter password:        #密码是上一个截图里最后的QV>6!r4LCyjw

 

3. php的源码安装及配置

1.安装

[[email protected] mnt# tar jxf php-5.6.20.tar.bz2    #解压

[[email protected] php-5.6.20]# rpm -vih libmcrypt-*   #安装libmcrypt库

[[email protected] php-5.6.20]# yum installre2c-0.13.5-1.el6.x86_64.rpm –y   #安装re2c

[[email protected] php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash

如果出现如下错误[[email protected] php-5.6.20]# yum install libxml2-devel -y

[[email protected] php-5.6.20]# ./configure--prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir--with-png-dir --with-jpeg-dir --with-freetype-dir --with-gettext--without-pear --with-gmp --enable-inline-optimization --enable-soap--enable-ftp --enable-sockets --enable-mbstring --with-mysqli --with-mysql--with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx--with-mcrypt --with-mhash

#####注意:php在加载配置过程中,如上面会报很多错误。有经验的可以根据报错自己去装所需要的包;新手可以参考前几篇博文,安装所需要的包

[[email protected] php-5.6.20]# make #编译

[[email protected] php-5.6.20]# make install   #安装

 2.php的配置

[[email protected] php-5.6.20]# cd /usr/local/lnmp/php/etc/

[[email protected] etc]# ls

php-fpm.conf.default

[[email protected] etc]# cp php-fpm.conf.default php-fpm.conf   #备份php的文件

[[email protected] etc]# ls

php-fpm.conf php-fpm.conf.default

[[email protected] etc]# cp /mnt/php-5.6.20/php.ini-productionphp.ini   #php的配置文件

[[email protected] etc]# ls

php-fpm.conf php-fpm.conf.default  php.ini

[[email protected] etc]# vim php.ini

925 date.timezone = Asia/Shanghai          #修改时区

1001 pdo_mysql.default_socket=/usr/local/lnmp/mysql/data/mysql.sock   #指定连接数据库的sock文件的路径

1150 mysql.default_socket =/usr/local/lnmp/mysql/data/mysql.sock   #同上

1209 mysqli.default_socket =/usr/local/lnmp/mysql/data/mysql.sock   #同上

[[email protected] etc]# vim php-fpm.conf

25 pid = run/php-fpm.pid          #将pid的标记去掉

[[email protected] etc]# cd /mnt/php-5.6.20/sapi/fpm/

[[email protected] fpm]# cp init.d.php-fpm /etc/init.d/php-fpm   #添加启动命令

[[email protected] fpm]# chmod +x /etc/init.d/php-fpm       #添加可执行权限

[[email protected] fpm]# ll /etc/init.d/php-fpm

-rwxr-xr-x 1 root root 2359 Sep 18 00:18 /etc/init.d/php-fpm

[[email protected] fpm]# /etc/init.d/php-fpm start        #开启php服务

Starting php-fpm  done

[[email protected] fpm]# cd /usr/local/lnmp/nginx/conf/

[[email protected] conf]# vim nginx.conf

51             root   html;

52             index  index.php index.html index.htm;     #在nginx里添加默认访问目录为php优先

50         location / {

53         }

75         location ~ \.php$ {

76             root           html;

77             fastcgi_pass   127.0.0.1:9000;

78             fastcgi_index  index.php;

79             fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

80             include        fastcgi.conf;         #设置成已存在的文件

81         }

[[email protected] conf]# nginx –t       #检测

[[email protected] conf]# nginx           #开启

 

4.搭建bbs论坛

[[email protected] html]# unzip /mnt/Discuz_X3.2_SC_UTF8.zip -d/usr/local/lnmp/nginx/html/              #解压Discuz包

[[email protected] html]# ls

50x.html  index.html  index.php readme  upload  utility

[[email protected] html]# mv upload/ bbs/       #给upload文件重命名

[[email protected] html]# ls

50x.html  bbs  index.html index.php  readme  utility

[[email protected] html]# chmod 777 -R bbs/     #修改权限

[[email protected] html]# mysql –p

Enter password:

mysql> grant all on discuz.* to [email protected] identifiedby ‘Red+hat888‘;  #创建能从论坛操作数据库的数据库用户

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> exit

Bye

[[email protected] html]# cd /usr/local/lnmp/mysql/

[[email protected] mysql]# chmod 755 data/

             

时间: 2024-10-19 13:19:15

LNMP架构的搭建(nginx+mysql+php源码安装 )+Discuz论坛的搭建的相关文章

ubuntu 14.04 nginx + mysql + php源码安装

本文参考了 http://www.tuicool.com/articles/3iUNFnA  并在细节上做了一些补充.使安装过程更加顺畅. 首先要说的是ubuntu 上操作需要加sudo命令,所以在以下的命令上都要以sudo开始. 先安装一些依赖资源gcc  g++ openssl  libssl-dev (RedHat.centos才是openssl-devel) sudo apt-get install openssl sudo apt-get install libssl-dev sudo

LAMP源码安装Discuz论坛

一.Mysql安装 http://mirrors.sohu.com/mysql/MySQL-5.1/   Mysql下载网站 cd /usr/local/src/ wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.72-linux-i686-glibc23.tar.gz tar zxvf mysql-5.1.72-linux-i686-glibc23.tar.gz  mv mysql-5.1.72-linux-i686-glibc23 

搭建zabbix(yum安装zabbix,ngixn,mysql,源码安装php)

yum安装zabbix,ngixn,mysql,源码安装php,并不是有特别的效果,而是zabbix源码安装失败了... 1.安装zabbix的repo2.yum 安装 3.yum安装mariadb mariadb-server4.创库zabbix,赋权给zabbix用户5.将zabbix文件的库导入mysql中 6.修改zabbix_server.conf配置文件7.启动开机自启zabbix_server.service 8.yum安装nginx9.修改nginx.conf配置文件,用ngin

Centos 7 Nginx+Keepalived+Tomcat 源码安装与运用

Nginx+Keepalived+Tomcat 源码 第一部分 环境准备一:Nginx+keepalived服务器两台(调度器,双机热备)系统:Linux-CentOS7.4IP地址:192.168.80.100(lvs01)192.168.80.101(lvs02)软件需求:nginx安装包(nginx-1.13.9.tar.gz)Keepalived安装包(keepalived-1.4.2.tar.gz)二:tomcat服务器两台(服务器池)系统:Linux-CentOS7.4IP地址:19

Mysql的源码安装

到网站上面下载:cmake-3.0.0.tar.gz和mysql-5.5.8.tar.gz: 解压安装cmake-3.0.0.tar.gz tar -zxv -f cmake-3.0.0.tar.gz cd cmake-3.0.0 ./configure make make install 解压安装mysql-5.5.8.tar.gz (1).创建mysql安装目录和数据存放目录 mkdir -p /usr/local/mysql                 //安装mysql  mkdir

Linux+Apache+Mysql+Php源码安装

一.安装环境: 系统:Centos6.5x64 Apache: httpd-2.4.10.tar.gz Mysql: mysql-5.6.20-linux-glibc2.5-x86_64.tar.gz Php: php-5.6.0.tar.gz Apr: apr-1.5.1.tar.gz Apr-util: apr-util-1.5.3.tar.gz Libxml2: libxml2-2.9.1.tar.gz 默认安装路径我们统一安装到/usr/local下 二.Apache安装: 安装Apac

mysql数据库源码安装

Mysql数据库采用源码安装 [[email protected] ~]# wget -c http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17.tar.gz [[email protected] ~]# tar -zxf mysql-5.7.17.tar.gz [[email protected] ~]# cd mysql-5.7.17 [[email protected] mysql-5.7.17]# yum install cmake n

LNMP架构结介绍,MySQL和PHP的安装以及Nginx介绍

一.LNMP架构结介绍 LNMP代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器架构.Nginx中的PHP是以fastcgi的方式结合Nginx的,可以理解为Nginx代理了PHP的fastcgi. 详细介绍可参考:http://blog.csdn.net/u013592371/article/details/73729892 二.LNMP架构-安装MySQL LNMP中MySQL的安装步骤与LAMP中安装一样,这里简单写一下安装过程: [email protected]

CentOS 7搭建tengine+php+mariadb环境并安装discuz论坛

一.安装tengine+php+mariadb环境 1.配置网络 nmcli c del 'System eth0'  # 删除网络 nmcli c add con-name myeth0 ifname eth0 typeethernet ip4 172.16.10.133/24 gw4 172.16.10.254     #配置IP地址以及网关 nmcli c mod myeth0 ipv4.dns"223.5.5.5,223.6.6.6" #设置DNS服务器 systemctl d