标签:Discuz
一、准备工作准备一台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包安装没有区别,所以也放入该目录下 <Directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> [root@centos7 ~]# systemctl restart httpd.service
10.测试httpd2.4
[root@centos7 ~]# vim /var/www/html/index.html <h1>test html index.html</h1>
四、编译安装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 <IfModule dir_module> DirectoryIndex index.php index.html </IfModule> AddType application/x-httpd-php .php AddType application/x-httpd-php-soure .phps
6.测试php与mysql数据库连通性
[root@centos7 html]# vim index.php <?php $conn = mysql_connect('127.0.0.1','luntanuser','centos'); if ($conn) echo "OK"; else echo "Failure"; mysql_close(); ?> [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/
标签:Discuz
原文地址:http://blog.51cto.com/10492754/2113044