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

CentOS 7 source code compilation and installation of LAMP architecture, build Discuz forum (detailed process analysis)

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

Share

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

LAMP platform Overview what is LAMP

At present, the most mature enterprise website application model can provide dynamic Web site application and development environment.

Constituent component

Linux 、 Apache 、 MySQL 、 PHP/Per/Python

Advantages of LAMP

Low cost

Customizable and easy to develop

Easy to use, safe and stable

LAMP source code compilation and installation example 1. Install Apache server

(1) through the Samba service, mount the compressed package needed for the entire LAMP deployment from my host to the "/ mnt/" directory.

Smbclient-L / / 192.168.100.50 / / View the shared files mount.cifs / / 192.168.100.50/LAMP-C7 / mnt/ mount the files we need

(2) unpack the compressed package needed to install Apache to the "/ opt/" directory.

[root@localhost mnt] # tar zxvf apr-1.6.2.tar.gz-C / opt/ Cross-platform required component package. / / omit the component packages required for the process [root@localhost mnt] # tar zxvf apr-util-1.6.0.tar.gz-C / opt/ across platforms. / / omit the process [root@localhost mnt] # tar jxvf httpd-2.4.29.tar.bz2-C / opt/ service pack. / / omit the process

(3) move the directory files of the two packages to the httpd file directory and rename them to apr and apr-util, respectively.

[root@localhost mnt] # cd.. / opt/ [root@localhost opt] # lsapr-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] # lsapr-util-1.6.0 httpd-2.4.29 rh [root@localhost opt] # mv apr-util-1.6.0/ httpd-2.4.29 / srclib/apr-util [root@localhost opt] # lshttpd-2.4.29 rh [root@localhost opt] #

(4) install and compile the Apache service and the related tools needed for the service.

[root@localhost opt] # yum-y install\ > gcc\ > gcc-c++\ > make\ > pcre-devel\ > expat-devel\ > perl. / / omit the process

(5) go to the "/ opt/httpd-2.4.29/" directory and configure the Apache server.

[root@localhost opt] # lshttpd-2.4.29 rh [root@localhost opt] # cd httpd-2.4.29/ [root@localhost httpd-2.4.29] # lsABOUT_APACHE BuildBin.dsp emacs-style LAYOUT NOTICE srclibacinclude.m4 buildconf httpd.dep libhttpd.dep NWGNUmakefile supportApache-apr2.dsw CHANGES httpd.dsp libhttpd.dsp os testApache.dsw CMakeLists.txt httpd.mak libhttpd.mak README VERSIONINGapache_probes.d config.layout httpd.spec LICENSE README.cmakeap.d configure include Makefile.in README.platformsbuild configure.in INSTALL Makefile.win ROADMAPBuildAll.dsp docs InstallBin.dsp modules server [root@localhost httpd-2.4.29] #. / configure\ > -- prefix=/usr/local/httpd\ / / installation path >-- enable-so\ / / enable dynamic loading module support >-- enable-rewrite\ / / enable web address rewriting >-- enable-charset-lite\ / / enable character set support >-- enable-cgi / / enable CGI script support. / / omit the process

(6) compile and install Apache service.

[root@localhost httpd-2.4.29] # make & & make install. / / omit the process (long compilation time and wait patiently) # make compiles to convert the source code into an executable program. Make install for installation.

(7) move the "apachectl" file under the "/ usr/local/httpd/bin/" directory to the "/ etc/init.d/" directory, add the chkconfig recognition configuration at the beginning of the file, and then add it as a standard Linux system service.

[root@localhost httpd-2.4.29] # ls / usr/local/httpd/bin build cgi-bin conf error htdocs icons include lib logs man manual modules [root@localhost httpd-2.4.29] # cp / usr/local/httpd/bin/apachectl / etc/init.d/httpd [root@localhost httpd-2.4.29] # ls / etc/init.d/functions httpd netconsole network README [root@localhost httpd-2.4.29] # # / usr/local/httpd/ directory The purpose of the main subdirectory: # / usr/local/httpd/bin / / to store various executive program files # / usr/local/httpd/conf / / to store various configuration files # / usr/local/httpd/htdocs / / to store web documents # / usr/local/httpd/logs / / to store log files # / usr/local/httpd/modules / / storing various module files # / usr/local/httpd/cgi-bin / / storing various CGI program files [root@localhost httpd-2.4.29] # vim / etc/init.d/httpd #! / bin/sh# chkconfig: 35 85 21 / / Service identification parameters Start at levels 3 and 5: start and shut down in the order of 85 and 2 percent description: Apache is a World Wide Web server / / service description information # # Licensed to the Apache Software Foundation (ASF) under one or more. / / omit part [root@localhost httpd-2.4.29] # chkconfig-- add httpd / / add httpd service as a system service [root@localhost httpd-2.4.29] #

(8) Edit the main configuration file of the httpd service and configure the name of the website. Here, take "www.yun.com:80" as an example. Change the listening address to the IP address of the web server "192.168.52.132 IP 80", port 80. Here, I listen directly to the IP address of the current host. Comment out the command line that listens for ipv6IP addresses.

[root@localhost httpd-2.4.29] # vim / usr/local/httpd/conf/httpd.conf ServerName www.yun.com:80 / / configure the website name Listen 192.168.52.132 IPv4 80 / / configure the IPv4 listening address # Listen 80

(9) optimize the configuration file and the execution path, establish the soft link of the httpd service configuration file in the default configuration file directory "/ etc/" of the system, and establish the soft link of the httpd service execution program under the environment variable directory "/ usr/local/bin/" identified by the system.

[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] #

(10) use "httpd-t" or "apachectl-t" to check the syntax of the configuration content. "Syntax OK" means there are no syntax errors. If there are no errors, let's start the service directly, and then check whether port 80 of TCP can be monitored. Finally, turn off the firewall and enhanced security features.

[root@localhost httpd-2.4.29] # httpd- tSyntax OK [root@localhost httpd-2.4.29] # apachectl-tSyntax OK [root@localhost httpd-2.4.29] # service httpd start / / enable the service [root@localhost httpd-2.4.29] # netstat-ntap | grep 80 / / check whether port 80 tcp of TCP is 0 0192.168.52.132 apachectl 80 0.0.0.0 TCP * LISTEN 34935/httpd [root@localhost httpd-2.4.29] # systemctl stop firewalld.service / / turn off firewall [root@localhost httpd-2.4.29] # setenforce 0 / / turn off enhanced security features [root@localhost httpd-2.4.29] #

(11) use our host to access the built http service.

Second, install MySQL service

(1) install the tools needed to compile the MySQL service and the service.

[root@localhost httpd-2.4.29] # yum install-y ncurses-devel autoconf cmake. / / omit the process

(2) decompress the source code package of the MySQL service to the "/ opt/" directory.

[root@localhost mnt] # cd / mnt/ [root@localhost mnt] # tar zxvf mysql-5.6.26.tar.gz-C / opt/. / / omit the process

(3) enter "opt/mysql-5.6.26/" to configure the service.

[root@localhost mnt] # cd / opt/mysql-5.6.26/ [root@localhost mysql-5.6.26] # lsBUILD config.h.cmake extra libmysqld packaging sql-bench unittestBUILD-CMAKE configure.cmake include libservices plugin sql-common VERSIONclient COPYING INSTALL-SOURCE man README storage viocmake Dbug INSTALL-WIN-SOURCE mysql-test regex strings winCMakeLists.txt Docs libevent mysys scripts support-files zlibcmd-line-utils Doxyfile-perfschema libmysql mysys_ssl sql tests [root@localhost mysql-5.6.26] # cmake\ >-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\ / / specify an Install path >-DDEFAULT_CHARSET=utf8\ / specify default character set >-DDEFAULT_COLLATION=utf8_general_ci\ / / proofreading rules for specifying default character set >-DEXTRA_CHARSETS=all\ / / specify additional supported character sets >-DSYSCONFIDIR= / etc\ / specify the initialization parameter file directory >-DMYSQL_DATADIR=/home/mysql/\ / / specify the data file directory >-DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock / / specify the file to connect to the database. / / omit the process

(4) compile and install MySQL.

[root@localhost mysql-5.6.26] # make&&make install. / / omit the process (long compilation time and wait patiently) # make compiles to convert the source code into an executable program. Make install for installation.

(5) create a configuration file and overwrite the default MySQL service configuration file of the system with the default configuration file included in our source code package.

[root@localhost mysql-5.6.26] # cp support-files/my-default.cnf / etc/my.cnfcp: overwrite "/ etc/my.cnf"? Yes [root@localhost mysql-5.6.26] #

(6) first copy the script file "mysql.server" from the "support-files/" directory to the "/ etc/init.d/" directory, rename it to "mysqld", and add execution permissions to the script file. Then add the MySQL service as a system service and set the environment variable for MySQL.

[root@localhost mysql-5.6.26] # cp support-files/mysql.server / etc/init.d/mysqld / / copy the script file to the / etc/init.d/ directory [root@localhost mysql-5.6.26] # ls-l / etc/init.d/mysqld-rw-r--r--. 1 root root 10870 October 18 17:28 / etc/init.d/mysqld [root@localhost mysql-5.6.26] # chmod + x / etc/init.d/mysqld / / add execution permissions [root@localhost mysql-5.6.26] # ls-l / etc/init.d/mysqld-rwxr-xr-x. 1 root root 10870 October 18 17:28 / etc/init.d/mysqld [root@localhost mysql-5.6.26] # chkconfig-- add / etc/init.d/mysqld / / added as a system service [root@localhost mysql-5.6.26] # chkconfig mysqld-- level 35 on [root@localhost mysql-5.6.26] # echo "PATH=$PATH:/usr/local/mysql/bin" > > / etc/profile / / set the environment variable [root@localhost Mysql-5.6.26] # source / etc/profile / / re-execute Refresh configuration [root@localhost mysql-5.6.26] # echo $PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin [root@localhost mysql-5.6.26] #

(7) create a mysql user and set it to disable login. Then change the owner and group of all the file directories under the "/ usr/local/mysql/" directory to mysql.

[root@localhost mysql-5.6.26] # useradd-s / sbin/nologin mysql/ / add user [root@localhost mysql-5.6.26] # chown-R mysql:mysql / usr/local/mysql/ change owner and group, and-R represents recursive [root@localhost mysql-5.6.26] # ls-1 / usr/local/mysql/ total amount 152drwxr-xr-x. 2 mysql mysql 4096 October 18 17:27 bin-rw-r--r--. 1 mysql mysql 17987 July 15 2015 COPYINGdrwxr-xr-x. 3 mysql mysql 18 October 18 17:27 datadrwxr-xr-x. 2 mysql mysql 55 October 18 17:27 docsdrwxr-xr-x. 3 mysql mysql 4096 October 18 17:27 include-rw-r--r--. 1 mysql mysql 104897 July 15 2015 INSTALL-BINARYdrwxr-xr-x. 3 mysql mysql 4096 October 18 17:27 libdrwxr-xr-x. 4 mysql mysql 30 October 18 17:27 mandrwxr-xr-x. 10 mysql mysql 4096 October 18 17:27 mysql-test-rw-r--r--. 1 mysql mysql 2496 July 15 2015 READMEdrwxr-xr-x. 2 mysql mysql 30 October 18 17:27 scriptsdrwxr-xr-x. 28 mysql mysql 4096 October 18 17:27 sharedrwxr-xr-x. 4 mysql mysql 4096 October 18 17:27 sql-benchdrwxr-xr-x. 2 mysql mysql 136 October 18 17:27 support-files [root@localhost mysql-5.6.26] #

(8) initialize the database.

[root@localhost mysql-5.6.26] # / usr/local/mysql/scripts/mysql_install_db\ >-- user=mysql\ / / manage user >-- ldata=/var/lib/mysql\ / / data directory >-- basedir=/usr/local/mysql\ / / working directory >-- datadir=/ Home/mysql / / data directory. / / omit the process

(9) establish a soft link under the directory "/ home/mysql/" for the file "mysql.sock" to connect to the database, which is easy to use.

[root@localhost mysql-5.6.26] # ln-s / var/lib/mysql/mysql.sock / home/mysql/mysql.sock [root@localhost mysql-5.6.26] #

(10) modify the configuration file and add our working directory and data storage directory.

[root@localhost mysql-5.6.26] # vim / etc/init.d/mysqldbasedir=/usr/local/mysqldatadir=/home/mysql

(11) start the mysql service and check whether TCP protocol port 3306 is listening.

[root@localhost mysql-5.6.26] # service mysqld start / / start the service Starting MySQL. SUCCESS! [root@localhost mysql-5.6.26] # netstat-anpt | grep 3306tcp6 0 0:: 3306: * LISTEN 53852/mysqld [root@localhost mysql-5.6.26] #

(12) modify the administrator password of the mysql database.

[root@localhost mysql-5.6.26] # mysqladmin-u root-p password "abc123" Enter password: / / enter the original password here. The original password is empty, and you can enter Warning: Using a password on the command line interface can be insecure. [root@localhost mysql-5.6.26] #

(13) try to access the mysql database and check whether the database has been built successfully.

[root@localhost mysql-5.6.26] # mysql- u root-p / / Log in to Enter password: / / enter the password Welcome to the MySQL monitor set in the previous step. Commands end with; or\ g.Your MySQL connection id is 2Server version: 5.6.26 Source distributionCopyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.mysql > show databases / / View database +-+ | Database | +-+ | information_schema | | mysql | | performance_schema | | test | +-+ 4 rows in set. Sec) mysql > quit / / exit Bye [root@localhost mysql-5.6.26] # III. Install the PHP service

(1) install the tools needed to compile the PHP service and the service.

[root@localhost mysql-5.6.26] # yum-y install\ > gd\ > libpng\ > libpng-devel\ > pcre\ > pcre-devel\ > libxml2-devel\ > libjpeg-devel. / / omit the process

(2) decompress the source code package of the PHP service to the "/ opt/" directory.

[root@localhost mysql-5.6.26] # cd / mnt/ [root@localhost mnt] # lsapr-1.6.2.tar.gz Discuz_X2.5_SC_UTF8.zip LAMP-php5.6.txt php-5.6.11.tar.bz2apr-util-1.6.0.tar.gz httpd-2.4.29.tar.bz2 mysql-5.6.26.tar.gz [root@localhost mnt] # tar jxvf php-5.6. 11.tar.bz2-C / opt/. / / omit the process

(3) go to the "/ opt/php-5.6.11/" directory and configure the PHP service.

[root@localhost mnt] # cd / opt/php-5.6.11/ [root@localhost php-5.6.11] #. / configure\ >-- prefix=/usr/local/php5\ / / specify the installation path >-- with-gd\ / / Image processing Library >-- with-zlib \ / / compressed function library >-- with-apxs2=/usr/local/httpd/bin/apxs\ / / set the file location of the apxs module support program provided by Apache HTTP Server >-- with-mysql=/usr/local/mysql\ / / set the installation location of the MySQL database service program >-- with -config-file-path=/usr/local/php5\ / / sets the location where the PHP configuration file php.ini will be stored >-- enable-mbstring / / enables the multi-byte string function. / / omit the process

(4) compile and install PHP

[root@localhost php-5.6.11] # make&& make install. / / omit the process (long compilation time and wait patiently) # make compiles to convert the source code into an executable program. Make install for installation.

(5) copy the configuration file in the source package to the "/ usr/local/php5/" directory, rename it to "php.ini", and at the same time establish a soft link to the PHP service execution program under the system-identified environment variable directory "/ usr/local/bin/".

[root@localhost php-5.6.11] # cp php.ini-development / usr/local/php5/php.ini [root@localhost php-5.6.11] # ln-s / usr/local/php5/bin/* / usr/local/bin/ [root@localhost php-5.6.11] #

(6) modify the configuration file "httpd.conf" of httpd service to make httpd server support PHP page parsing function.

[root@localhost php-5.6.11] # vim / etc/httpd.conf DirectoryIndex index.html index.php / / add default home page recognition php format file type AddType application/x-httpd-php .php / / add support for ".php" type web page files AddType application/x-httpd-php-source .phps

(7) restart the httpd service. "restart" is not recommended because some processes in "restart" do not end.

[root@localhost php-5.6.11] # service httpd stop [root@localhost php-5.6.11] # service httpd start [root@localhost php-5.6.11] #

(8) modify the contents of the home file and rename the home file "index.html" to "index.php".

[root@localhost php-5.6.11] # cd / usr/local/httpd/htdocs/ [root@localhost htdocs] # lsindex.html [root@localhost htdocs] # vim index.html [root@localhost htdocs] # mv index.html index.php [root@localhost htdocs] # lsindex.php [root@localhost htdocs] #

(9) use our host to access the http service at this time, and the results are as follows.

IV. Installation Forum

(1) enter MySQL and create a database named "bbs" for the forum.

[root@localhost htdocs] # cd / mnt/ [root@localhost mnt] # lsapr-1.6.2.tar.gz Discuz_X2.5_SC_UTF8.zip LAMP-php5.6.txt php-5.6.11.tar.bz2apr-util-1.6.0.tar.gz httpd-2.4.29.tar.bz2 mysql-5.6.26.tar.gz [root@localhost mnt] # mysql- u root-p / / Log in to Enter password: / / enter the password Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 3Server version: 5.6.26 Source distributionCopyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.mysql > create database bbs; / / create database Query OK, 1 row affected (0.03 sec) mysql > grant all on bbs.* to 'bbsuser'@'%' identified by' admin123'; / / elevate privileges to all tables in the bbs database, create the user "bbsuser" to manage the database, and set the password. " % "indicates that Query OK can be accessed from all terminals, 0 rows affected (0.01 sec) mysql > flush privileges; / / refresh database Query OK, 0 rows affected (0.01 sec) mysql > quit / / exit Bye [root@localhost mnt] #

(2) extract the Discuz package to the "/ opt/" directory and name it "dis".

[root@localhost mnt] # lsapr-1.6.2.tar.gz Discuz_X2.5_SC_UTF8.zip LAMP-php5.6.txt php-5.6.11.tar.bz2apr-util-1.6.0.tar.gz httpd-2.4.29.tar.bz2 mysql-5.6.26.tar.gz [root@localhost mnt] # unzip Discuz_X2.5_SC_UTF8.zip-d / opt/dis

(3) use the "cp-r" command to recursively copy the "upload/" directory to the directory "/ usr/local/httpd/htdocs/" where the httpd service stores the web documents, and name it bbs.

[root@localhost mnt] # cd / opt/ [root@localhost opt] # lsdis httpd-2.4.29 mysql-5.6.26 php-5.6.11 rh [root@localhost opt] # cd dis/ [root@localhost dis] # lsreadme upload utility [root@localhost dis] # cp-r upload/ / usr/local/httpd/htdocs/bbs [root@localhost bbs] #

(4) change the ownership of the following documents or directories to "daemon" respectively.

[root@localhost dis] # cd / usr/local/httpd/htdocs/bbs/ [root@localhost bbs] # lsadmin.php config data home.php misc.php search.php uc_clientapi connect.php favicon.ico index.php plugin.php source uc_serverapi.php cp.php forum.php install portal.php static userapp.phparchiver crossdomain.xml group.php member.php robots.txt template [root@localhost bbs] # chown-R daemon. / config / / change owner [root@localhost bbs] # chown-R daemon. / data / / change owner [root@localhost bbs] # chown-R daemon. / uc_client / / change owner [root@localhost] Bbs] # chown-R daemon. / uc_server/data / / change owner [root@localhost bbs] #

(5) enter http://192.168.52.132/bbs in our host browser, go to the forum installation interface and click I agree.

(6) Click next.

(7) Select a new installation, and click next.

(8) enter the information about the database according to the figure below, and then click next to install the database.

The installation is as shown below:

(9) re-enter http://192.168.52.132/bbs to successfully enter the forum.

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