Discuz Forum of LAMP Architecture (practical part)
LAMP Architecture experiment
Experimental premise
Mount.cifs / / 192.168.100.3/LAMP-C7 / mnt # remotely mount the software package to the local server / mnt directory
Compile and install the Apache service
1) decompress the source code package to the / opt directory
Tar zxvf apr-1.6.2.tar.gz-C / opt/
Tar zxvf apr-util-1.6.0.tar.gz-C / opt/
Tar jxvf httpd-2.4.29.tar.bz2-C / opt/
2) move the two cross-platform directories of apr to the httpd directory
Mv apr-1.6.2/ httpd-2.4.29/srclib/apr
Mv apr-util-1.6.0/ httpd-2.4.29/srclib/apr-util
3), install the environment package
Yum-y install\
Gcc\ # c language compiler
Gcc-c++\ # C++ language compiler
Make\ # compilation tool
Pcre-devel\ # pcre language tool
Expat-devel\ # A tool for identifying tagged languages
Perl # perl compiler
# enter the httpd configuration installation directory and modules:
Cd / opt/httpd-2.4.29/
. / configure\
-- prefix=/usr/local/httpd\
-- enable-deflate\
-- enable-expires\
-- enable-so\ # apache core module is enabled
-- enable-rewrite\ # enable rewrite function to protect hotlink
-- enable-charset-lite\ # supports character set, simplified Chinese
-- enable-cgi # Universal Gateway Interface
# compile and install
Make & & make install
# copy the apache startup script to overwrite the original httpd startup script
Cp / usr/local/httpd/bin/apachectl / etc/init.d/httpd
Vim / etc/init.d/httpd / / configure the httpd file parameters and enter the following three lines in the document
#! / bin/sh
# chkconfig: 35 85 21
# description: Apache is a World Wide Web server
Chkconfig-- add httpd / / add httpd to server Manager
Vim / usr/local/httpd/conf/httpd.conf
Ln-s / usr/local/httpd/conf/httpd.conf / etc/ create a soft connection
Ln-s / usr/local/httpd/bin/* / usr/local/bin/
Systemctl stop firewalld.service / / turn off the firewall
Setenforce 0
Httpd-t / / check that the configuration file syntax is correct
Service httpd start / / enable the service
Second, install MySQL
Cd ~
# installation environment package and cmake toolkit
Yum install-y ncurses-devel autoconf cmake
# decompress the database package to the / opt directory
Tar zxvf mysql-5.6.26.tar.gz-C / opt/
# enter the database directory
Cd / opt/mysql-5.6.26/
Cmake\
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\ # specify the installation path
-DDEFAULT_CHARSET=utf8\ # specify the character set
-DDEFAULT_COLLATION=utf8_general_ci\ # specifies the character set default
-DEXTRA_CHARSETS=all\ # specify an extended character set
-DSYSCONFIDIR=/etc\ # specify the configuration file directory
-DMYSQL_DATADIR=/home/mysql/\ # specify the data file in the database
-DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock # defines sock files to connect to database files
# compile and install
Make & & make install
# copy template to create configuration file
Cp support-files/my-default.cnf / etc/my.cnf
Cp: overwrite "/ etc/my.cnf"? Yes
Cp support-files/mysql.server / etc/init.d/mysqld
Cp: overwrite "/ etc/init.d/mysqld"? Yes
# Grant execution permission
Chmod 755 / etc/init.d/mysqld
# add database services to the server manager
Chkconfig-add / etc/init.d/mysqld
# Open the database running level 2, 3, 5
Chkconfig mysqld-level 235 on
# enable database commands to system environment variables
Echo "PATH=$PATH:/usr/local/mysql/bin" > > / etc/profile
# enable system environment variables
Source / etc/profile
# View system environment variables
Echo $PATH
/ ur/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin
# create mysql program users and prohibit logging in to the database
Useradd-s / sbin/nologin mysql
Chown-R mysql:mysql / usr/local/mysql/
# initialize the database and specify the user data information to the specified directory
/ usr/local/mysql/scripts/mysql_install_db-user=mysql-ldata=/var/lib/mysql-basedir=/usr/local/mysql-datadir=/home/mysql
# Editing the database configuration file
Vim / etc/init.d/mysqld
# specify the local path to the database on line 46
Basedir=/usr/local/mysql
# specify the location of the database on line 47
Datadir=/home/mysql
# enable database service
Service mysqld start
Starting MySQL. SUCCESS!
# View database listening port 3306
Netstat-anpt | grep 3306
Tcp6 0 0: 3306: * LISTEN 90105/mysqld
# set a password for the root account
Mysqladmin-u root-p password "abc123"
Third, install PHP
Install the PHP environment:
Yum install-y gd libpng libpng-devel pcre pcre-devel libxml2-devel libjpeg-devel
Decompress PHP source code packet
Cd / mnt
Tar jxvf php-5.6.11.tar.bz2-C / opt/
# configure PHP-related components and associated database and httpd services
Cd / opt/php-5.6.11/ # enter the / opt/php-5.6.11/ directory
. / configure\
-- prefix=/usr/local/php5\
-- with-gd\
-- with-zlib\
-- with-apxs2=/usr/local/httpd/bin/apxs\
-- with-mysql=/usr/local/mysql\
-- with-config-file-path=/usr/local/php5\
-- enable-mbstring
Compile and install
Make & & make install
# copy the configuration file to the php.ini directory
Cp php.ini-development / usr/local/php5/php.ini
# establish soft links for PHP commands
Ln-s / usr/local/php5/bin/* / usr/local/bin/
Edit httpd profile
Vim / etc/httpd.conf
# # replace index.html with index.php in line 256 DirectoryIndex index.html # #
two hundred and fifty five
256 DirectoryIndex index.php
two hundred and fifty seven
# # and then append the following two line entries to grant PHP execution permission # #
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Edit the PHP home page file
# vim / usr/local/httpd/htdocs/index.php
Restart the httpd service
Service httpd restart
Fourth, install Discuz Forum
# enter the / mnt directory
Cd / mnt
# decompress the forum component package to the / opt directory
Unzip Discuz_X2.5_SC_UTF8.zip-d / opt/Discuz
# copy the contents of the / opt directory to the bbs directory of the httpd site
Cp-r / opt/Discuz/upload/ / usr/local/httpd/htdocs/bbs
# enter the database, and the password is the previously set abc123
# create bbs database
Create database bbs
# lift the rights of the database user bbsuser as the administrator and set the password
GRANT all ON bbs.* TO 'bbsuser'@'192.168.235.137' IDENTIFIED BY' admin123'
# refresh the database
Flush privileges
# exit the database
Quit
# enter the bbs directory
Cd / usr/local/httpd/htdocs/bbs/
# elevate privileges for users of each program
Chown-R daemon. / config/
Chown-R daemon. / data/
Chown-R daemon. / uc_client/data/cache/ [root @ lamp bbs] # chown-R daemon. / uc_server/data/
5. Installation of forums on the web page
Enter 192.168.131.133/bbs in the browser to officially install the Discuz forum
Check the installation environment
Select a fresh installation when setting up the running environment
Install the database
Data server: 192.168.235.137 (enter the IP to create the database host here)
Database name: bbs
Database user name: bbsuser (user name can be changed on the command line)
Database password: admin123 (password can be changed on the command line)
Administrator account: admin (this account is the default)
Password: abc123 (password can be set directly on the web page)
This is where we can go to the home page of the forum.