Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

LAMP framework to build Discuz forum, pure practical information! Everybody's watching!

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Lab catalog:

I. the concept of LAMP architecture

II. Installation and configuration of LAMP structure

2-1 manually compile and install the http service

2-2 compile and install mysql database manually

2-3 compile and install PHP tools manually

Install Discuz Forum (Open Source Forum)

IV. Small welfare

I. the concept of LAMP architecture

LAMP refers to a group of free software acronyms that are usually used together to run dynamic websites or servers:

Linux, operating system Apache, web server MariaDB or MySQL, database management system (or database server) PHP, Perl or Python, scripting language

It is the most mature enterprise website application mode at present, which can provide dynamic Web site application and development environment.

The source packages of all the services required for this experiment have been uploaded to the network disk, and you can copy and use them (all open source software).

Link: https://pan.baidu.com/s/1H_k-1lXH4Pjkrsl2EN4CNA extraction code: r0pi

2. Installation and configuration of LAMP structure 2-1 manual compilation and installation of http service

Use mount.cifs to mount the entire software directory into Linux or copy the entire directory directly into Linux. (the mount point of this experiment is / mnt/ directory)

Install the Apache service

Three software packages required to extract the Apache service

[root@localhost ~] # cd / mnt [root@localhost mnt] # tar xf apr-1.6.2.tar.gz-C / opt / / extract the package to the opt directory [root@localhost mnt] # tar xf apr-util-1.6.0.tar.gz-C / opt [root@localhost mnt] # tar xf httpd-2.4.29.tar.gz-C / opt

Move the apr and apr-util plug-ins to the specified location of httpd

[root@localhost mnt] # mv apr-1.6.2 httpd-2.4.29/srclib/apr [root@localhost mnt] # mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util

After all moves, begin to install the required environment package (\ for newline display)

[root@localhost mnt] # yum-y install\ gcc\ gcc-c++\ make\ pcre-devel\ expat-devel\ perl

Among them

Compilers of gcc, gcc-c++:c and C++

Make: compilation tool

Development and compiler of pcre and pcre-devel:pcre languages

Expat-devel: enables newly created websites to parse files in xml format

After the installation, move to the http package and compile the "configure" file manually (be sure to go into the package! )

[root@localhost mnt] # cd httpd-2.4.29 [root@localhost httpd-2.4.29] #. / configure\-- prefix=/usr/local/httpd\-- enable-so\-- enable-rewrite\-- enable-charset-lite\-- enable-cgi [root@localhost httpd-2.4.29] # make & & make install / / compile and install (you need to wait for some time)

Where:

-- prefix: the path followed by the custom installation

-- enable-so: open the core module

-- enable-rewrite: enable rewriting function

-- enable-charset-lite: enable character set support

-- enable-cgi: enables the universal gateway interface (cgj is an encoding format)

After completion, start to add startup scripts to facilitate the system to better control the opening and closing of services, and easily add httpd to the SERVICE manager.

[root@localhost httpd-2.4.29] # cp / usr/local/httpd/bin/apachectl / etc/init.d/httpd// add startup script [root@localhost httpd-2.4.29] # chkconfig-- add httpd// adds httpd to SERVICE Manager

Then go to the configuration file of the Apache service and modify it as shown below

Finally, for ease of management, we can soft-link the configuration file with the startup-related file (not to add it), turn off the firewall, and start the Apache service.

[root@localhost httpd-2.4.29] # ln-s / usr/local/httpd/conf/httpd.conf / etc/ [root@localhost httpd-2.4.29] # ln-s / usr/local/httpd/bin/* / usr/local/bin/ [root@localhost httpd-2.4.29] # systemctl stop firewalld.service [root@localhost httpd-2.4.29] # setenforce 0 [root@localhost httpd-2.4.29] # service httpd start2-2 manually compile and install mysql database

Install the Mysql database

[root@localhost ~] # yum install-y ncurses-devel autoconf cmake / / transfer environment package and cmake compiler [root@localhost ~] # cd / mnt/ [root@localhost mnt] # tar xzvf mysql-5.6.26.tar.gz-C / opt / / decompress the mysql source package

Compile the source package (\ to wrap)

[root@localhost mnt] # cd / opt/mysql-5.6.26 [root@localhost mysql-5.6.26] # cmake\ / / compile the source package-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\-DDEFAULT_CHARSET=utf8\-DDEFAULT_COLLATION=utf8_general_ci\-DEXTRA_CHARSETS=all\-DSYSCONFIDIR=/etc\-DMYSQL_DATADIR=/home/mysql/\-DMYSQL_UNIX_ADDR=/home/mysql/ mysql.sock [root @ localhost Mysql-5.6.26] # make & & make install / / compile installation

Among them

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql: specify the database installation directory

-DDEFAULT_CHARSET=utf8: specifies the character set

-DDEFAULT_COLLATION=utf8_general_ci: specifies the default character set

-DEXTRA_CHARSETS=all: specifies the extended character set

-DSYSCONFIDIR=/etc: specify the configuration file directory

-DMYSQL_DATADIR=/home/mysql/: specify the location of data files in the database

-DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock: define the sock file

Configure MySQL

[root@localhost mysql-5.6.26] # cp support-files/my-default.cnf / etc/my.cnf [root@localhost mysql-5.6.26] # cp support-files/mysql.server / etc/init.d/mysqld [root@localhost mysql-5.6.26] # chmod 755 / etc/init.d/mysqld / / Grant execution permission [root@localhost mysql-5.6.26] # chkconfig-- add / etc/init.d/mysqld / / add database services to the manager [root@localhost mysql-5.6.26] # chkconfig mysqld-- level 35 on / / Open the database run level 5 [root@localhost mysql-5.6.26] # echo "PATH=$PATH:/usr/local/mysql/bin" > > / etc/profile / / enable the database command to the system environment variable [root@localhost mysql-5.6.26] # source / etc/ Profile / / enable system environment variable [root@localhost mysql-5.6.26] # echo $PATH / / View system environment variable [root@localhost mysql-5.6.26] # useradd-s / sbin/nologin mysql / / create mysql program user Prohibited from logging in [root@localhost mysql-5.6.26] # chown-R mysql:mysql / usr/local/mysql/ to give rights to all users under / usr/local/mysql/ directory [root@localhost mysql-5.6.26] # / usr/local/mysql/scripts/mysql_install_db\-- user=mysql\-- ldata=/var/lib/mysql\-- basedir=/usr/local/mysql\-- datadir=/home/mysql / / initialize the database And specify the user data information to the specified directory [root@localhost mysql-5.6.26] # vim / etc/init.d/mysqld / / Edit the database configuration file basedir=/usr/local/mysql / / specify the installation path of the database itself datadir=/home/mysql / / specify the location where the database is stored

Open the database and set the login password

[root@localhost mysql-5.6.26] # service mysqld start [root@localhost mysql-5.6.26] # mysqladmin-u root-p password "123123" / / set password for root account 2-3 compile and install PHP tool manually

Install the environment package and extract the source package

[root@localhost mysql-5.6.26] # cd / mnt/ [root@localhost mnt] # yum-y install\ gd\ libpng\ libpng-devel\ pcre\ pcre-devel\ libxml2-devel\ libjpeg-devel [root@localhost mnt] # tar xjvf php-5.6.11.tar.bz2-C / opt

Among them

Gd: image processing tool

Libxml2-devel: supports parsing, markup language

Libjpeg-devel: supports jpg image format

Compile and install the PHP tool

[root@localhost mnt] # 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 [root@localhost php-5.6.11] # Make & & make install [root@localhost php-5.6.11] # cp php.ini-development / usr/local/php5/php.ini / / overwrite the initialization file Note the path [root@localhost php-5.6.11] # ln-s / usr/local/php5/bin/* / usr/local/bin/ establish a soft link to the PHP command [root@localhost php-5.6.11] # ln-s / usr/local/php5/sbin/* / usr/local/sbin/

Among them

-- prefix=/usr/local/php5: specify the installation path for PHP tools

-- with-gd: gd library for graphical processing

-- with-zlib: function library

-- with-apxs2=/usr/local/httpd/bin/apxs: used to provide functional modules for apache

-- with-mysql=/usr/local/mysql: associate the installed database

-- with-config-file-path=/usr/local/php5: associate PHP configuration

-- enable-mbstring: load functional modules

Modify the apache configuration file and set up the PHP home page

[root@localhost php-5.6.11] # vim / etc/httpd.conf locate the last line by G, and add AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps search DirectoryIndex Change to DirectoryIndex index.php index.htmlwq save exit [root@localhost php-5.6.11] # vim / usr/local/httpd/htdocs/index.php / / PHP home page press I to add wq save exit [root@localhost php-5.6.11] # service httpd restart / / restart httpd service

Verify the PHP web page

Enter 192.168.116.131/index.php in the browser and the following web page will appear as a success

Install Discuz Forum (Open Source Forum)

Extract the forum source code and place it in the http site

[root@localhost php-5.6.11] # cd / mnt [root@localhost mnt] # unzip Discuz_X2.5_SC_UTF8.zip-d / opt/Discuz [root@localhost mnt] # cp-r / opt/Discuz/upload/ / usr/local/httpd/htdocs/bbs / / on the http site

Set up the database related to bbs and set the administrator password

[root@localhost mnt] # mysql-u root-p / / enter the MySQL database with the password of mysql > create database bbs; / / create a subdatabase named bbs in the database mysql > GRANT all ON bbs.* TO 'zhy'@'%' IDENTIFIED BY' 123123; / / A pair of zhy users raise rights and set the password as 123123mysql > flush privileges / / Refresh database mysql > quit [root@localhost mnt] # cd / usr/local/httpd/htdocs/bbs/ enter the bbs directory [root@localhost bbs] # chown-R daemon. / config/ [root@localhost bbs] # chown-R daemon. / data/ [root@localhost bbs] # chown-R daemon. / uc_client/data/cache/ [root @ localhost bbs] # chown-R daemon. / uc_server/data/// elevates privileges for program users

Complete the installation of the forum

Enter 192.168.116.131/bbs in the browser to enter the installation process

The installation is then complete.

IV. Welfare at the end of the article

Does it bother you to see here? Is there a fully automatic, interaction-free installation process that can be carried out with one click?

Of course the answer is yes!

The Shell script is as follows: #! / bin/bash# automatically builds the LAMP schema with one button (please use source or use. Command execution) # Database default password is 12312remote mount df-hT | grep-o "cifs" if [$?-ne 0]; thenecho "Start mount" yum install expect-yread-p "enter the host IP:" gongip/usr/bin/expect / etc/profilesource / etc/profileecho $PATH | grep-o "mysql" if [$?-eq 0] Then echo "add success" else echo "failed" exit 1fiuseradd-s / sbin/nologin mysqlchown-R mysql:mysql / usr/local/mysql//usr/local/mysql/scripts/mysql_install_db\-- user=mysql\-- ldata=/var/lib/mysql\-- basedir=/usr/local/mysql\-- datadir=/home/mysqlsed-I-e '47d'-e' 46d'-e '45abasedir=/usr/local/mysql\ ndatadir=/home/mysql' / Etc/init.d/mysqldservice mysqld startnetstat-ntuap | grep mysqldif [$?-eq 0] Then echo Mysql database startup else echo startup failed exit 1 fi/usr/bin/expect

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report