Linux builds LAMP platform and DISCUZ Forum

LAMP introduction and overview


(1) Overview of LAMP platform
LAMP architecture is one of the mature enterprise website application modes at present. It refers to a whole system and related software working together, which can provide dynamic web site services and its application development environment

LAMP is an abbreviation, including Linux operating system, Apache Web server, MySQL database server, PHP (or perl, Python) web programming language

(2) . sequence of building LAMP platform
When building the LAMP platform, the installation sequence of each component is Linux, Apache, MySQL and PHP

There is no strict sequence requirement for the installation of Apache and MySQL, while the installation of PHP environment is generally put at the end, which is responsible for communicating the web server and database system to work together

(3) Advantages of compilation and installation
1. It has a large degree of freedom and can be customized
2. The latest software version can be obtained in time
3. It is generally applicable to most Linux versions and is easy to use all the time

(4) Main functions of components
(platform) Linux: as the basis of LAMP architecture, it provides an operating system to support the Web site, which can provide better stability and compatibility with the other three components (AMP components also support Windows, UNIX and other platforms).

(front desk) Apache: as the front end of LAMP architecture, it is a powerful and stable Web server program. The server directly provides users with website access, sending Web pages, pictures and other file contents.

(background) MySQL: as the back end of LAMP architecture, it is a popular open source relational database system. In enterprise websites, business systems and other applications, various account information, product information, customer information and business data can be stored in MySQL database. Other programs can query and change these information through SQL statements.

(intermediate connection) PHP/Perl/Python: as three programming languages for developing dynamic Web pages, it is responsible for interpreting dynamic Web page files, communicating the Web server and database system to work together, and providing the development and running environment of Web applications. PHP is a widely used open source multi-purpose scripting language, which can be embedded in HTML, especially suitable for Web application development.

Environmental preparation

Turn off firewall and selinux

systemctl stop firewal1d.service
setenforce 0

1, Install Apache

Transfer the software package required to install Apache into the / opt directory

cd /opt/

(I sent the software package to the resource)  

Unzip package

tar xf apr-1.6.2.tar.gz
tar xf apr-util-1.6.0.tar.gz
tar jxf httpd-2.4.29.tar.bz2
ls

Move the apr package to the installation directory and switch to the httpd-2.4.29 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
cd httpd-2.4.29/

  Check it out

Install environment dependent packages

yum -y install \
gcc \                                #C language compiler
gcc-c++ \                            #C + + compiler
make \                               #Source code compiler (source code to binary)
pcre-devel \                         #perl interface development package   
expat-devel \                        #Used to support website parsing HTML and XML files
perl                                 #perl compiler

 

  Compile and install

./configure \
--prefix=/usr/local/httpd \		#Specify the installation path of the httpd service program
--enable-so \					#Enable dynamic loading core module support to enable httpd to further expand its functions
--enable-rewrite \				#Enable the web address rewriting function for website optimization, anti-theft chain and directory migration maintenance
--enable-charset-lite \			#Start character set support to support pages encoded with various character sets
--enable-cgi					#Enable CGI (general Gateway Interface) script program support to enhance the access ability of external extended applications of the website

The results are shown in the figure below  

 

make && make install -j8  (Do not compile with a number larger than the number of kernels)

The results are shown in the figure below

 

 

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

# Chkconfig: 35 85 21 / / 35 level automatic operation 85th startup 21st shutdown
# description: Apache is a World Wide Web server

 

 

  Add httpd to the SERVICE manager and modify the configuration file

chkconfig --add httpd 

 

Change line 52 to your own IP address

vim /usr/local/httpd/conf/httpd.conf
Listen 192.168.241.134:80

  Be sure to delete the # number in line 197

Optimize the configuration file path, and put the executable program file of httpd service into the directory of path environment variable for system identification

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

Then enter to see if there is an error

httpd -t

 

  Start the service and view

service httpd start
ss -ntap |grep "80"

 

After success, you can enter your own IP address in the browser, as shown in the following figure

  The above completes the Apache installation

2, Install MYSQL

Install dependent packages first

yum install -y ncurses-devel autoconf cmake

  Check it out

cd mysql-5.6.26

 

Then compile the installation

cmake  \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \	
-DDEFAULT_CHARSET=utf8 \						#Specifies the character set encoding used by default, such as utf-8
-DDEFAULT_COLLATION=utf8_general_ci \			#Specifies the default character set collation rule to use
-DEXTRA_CHARSETS=all \							#Specifies that other character set encodings are supported
-DSYSCONFIDIR=/etc \							#/There is a default configuration / etc/my.cnf in the / etc / MySQL -- > system
-DMYSQL_DATADIR=/home/mysql/ \					#data file
-DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock		#Specify the communication file to connect to the database (it will be generated when starting the database)

  This time is quite long

 make && make install -j8

then

cp support-files/my-default.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld

Modify the permissions

chmod 755 /etc/init.d/mysqld

Startup and self start

chkconfig --add /etc/init.d/mysqld
chkconfig  mysqld --level 35 on

Put all the commands in / etc/profile

echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile

source /etc/profile
echo $PATH

 

Change a subordinate primary group

useradd -s /sbin/nologin mysql

chown -R mysql:mysql /usr/local/mysql/

Initialize it

/usr/local/mysql/scripts/mysql_install_db \
--user=mysql \
--ldata=/var/lib/mysql \
--basedir=/usr/local/mysql \
--datadir=/home/mysql

Modify profile
 

vim /etc/init.d/mysqld

basedir=/usr/local/mysql     
datadir=/home/mysql

Then start to check whether it is successful

service mysqld start
ss -ntap |grep "3306"

 

//Set password for root account

 mysqladmin -u root -p password "abc123"

 

  Enter the following code to enter mysql, and then enter the password "abc123" set above

mysql -u root -p

  In this way, you have logged in and mysql has been successfully installed

  3, Install PHP

 

yum -y install \
gd \					#Library of image processing
libpng \				#png format picture library
libpng-devel \
pcre \					#The PCRE library supports regular expressions
pcre-devel \			#PCRE devel is the development library required for secondary development using PCRE, and it is also required for compilation and installation
libxml2-devel \			#Parsing xml markup language library
libjpeg-devel			#jpeg format picture library

cd /opt/
ls

 

 

Unzip php and take a look

tar xjvf php-5.6.11.tar.bz2
cd php-5.6.11
ls

 

 

compile

./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 
make && make install -j8

Optimization puts PHP executable program files into the directory of path environment variables for system identification

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

Modify the Apache configuration file to make Apache support PHP   (as shown below)

vim /etc/httpd.conf 

 

 

Create and edit php page files

vim /usr/local/httpd/htdocs/index.php
<?php
phpinfo();
?>

Restart service

service httpd stop 
service httpd start

Test on Web“ http://192.168.241.134/index.php ”(own IP address)

  As shown in the figure, it is built successfully

4, Build a forum

Open database

mysql -u root -p

  Then create a database bbs

mysql> CREATE DATABASE bbs;  //Create a database//

mysql> GRANT all ON bbs.* TO 'bbsuser'@'%' IDENTIFIED BY 'admin123';   //Grant permissions to all tables in the bbs database to bbsuser and set the password. / / all access sources / channels

mysql>flush privileges; //Refresh database//

  Check it out

show databases;

The creation is successful  

Then unzip it

unzip /opt/Discuz_X2.5_SC_UTF8.zip -d /opt/dis

cd /opt/dis

cp -r upload/ /usr/local/httpd/htdocs/bbs

cd /usr/local/httpd/htdocs/bbs

Change the permissions

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

 

Enter website  

http:///192.168.241.134/bbs 

The following interface will succeed, and then install step by step

 

 

Tags: PHP Linux Apache lamp

Posted on Wed, 03 Nov 2021 16:41:30 -0400 by amitdubey2