设为首页 收藏本站
查看: 1143|回复: 0

[经验分享] centos7利用LAMP实现Discuz的搭建

[复制链接]
发表于 2019-2-17 06:25:40 | 显示全部楼层 |阅读模式
  一、准备工作

  •   准备一台centos7.4的系统
  •   关闭防火墙和selinux
[root@centos7 ~]# systemctl stop  firewalld.service
[root@centos7 ~]# systemctl disable  firewalld.service
[root@centos7 ~]# vim /etc/selinux/config
SELINUX=disabled
[root@centos7 ~]# 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卸载
[root@centos7 ~]# 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解压缩
[root@centos7 ~]# 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
[root@centos7 ~]# mv apr-1.6.2 httpd-2.4.29/srclib/apr
[root@centos7 ~]# mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util  4.在编译安装之前需要安装几个软件包,不然在编译过程中会报错
[root@centos7 httpd-2.4.29]# yum -y groupinstall "Development Tools"
[root@centos7 httpd-2.4.29]# yum -y install pcre-devel openssl-devel expat-devel  5.开始编译安装
[root@centos7 ~]# cd httpd-2.4.29/
[root@localhost 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
[root@centos7 httpd-2.4.29]# make -j 4 #这里根据cpu的数量自己定义
[root@centos7 httpd-2.4.29]# make install  6.创建apache用户
[root@centos7 httpd-2.4.29]# useradd -r -m -d /var/www -s /sbin/nologin apache
[root@centos7 httpd-2.4.29]# mkdir /var/www/html  7.为了方便这里添加PATH变量
[root@centos7 bin]# vim /etc/profile.d/test.sh
export  PATH=/app/httpd24/bin:$PATH
[root@centos7 bin]# source /etc/profile.d/test.sh  8.将编译好的httpd服务添加到归systemd管理
[root@centos7 ~]# vim /usr/lib/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)
[Service]
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
[Install]
WantedBy=multi-user.target
[root@centos7 ~]# systemctl daemon-reload #更新systemd
[root@centos7 ~]# 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

[root@centos7 ~]# systemctl restart httpd.service  10.测试httpd2.4
[root@centos7 ~]# vim /var/www/html/index.html
test html index.html

  四、编译安装mariadb数据库
  1.解压缩,由于编译mariadb时间太长,这里是从mariadb官方网站上下载已经编译好的包,所以解压缩时需要解压缩到/usr/local/目录下并且需要叫mysql
[root@centos7 ~]# tar xf mariadb-5.5.60-linux-x86_64.tar.gz -C /usr/local/
[root@centos7 ~]# cd /usr/local/
[root@centos7 local]# ln -s mariadb-5.5.60-linux-x86_64/ mysql  2.创建用户

[root@centos7 local]# useradd -r -m -d /app/mysqldb -s /sbin/nologin mysql  3.设置配置文件
[root@centos7 mysql]# cd /usr/local/mysql/
[root@centos7 mysql]# mkdir /etc/mysql
[root@centos7 mysql]# cp support-files/my-large.cnf /etc/mysql/my.cnf
[root@centos7 mysql]# vim /etc/mysql/my.cnf
[mysqld]
datadir = /app/mysqldb #指定数据库文件存放位置
innodb_file_per_table = on  #指定每一个表是一个文件
skip_name_resolve = on #不进行反解析  4.安装数据库

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

[root@centos7 log]# 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/n] 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/n] 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? [Y/n] 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/n] 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/n] 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.创建对应的数据库和授权用户
[root@centos7 log]# 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.解压缩

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

[root@centos7 php-5.6.36]# ./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
[root@centos7 php-5.6.36]# make -j 4
[root@centos7 php-5.6.36]# make install  4.复制配置文件
[root@centos7 php-5.6.36]# cp php.ini-production /etc/php.ini  5.编辑httpd服务的配置文件
[root@centos7 php-5.6.36]# 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数据库连通性
[root@centos7 html]# vim index.php

[root@centos7 html]# systemctl restart httpd.service

  六、安装Discuz
[root@centos7 ~]# unzip Discuz_X3.4_GIT_SC_UTF8.zip
[root@centos7 ~]# mv dir_SC_UTF8/ /var/www/html/
[root@centos7 upload]# ln -s dir_SC_UTF8/ lt
[root@centos7 ~]# cd /var/www/html/dir_SC_UTF8/upload/config/
[root@centos7 config]# cp config_global_default.php config_global.php
[root@centos7 config]# cp config_ucenter_default.php config_ucenter.php
[root@centos7 html]# setfacl -Rm u:apache:rwx dir_SC_UTF8/  在网页上输入http://192.168.86.7/lt/upload/install/





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-673277-1-1.html 上篇帖子: centos6安装LAMP并进行xcache加速 下篇帖子: centos7.4编译安装lamp
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表