Compile and install LAMP from source code (L=Linux platform, A=Apache front-end, M=mysql back-end, P=php middleware)

1. LAMP

The LAMP architecture is one of the current mature enterprise website application modes. It refers to a set of systems and related software that work together to provide dynamic website services and application development environments. LAMP is an acronym that specifically includes Linux operating system, Apache web server, MySQL database server, PHP (or Perl, Python) web programming language.

1. The role of each component

  • Linux (platform): As the foundation of the 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 platforms such as Windows and UNIX).

  • Apache (Foreground): As the front end of the LAMP architecture, it is a powerful and stable web server program that directly provides users with website access, sending web pages, pictures and other file content.

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

  • PHP/Perl/Python (middleware): As three programming languages ​​for developing dynamic web pages, it is responsible for interpreting dynamic webpage files, communicating with web servers and database systems for collaborative work, and providing a development and operating environment for web applications. Among them, PHP is a widely used open source multi-purpose scripting language, which can be embedded in HTML, and is especially suitable for Web application development.

2. Platform build sequence

  • When building the LAMP platform, the order of installation of each component is Linux, Apache, MySQL, PHP. Among them, there is no strict order requirement for the installation of Apache and MySQL, and the installation of the PHP environment is generally put at the end, responsible for communicating with the web server and the database system to work together.

2. Deployment steps

1. Compile and install Apache httpd service

1. Turn off the firewall, and upload the required software packages to install Apache to the /opt directory
systemctl stop firewalld
systemctl disable firewalld
setenforce 0

httpd-2.4.29.tar.gz
apr-1.6.2.tar.gz
apr-util-1.6.0.tar.gz
#apr component package is used to support cross-platform Apache upper-level applications, provide the underlying interface library, can be effective Reduce the number of concurrent connections, reduce processes and reduce access congestion.

2. The installation environment depends on the package
yum -y install
gcc \ #C language compiler
gcc-c++ \ #C ++'s compiler
make
\ #source code compiler (source code is converted into binary files) pcre \ #pcre is a Perl function Libraries, including perl-compatible regular expression library
pcre-devel \ #perl's interface development kit
expat-devel \ #Used to support website parsing HTML and XML files
perl #perl language compiler


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

3. Configure the software module
cd /opt/
tar zxvf apr-1.6.2.tar.gz
tar zxvf apr-util-1.6.0.tar.gz
tar jxvf httpd-2.4.29.tar.bz2

mv apr-1.6.2 /opt/httpd-2.4.29/srclib/apr
mv apr-util-1.6.0 /opt/httpd-2.4.29/srclib/apr-util

cd /opt/httpd-2.4.29/
./configure –prefix
=/usr/local/httpd \ #Specify the installation path of the httpd service program
–enable-so \ #Enable dynamic loading module support, so that httpd has further extended functions The ability
-enable-rewrite \ #Enable web page address rewriting function for website optimization, anti-leech and catalog migration maintenance
-enable-charset-lite \ Enable character set support to support pages using various character set encodings enable- cgi Enable CGI (Common Gateway Interface) script program support, which is convenient for the external extension of the website to access the application


./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi

4. Compile and install
make #make -j 2 means to open 2 cores and compile at the same time
make install

5. Optimize the configuration file path, and put the executable program file of the httpd service into the directory of the path environment variable for the system to recognize
ln -s /usr/local/httpd/conf/httpd.conf /etc/
ln -s /usr /local/httpd/bin/* /usr/local/bin/

6. Add httpd system service
Method one:
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd #for service service management
chmod +x /etc/init.d/httpd
vi /etc/init .d/httpd
#!/bin/bash #Insert a new line before the first line, add these three lines
chkconfig: 35 85 21 #35 level automatically run 85th start and 21st close
description: Apache is a World Wide Web server

chkconfig --add httpd #Add httpd service to service manager

systemctl start httpd.service

service httpd start

Method 2:
vim /lib/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server #Description
After=network.target #Description of service category
[Service]
Type=forking
#Background operation method PIDFile=/usr/local /httpd/logs/httpd.pid #PID file location
ExecStart=/usr/local/bin/apachectl $OPTIONS
#Start service ExecReload=/bin/kill -HUP $MAINPID #Reload configuration according to PID
[Install]
WantedBy=multi- user.target

systemctl start httpd.service
systemctl enable httpd.service

7. Modify httpd service configuration file
vim /etc/httpd.conf-Line
52-Modify
Listen 192.198.174.128:80 (change to your own ip address)
-Line 197-Uncomment, modify
ServerName www.lmx.com:80

–Line 221 – The default home page storage path
DocumentRoot "/usr/local/httpd/htdocs"
– Line 255 – The default home page file name setting
DirectoryIndex index.html

httpd -t or apachectl -t #Check whether the configuration items of the configuration file are wrong
cat /usr/local/httpd/htdocs/index.html
systemctl restart httpd.service

8. Browser access verification
netstat -anpt | grep 80
echo "192.168.172.128 www.kgc.com" >> /etc/hosts

2. Apache installation

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

Insert picture description here
Insert picture description here

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

3. mysql installation

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

Insert picture description here

4. Compile and install PHP parsing environment

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Open the browser to verify:
Insert picture description here

5. Install Discuz Forum

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

  • Open the browser to install:
  • Click I agree, then turn to the end and click Next
    Insert picture description here

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/LI_MINGXUAN/article/details/113069148