期盼死亡的小丑 发表于 2019-2-17 06:25:40

centos7利用LAMP实现Discuz的搭建

  一、准备工作

[*]  准备一台centos7.4的系统
[*]  关闭防火墙和selinux
# systemctl stopfirewalld.service
# systemctl disablefirewalld.service
# vim /etc/selinux/config
SELINUX=disabled
# systemctl reboot  二、准备搭建Discuz所需要的软件包,这是使用的是编译安装所有软件
  需要的软件有:apr-1.6.2.tar.gz、Discuz_X3.4_GIT_SC_UTF8.zip、mariadb-5.5.60-linux-x86_64.tar.gz 、xcache-3.2.0.tar.bz2、apr-util-1.6.0.tar.gz 、httpd-2.4.29.tar.bz2、php-5.6.36.tar.xz
  三、编译安装httpd2.4

[*]  这里是编译安装httpd,而httpd需要由apr,这里将centos7自带的apr和apr-util卸载
# yum remove -y apr.x86_64 apr-util.x86_64  2.将apr-1.6.2.tar.gz、apr-util-1.6.0.tar.gz 、httpd-2.4.29.tar.bz2解压缩
# tar xf apr-1.6.2.tar.gz ;tar xf apr-util-1.6.0.tar.gz ;tar xf httpd-2.4.29.tar.bz2  3.将apr-1.6.2.tar.gz、apr-util-1.6.0.tar.gz移动到httpd-2.4.29/srclib目录下,并将名字改为apr和apr-util
# mv apr-1.6.2 httpd-2.4.29/srclib/apr
# mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util  4.在编译安装之前需要安装几个软件包,不然在编译过程中会报错
# yum -y groupinstall "Development Tools"
# yum -y install pcre-devel openssl-devel expat-devel  5.开始编译安装
# cd httpd-2.4.29/
# ./configure --prefix=/app/httpd24 --sysconfdir=/etc/httpd24/conf --enable-so --enable-ssl --enable-rewrite --with-zlib --with-pcre
--with-included-apr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
# make -j 4 #这里根据cpu的数量自己定义
# make install  6.创建apache用户
# useradd -r -m -d /var/www -s /sbin/nologin apache
# mkdir /var/www/html  7.为了方便这里添加PATH变量
# vim /etc/profile.d/test.sh
exportPATH=/app/httpd24/bin:$PATH
# source /etc/profile.d/test.sh  8.将编译好的httpd服务添加到归systemd管理
# vim /usr/lib/systemd/system/httpd.service

Description=The Apache HTTP Server
After=network.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)

Type=forking
ExecStart=/app/httpd24/bin/apachectl start
ExecReload=/app/httpd24/bin/httpd $OPTIONS -k graceful
ExecStop=/bin/kill -WINCH ${MAINPID}
KillSignal=SIGCONT
PrivateTmp=true

WantedBy=multi-user.target
# systemctl daemon-reload #更新systemd
# systemctl restart httpd.service  9.简单修改配置文件
User apache
Group apache
ServerName www.test.com:80
DocumentRoot "/var/www/html"      #这里为了使用上和rpm包安装没有区别,所以也放入该目录下

    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted

# systemctl restart httpd.service  10.测试httpd2.4
# vim /var/www/html/index.html
test html index.htmlhttp://s1.运维网.com/images/20180505/1525506373231728.png
  四、编译安装mariadb数据库
  1.解压缩,由于编译mariadb时间太长,这里是从mariadb官方网站上下载已经编译好的包,所以解压缩时需要解压缩到/usr/local/目录下并且需要叫mysql
# tar xf mariadb-5.5.60-linux-x86_64.tar.gz -C /usr/local/
# cd /usr/local/
# ln -s mariadb-5.5.60-linux-x86_64/ mysql  2.创建用户

# useradd -r -m -d /app/mysqldb -s /sbin/nologin mysql  3.设置配置文件
# cd /usr/local/mysql/
# mkdir /etc/mysql
# cp support-files/my-large.cnf /etc/mysql/my.cnf
# vim /etc/mysql/my.cnf

datadir = /app/mysqldb #指定数据库文件存放位置
innodb_file_per_table = on#指定每一个表是一个文件
skip_name_resolve = on #不进行反解析  4.安装数据库

# scripts/mysql_install_db --datadir=/app/mysql --user=mysql  5.设置PATH变量
# vim /etc/profile.d/test.sh
exportPATH=/usr/local/mysql/bin:/app/httpd24/bin:$PATH
# source /etc/profile.d/test.sh  6.拷贝启动脚本,让服务可以使用systemctl管理
# cp support-files/mysql.server /etc/init.d/mysqld
# chkconfig --add mysqld
# chkconfig mysqld on  7.mariadb5版本要想让mysql用户在/var/log/目录下写日志需要单独给权限
# mkdir /var/log/mariadb
# setfacl -m u:mysql:rwx /var/log/
# setfacl -m u:mysql:rwx /var/log/mariadb  8.重启服务
# systemctl restart mysqld.service  9.创建初始化数据库

# mysql_secure_installation
/usr/local/mysql/bin/mysql_secure_installation: line 393: find_mysql_client: command not found
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user.If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.This is intended only for testing, and to make the installation
go a bit smoother.You should remove them before moving into a
production environment.
Remove anonymous users? y
... Success!
Normally, root should only be allowed to connect from 'localhost'.This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? n
... skipping.
By default, MariaDB comes with a database named 'test' that anyone can
access.This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? y
... Success!
Cleaning up...
All done!If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!  10.创建对应的数据库和授权用户
# mysql -uroot -pcentos
MariaDB [(none)]> create database luntan;
MariaDB [(none)]> grant all on luntan.* to luntanuser@"%" identified by "centos";  五.编译安装php,若使用php5版本,则需要mariadb,使用10版本的mariadb不兼容
  1.解压缩

# tar xf php-5.6.36.tar.xz  2.安装编译安装所需要的软件包,这里需要epel源
# yum -y install libxml2-devel bzip2-devel libmcrypt-devel  3.编译安装

# ./configure --prefix=/app/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring
--with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/app/httpd24/bin/apxs --with-mcrypt
--with-config-file-path=/etc/php --with-config-file-scan-dir=/etc/php.d --with-bz22
# make -j 4
# make install  4.复制配置文件
# cp php.ini-production /etc/php.ini  5.编辑httpd服务的配置文件
# vim /etc/httpd24/conf/httpd.conf

    DirectoryIndex index.php index.html

AddType application/x-httpd-php .php
AddType application/x-httpd-php-soure .phps  6.测试php与mysql数据库连通性
# vim index.php

# systemctl restart httpd.servicehttp://s1.运维网.com/images/20180505/1525511450900315.png
  六、安装Discuz
# unzip Discuz_X3.4_GIT_SC_UTF8.zip
# mv dir_SC_UTF8/ /var/www/html/
# ln -s dir_SC_UTF8/ lt
# cd /var/www/html/dir_SC_UTF8/upload/config/
# cp config_global_default.php config_global.php
# cp config_ucenter_default.php config_ucenter.php
# setfacl -Rm u:apache:rwx dir_SC_UTF8/  在网页上输入http://192.168.86.7/lt/upload/install/
http://s1.运维网.com/images/20180505/1525511667279807.pnghttp://s1.运维网.com/images/20180505/1525512200400215.pnghttp://s1.运维网.com/images/20180505/1525512212838845.pnghttp://s1.运维网.com/images/20180505/1525512225924326.pnghttp://s1.运维网.com/images/20180505/1525512317701461.png



页: [1]
查看完整版本: centos7利用LAMP实现Discuz的搭建