Construction of AMP architecture Instance Application Forum

1. LAMP overview

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

50: L inux provides operating system support and an environment support
A: Apache provides static page requests
M: MySQL persistence saves data / status information
P: PHP handles dynamic page requests

The construction order is Linux, Apache, MySQL and PHP

2. Installation steps of source code

The source code package of open source software is generally in the form of TarBall, with the extension of ". tar.gz" or ". tar.bz2", which can be decompressed by tar command.

Before compiling the application, you need to enter the source code directory to configure the software installation directory, function selection and other parameters.

The compilation process is mainly to compile the source code file according to the configuration information in the Makefile file to generate binary program modules, dynamic link libraries, executable files, etc.
After the configuration is completed, you only need to execute the "make" command in the source code directory to perform the compilation operation

After compiling, you can execute the "make install" command to copy the software executor, configuration file, help document and other related files to the Linux system, that is, the final "installation" process of the application. It also executes commands in the source code directory.

3. Apache

3.1 general
In 1955, version 1.0 of the Apache service program was released
It comes from a patch server, a famous open source web service software
It is maintained by the Apache Software Foundation (ASF)
The latest name is "Apache HTTP Server"

Main features:
Open source, cross platform application
Support multiple web programming languages
Modular design, stable operation and good safety

```cpp
 Insert code slice here
```[root@localhost ~]# mkdir /LAMP / / create mount point
[root@localhost ~]# mount. CIFS / / 192.168.17.1/lamp / / link sharing
Password for root@//192.168.17.1/LAMP:  
[root@localhost ~]# df -hT                             
file system            type      Capacity used available used% Mount point
/dev/sda5           xfs        32G  3.3G   29G   11% /
devtmpfs            devtmpfs  898M     0  898M    0% /dev
tmpfs               tmpfs     912M     0  912M    0% /dev/shm
tmpfs               tmpfs     912M  9.0M  903M    1% /run
tmpfs               tmpfs     912M     0  912M    0% /sys/fs/cgroup
/dev/sda2           xfs       4.0G   33M  4.0G    1% /home
/dev/sda1           xfs       497M  167M  331M   34% /boot
tmpfs               tmpfs     183M  4.0K  183M    1% /run/user/42
tmpfs               tmpfs     183M   28K  183M    1% /run/user/0
//192.168.17.1/LAMP cifs      293G  111G  183G   38% /LAMP
[root@localhost ~]# cd LAMP
[root@localhost LAMP]# ls
apr-1.6.2.tar.gz           httpd-2.4.29.tar.bz2  mysql-5.6.26.tar.gz
apr-util-1.6.0.tar.gz      httpd-2.4.2.tar.gz    php-5.6.11.tar.bz2
Discuz_X2.5_SC_UTF8.zip    john-1.8.0.tar.gz
extundelete-0.2.4.tar.bz2  LAMP-php5.6.txt
[root@localhost LAMP]# tar zvxf apr-1.6.2.tar.gz -C /opt
[root@localhost LAMP]# tar zvxf apr-util-1.6.0.tar.gz -C /opt
[root@localhost LAMP]# tar jvxf httpd-2.4.29.tar.bz2 -C /opt / / unzip 3 packages to opt
[root@localhost LAMP]# cd /opt
[root@localhost opt]# ls / / move two apr files to httpd
apr-1.6.2  apr-util-1.6.0  httpd-2.4.29  rh
[root@localhost opt]# mv apr-1.6.2 httpd-2.4.29/srclib/apr
[root@localhost opt]# mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util
[root@localhost opt]# ls
httpd-2.4.29  rh
[root@localhost opt]# cd httpd-2.4.29/
[root@localhost httpd-2.4.29]# ls                 
ABOUT_APACHE     CMakeLists.txt  INSTALL         NWGNUmakefile
acinclude.m4     config.layout   InstallBin.dsp  os
Apache-apr2.dsw  configure       LAYOUT          README
Apache.dsw       configure.in    libhttpd.dep    README.cmake
apache_probes.d  docs            libhttpd.dsp    README.platforms
ap.d             emacs-style     libhttpd.mak    ROADMAP
build            httpd.dep       LICENSE         server
BuildAll.dsp     httpd.dsp       Makefile.in     srclib
BuildBin.dsp     httpd.mak       Makefile.win    support
buildconf        httpd.spec      modules         test
CHANGES          include         NOTICE          VERSIONING
[root@localhost httpd-2.4.29]# Yum install - y GCC gcc-c + + PCRE devel PCRE expat devel / / install language pack  
[root@localhost httpd-2.4.29]#./configure \        
--prefix=/usr/local/httpd \
--enable-so --enable-rewrite \
--enable-charset-lite \
--enable-cgi                  //Configuration options such as installation path, enabling character set support, etc
[root@localhost httpd-2.4.29]#make / / compile
[root@localhost httpd-2.4.29]#make install / / install
[root@localhost httpd-2.4.29]#cd /usr/local/httpd/bin / / switch to the installation path
[root@localhost bin]# ls
ab            apu-1-config  dbmmanage    fcgistarter   htdigest  httxt2dbm
apachectl     apxs          envvars      htcacheclean  htpasswd  logresolve
apr-1-config  checkgid      envvars-std  htdbm         httpd     rotatelogs
[root@localhost bin]# cp apachectl /etc/init.d/httpd    
//Copy the Apache VTL script as / etc / init D / httpd, and add chkconfig at the beginning of the file to identify the configuration
[root@localhost bin]# vim /etc/init.d/httpd      
#!/bin/sh
#chkconfig: 35 85 21 / / service identification parameters. Start at levels 3 and 5; The startup and shutdown sequences are 85 and 21 respectively
#description: Apache is a World Wide Web server / / service description
......ellipsis
[root@localhost bin]# chkconfig --add httpd / / add httpd as a system service
[root@localhost bin]# cd ..
[root@localhost httpd]# ls
bin    cgi-bin  error   icons    lib   man     modules
build  conf     htdocs  include  logs  manual
[root@localhost httpd]# cd conf
[root@localhost conf]# ls
extra  httpd.conf  magic  mime.types  original
[root@localhost conf]# pwd
/usr/local/httpd/conf     //If the path is long, you can optimize the path and use ln -s to establish a soft link
[root@localhost conf]# ln -s /usr/local/httpd/conf/httpd.conf /etc/httpd.conf
[root@localhost conf]# ln -s /usr/local/httpd/bin/* /usr/local/bin
[root@localhost conf]# vim /etc/httpd.conf / / enter the configuration file and modify the listening address and other information
[root@localhost conf]# httpd -t
Syntax OK
[root@localhost conf]# service httpd start / / enable service
[root@localhost conf]# netstat -ntap | grep 80
tcp        0      0 192.168.17.132:80       0.0.0.0:*               LISTEN      105929/httpd        
[root@localhost conf]# systemctl stop firewalld.service / / turn off the firewall
[root@localhost conf]# setenforce 0

2.php installation

[root@localhost ~]# yum -y install gd libpng libpng-devel pcre pcre-devel libxml2-devel libjpeg-devel
//Install language pack
[root@localhost LAMP]# tar jvxf php-5.6.11.tar.bz2 -C /opt / / unzip the PHP installation package to opt
[root@localhost LAMP]# cd /opt/php-5.6.11
[root@localhost php-5.6.11]# ./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 
//Proceed/ Configure configure installation path, etc
[root@localhost php-5.6.11]# make && make install
[root@localhost php-5.6.11]# cp php.ini-development /usr/local/php5/php.ini
//Copy master profile
[root@localhost php-5.6.11]# ln -s /usr/local/php5/bin/* /usr/local/bin/
//Create soft link
[root@localhost php-5.6.11]# vim /etc/httpd.conf / / configure the httpd main configuration file
......Omit some contents
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>
......Omit some contents
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz.php .tgz
    AddType application/x-httpd-php .php       //insert
    AddType application/x-httpd-php-source .phps       //insert
 ............Omit content
 [root@localhost php-5.6.11]# vim /usr/local/httpd/htdocs/index.php / / add index PHP and web page test
<?php
phpinfo();
?>
[root@localhost htdocs]# service httpd restart
[root@localhost htdocs]# service mysqld restart
//Restart all services

3. Installation Forum

Enter password: 
mysql> create database bbs;                 //Create bbs Library
Query OK, 1 row affected (0.03 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| bbs                |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.00 sec)

 mysql> grant all on bbs.* to 'bbsuser'@'%' identified by 'admin321';                   //Grant the permissions of all tables in the bbs database to bbsuser and set the password 
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;               // //Refresh database
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
[root@localhost htdocs]# cd /LAMP
[root@localhost LAMP]# ls
apr-1.6.2.tar.gz       Discuz_X2.5_SC_UTF8.zip    httpd-2.4.29.tar.bz2  john-1.8.0.tar.gz  mysql-5.6.26.tar.gz
apr-util-1.6.0.tar.gz  extundelete-0.2.4.tar.bz2  httpd-2.4.2.tar.gz    LAMP.txt           php-5.6.11.tar.bz2
[root@localhost LAMP]# unzip Discuz_X2.5_SC_UTF8.zip -d /opt / / / unzip
[root@localhost LAMP]# cd /opt
[root@localhost opt]# ls
httpd-2.4.29  mysql-5.6.26  php-5.6.11  readme  rh  upload  utility
[root@localhost opt]# cp -r upload/ /usr/local/httpd/htdocs/bbs
[root@localhost bbs]# cd /usr/local/httpd/htdocs/
[root@localhost htdocs]# ls
bbs  index.php

#####At this time, go to the web page 192.168.17.128/bbs to enter the installation wizard
#####The status prompt indicates that the directory does not exist. The reason is that you do not have execution permission
[root@localhost htdocs]# cd bbs
[root@localhost bbs]# ls
admin.php  archiver     cp.php           favicon.ico  home.php   member.php  portal.php  source    uc_client
api        config       crossdomain.xml  forum.php    index.php  misc.php    robots.txt  static    uc_server
api.php    connect.php  data             group.php    install    plugin.php  search.php  template  userapp.php
[root@localhost bbs]# chown -R daemon ./config
[root@localhost bbs]# chown -R daemon ./data
[root@localhost bbs]# chown -R daemon ./uc_client
[root@localhost bbs]# chown -R daemon ./uc_server/data
//After adding permissions, you can install and log in to the website








Keywords: Operation & Maintenance

Added by califdon on Sun, 23 Jan 2022 20:48:10 +0200