LAMP+DISCUZ Forum

Table of contents

1. Introduction and overview of LAMP

1.1. Overview of the LAMP platform

1.2. Build the LAMP platform sequence

1.3. Advantages of compiling and installing 

1.4. The main function of each component

2. Application examples of LAMP architecture

2.1 Install Apache

2.2 Install MYSQL

2.3 Install PHP

2.3 Install Forum


1. Introduction and overview of LAMP

1.1. Overview of the LAMP platform

        The LAMP architecture is one of the mature enterprise website application modes at present. It refers to a whole system and related software that work in harmony, and can provide Dongtai web site service and its application development environment.

        LAMP is an acronym, specifically including Linux operating system, Apache web server, MySQL database server, PHP web programming language

1.2. Build the LAMP platform sequence

        When building the LAMP platform, the installation order of each component is Linux, Apache, MySQL, PHP

        Among them, the installation of Apache and MySQL does not have strict order requirements, and the installation of the PHP environment is generally put at the end, responsible for communicating with the web server and database to work together

1.3. Advantages of compiling and installing 

        1. With a large degree of freedom, the function can be customized

        2. The latest software version can be obtained in time

        3. Universally applicable to most Linux versions, easy to use all the time

1.4. The main function of each component

        linux: As the basis of the LAMP architecture, it provides an operating system for supporting Web sites, and can provide better stability and compatibility with the other three components (LAMP components also support Windows, UNIX and other platforms)

2. Application examples of LAMP architecture

2.1 Install Apache

1. Prepare the source package that needs to be installed

2. Unzip to the current directory

3. Move to the /srclib directory

4. Installation depends on the environment

 

yum -y install \
gcc \
gcc-c++ \
make \
pcre-devel \
expat-devel \
perl

5. Compile and install httpd and its modules

cd /opt/httpd-2.4.29/
./configure \
--prefix=/usr/local/httpd \
--enable-so \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi

6. Specify the number of cpu cores to compile and install

 7. Optimize configuration file path

ln -s /usr/local/httpd/conf/httpd.conf /etc/

ln -s /usr/local/httpd/bin/* /usr/local/bin/

8. Use systemctl to facilitate service management

cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
vim /etc/init.d/httpd

 

 

 9. Start the service

10. Enter the browser to access the address of the linux ens33 network card 

 Service installed successfully!

 

2.2 Install MYSQL

1. Installation dependent environment

yum -y install gcc gcc-c++ ncurses ncurses-devel bison cmake

2. Create program user management

useradd -s /sbin/nologin mysql

3. Unzip the source package

tar zxvf mysql-5.7.17.tar.gz -C /opt
tar zxvf boost_1_59_0.tar.gz -C /usr/local/
mv /usr/local/boost_1_59_0 /usr/local/boost

4. mysql compile and install

cd /opt/mysql-5.7.17/

cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DSYSCONFDIR=/etc \
-DSYSTEMD_PID_DIR=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8  \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_BOOST=/usr/local/boost \
-DWITH_SYSTEMD=1

make && make install

Note: Deploying mysql errors is basically caused by insufficient memory, 
you can try echo 1 > /proc/sys/vm/drop_caches #Clear cache  

If there is an error in the process of CMAKE, after the error is resolved, you need to delete the CMakeCache.txt file in the source directory, and then restart CMAKE, otherwise the error remains


#Create common user management mysql
useradd -s /sbin/nologin mysql
chown -R mysql:mysql /usr/local/mysql/
#Change management master/group
chown mysql:mysql /etc/my.cnf

#Modify configuration file
vim /etc/my.cnf #Delete the original configuration item, and then re-add the following content

[client] #Client setting
port = 3306
socket=/usr/local/mysql/mysql.sock            

[mysqld]                                    #服务全局设置
user = mysql                                   #设置管理用户
basedir=/usr/local/mysql                    #指定数据库的安装目录
datadir=/usr/local/mysql/data                #指定数据库文件的存储路径
port = 3306                                    #指定端口
character-set-server=utf8                    #设置服务器字符集编码格式为utf8
pid-file = /usr/local/mysql/mysqld.pid        #指定pid 进程文件路径
socket=/usr/local/mysql/mysql.sock            #指定数据库连接文件
bind-address = 0.0.0.0                        #设置监听地址,0.0.0.0代表允许所有,如允许多个IP需空格隔开
skip-name-resolve                            #禁用DNS解析
max_connections=2048                        #设置mysql的最大连接数
default-storage-engine=INNODB                #指定默认存储引擎
max_allowed_packet=16M #Set the maximum size of the data packet received by the database
server-id = 1 #Specify the service ID number


[client]                                    
port = 3306
default-character-set=utf8
socket=/usr/local/mysql/mysql.sock    

[mysql]                                    
port = 3306
default-character-set=utf8
socket=/usr/local/mysql/mysql.sock
auto-rehash

[mysqld]
user = mysql 
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port = 3306    
character-set-server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket=/usr/local/mysql/mysql.sock
bind-address = 0.0.0.0
skip-name-resolve
max_connections=2048
default-storage-engine=INNODB
max_allowed_packet=16M
server-id = 1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES

Initialize the database

cd /usr/local/mysql/bin/
./mysqld \
--initialize-insecure \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data

cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
systemctl daemon-reload #Refresh identification     
systemctl start mysqld.service #Enable service
systemctl enable mysqld #Boot self-start
netstat -anpt | grep 3306 #View port


#Set a password for the root account
mysqladmin -u root -p password "123456" 
———— "Enter directly

 

2.3 Install PHP

yum -y install \
gd \
libjpeg libjpeg-devel \
libpng libpng-devel \
freetype freetype-devel \
libxml2 libxml2-devel \
zlib zlib-devel \
curl curl-devel \
openssl openssl-devel
Install the GD library and GD library associated programs to process and generate images

 decompress

 
cd /opt
tar zxvf php-7.1.24.tar.gz

Compile and install

cd /opt/php-7.1.24/
./configure \
--prefix=/usr/local/php7 \                            #指定将 PHP 程序的安装路径
--with-apxs2=/usr/local/httpd/bin/apxs \            #指定Apache httpd服务提供的apxs 模块支持程序的文件位置
--with-mysql-sock=/usr/local/mysql/mysql.sock \        #指定mysql 数据库连接文件的存储路径
--with-config-file-path=/usr/local/php7                #设置 PHP 的配置文件 php.ini 将要存放的位置
--with-mysqli \                                        #添加 MySQL 扩展支持 #mysqli扩展技术不仅可以调用MySQL的存储过程、处理MySQL事务,而且还可以使访问数据库工作变得更加稳定
--with-zlib \                                        #支持zlib功能,提供数据压缩
--with-curl \                                        #开启curl扩展功能,实现HTTP的Get下载和Post请求的方法
--with-gd \                                            #激活gd 库的支持
--with-jpeg-dir \                                    #激活jpeg 的支持
--with-png-dir \                                    #激活png 的支持
--with-freetype-dir \
--with-openssl \
--enable-mbstring \                                    #启用多字节字符串功能,以便支持中文等代码
--enable-xml \                                        #开启扩展性标记语言模块
--enable-session \                                    #会话
--enable-ftp \                                        #文本传输协议
--enable-pdo \                                        #函数库
--enable-tokenizer \                                #令牌解释器
--enable-zip

make && make install

#复制模板文件,并进行修改


cp /opt/php-7.1.24/php.ini-development /usr/local/php7/php.ini

vim /usr/local/php7/php.ini

--line 1170--modify
mysqli.default_socket = /usr/local/mysql/mysql.sock


--line 939--uncomment, modify
date.timezone = Asia/Shanghai

 

 

#Optimize the PHP executable program file into the directory of the path environment variable for system identification
ln -s /usr/local/php7/bin/* /usr/local/bin/


#Modify the Apache configuration file to enable Apache to support PHP


vim /etc/httpd.conf 

 

#添加index.php
255 <IfModule dir_module>
256     DirectoryIndex index.html index.php
257 </IfModule>


#Insert the content below line 392 so that Apache can support .php webpage files
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
##Check if the default support module for php7 exists in line 156
LoadModule php7_module modules/libphp7.so

 

---->wq

 #Create and edit php page files
rm -rf /usr/local/httpd/htdocs/index.html
vim /usr/local/httpd/htdocs/index.php
<?php
phpinfo();
?>

systemctl restart httpd.service

2.3 Install Forum

1. Create a database

mysql -u root -p 

mysql> CREATE DATABASE bbs;

 

#Grant the permissions of all tables in the bbs database to bbsuser, and set the password

mysql> GRANT all ON bbs.* TO 'bbsuser'@'%' IDENTIFIED BY 'admin123';

#Refresh the database
mysql>flush privileges; 
 

#Unzip the forum compression package
unzip Discuz_X3.4_SC_UTF8.zip -d /opt/dis


cd /opt/dis
#upload site update package
cp -r upload/ /usr/local/httpd/htdocs/bbs

#Switch forum directory


cd /usr/local/httpd/htdocs/bbs

#Change forum directory owner


chown -R daemon ./config
chown -R daemon ./data
chown -R daemon ./uc_client
chown -R daemon ./uc_server/data
 

 Database server: localhost #Use localhost for local setup, if not on this machine, you must fill in the IP address and port number
Database name: bbs
Database user name: bbsuser
Database password: admin123
Administrator account: admin
Administrator password: admin123

 

Guess you like

Origin blog.csdn.net/weixin_44473708/article/details/131269768