基于LAMP的Discuz论坛的实现(源码安装)

1. 源码安装httpd

   72  yum -y install gcc gcc-c++ expat-devel pcre-devel
   73  tar -zxf apr-1.7.0.tar.gz 
   74  cd apr-1.7.0
   75  ./configure --prefix=/usr/local/apr
   76  make && make install
   77  cd
   78  tar -zxf apr-util-1.6.1.tar.gz 
   79  cd apr-util-1.6.1
   80  ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
   81  make && make install
   82  cd
   83  tar -zxf httpd-2.4.39.tar.gz 
   84  cd httpd-2.4.39
   85  ./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most
   86  make && make install

2. mysql源码安装

前提:请务必确保本机没有其他版本和其他形式的mysql(不论是yum安装的还是源码安全的) 否则 后期会冲突
其他版本和其他形式的mysql 包括: mysql mariadb MHA PXC percona

    1  yum -y install bison cmake ncurses-devel openssl-devel
    2  tar -zxf mysql-5.6.46.tar.gz 
    3  cd mysql-5.6.46
    4  cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all
    5  make && make install

参数释义:

-DCMAKE_INSTALL_PREFIX  安装路径
-DSYSCONFDIR 指定mysql配置文件目录
-DDEFAULT_CHARSET 设置mysql默认字符集
-DDEFAULT_COLLATION 默认编码格式
-DWITH_EXTRA_CHARSETS 指定mysql可用的其他字符集
[root@localhost mysql-5.6.46]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib
[root@localhost mysql-5.6.46]# ln -s /usr/local/mysql/bin/* /usr/local/bin/
[root@localhost mysql-5.6.46]# useradd -M -s /sbin/nologin mysql
[root@localhost mysql-5.6.46]# chown -R mysql:mysql /usr/local/mysql/
[root@localhost mysql-5.6.46]# pwd
/root/mysql-5.6.46
[root@localhost mysql-5.6.46]# cd support-files/
[root@localhost support-files]# cp my-default.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? y
[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld
[root@localhost support-files]# vim /etc/init.d/mysqld 
 46 basedir=/usr/local/mysql  #mysql安装路径
 47 datadir=/usr/local/mysql/data #数据存放目录
[root@localhost support-files]# chmod +x /etc/init.d/mysqld 

初始化数据库

[root@localhost support-files]# /usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db:
Data::Dumper

[root@localhost support-files]# yum -y install perl-Data-Dumper
[root@localhost support-files]# /usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
Installing MySQL system tables...2020-05-14 16:22:13 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-05-14 16:22:13 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2020-05-14 16:22:13 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.46) starting as process 23957 ...
2020-05-14 16:22:13 23957 [Note] InnoDB: Using atomics to ref count buffer pool pages
2020-05-14 16:22:13 23957 [Note] InnoDB: The InnoDB memory heap is disabled
2020-05-14 16:22:13 23957 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-05-14 16:22:13 23957 [Note] InnoDB: Memory barrier is not used
2020-05-14 16:22:13 23957 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-05-14 16:22:13 23957 [Note] InnoDB: Using CPU crc32 instructions
2020-05-14 16:22:13 23957 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2020-05-14 16:22:13 23957 [Note] InnoDB: Completed initialization of buffer pool
2020-05-14 16:22:13 23957 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2020-05-14 16:22:13 23957 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2020-05-14 16:22:13 23957 [Note] InnoDB: Database physically writes the file full: wait...
2020-05-14 16:22:13 23957 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2020-05-14 16:22:13 23957 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2020-05-14 16:22:14 23957 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2020-05-14 16:22:14 23957 [Warning] InnoDB: New log files created, LSN=45781
2020-05-14 16:22:14 23957 [Note] InnoDB: Doublewrite buffer not found: creating new
2020-05-14 16:22:14 23957 [Note] InnoDB: Doublewrite buffer created
2020-05-14 16:22:14 23957 [Note] InnoDB: 128 rollback segment(s) are active.
2020-05-14 16:22:14 23957 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-05-14 16:22:14 23957 [Note] InnoDB: Foreign key constraint system tables created
2020-05-14 16:22:14 23957 [Note] InnoDB: Creating tablespace and datafile system tables.
2020-05-14 16:22:14 23957 [Note] InnoDB: Tablespace and datafile system tables created.
2020-05-14 16:22:14 23957 [Note] InnoDB: Waiting for purge to start
2020-05-14 16:22:14 23957 [Note] InnoDB: 5.6.46 started; log sequence number 0
2020-05-14 16:22:14 23957 [Note] RSA private key file not found: /usr/local/mysql/data//private_key.pem. Some authentication plugins will not work.
2020-05-14 16:22:14 23957 [Note] RSA public key file not found: /usr/local/mysql/data//public_key.pem. Some authentication plugins will not work.
2020-05-14 16:22:14 23957 [Note] Binlog end
2020-05-14 16:22:14 23957 [Note] InnoDB: FTS optimize thread exiting.
2020-05-14 16:22:14 23957 [Note] InnoDB: Starting shutdown...
2020-05-14 16:22:15 23957 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2020-05-14 16:22:15 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-05-14 16:22:15 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2020-05-14 16:22:15 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.46) starting as process 23979 ...
2020-05-14 16:22:15 23979 [Note] InnoDB: Using atomics to ref count buffer pool pages
2020-05-14 16:22:15 23979 [Note] InnoDB: The InnoDB memory heap is disabled
2020-05-14 16:22:15 23979 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-05-14 16:22:15 23979 [Note] InnoDB: Memory barrier is not used
2020-05-14 16:22:15 23979 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-05-14 16:22:15 23979 [Note] InnoDB: Using CPU crc32 instructions
2020-05-14 16:22:15 23979 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2020-05-14 16:22:15 23979 [Note] InnoDB: Completed initialization of buffer pool
2020-05-14 16:22:15 23979 [Note] InnoDB: Highest supported file format is Barracuda.
2020-05-14 16:22:15 23979 [Note] InnoDB: 128 rollback segment(s) are active.
2020-05-14 16:22:15 23979 [Note] InnoDB: 5.6.46 started; log sequence number 1625977
2020-05-14 16:22:15 23979 [Note] RSA private key file not found: /usr/local/mysql/data//private_key.pem. Some authentication plugins will not work.
2020-05-14 16:22:15 23979 [Note] RSA public key file not found: /usr/local/mysql/data//public_key.pem. Some authentication plugins will not work.
2020-05-14 16:22:15 23979 [Note] Binlog end
2020-05-14 16:22:15 23979 [Note] InnoDB: FTS optimize thread exiting.
2020-05-14 16:22:15 23979 [Note] InnoDB: Starting shutdown...
2020-05-14 16:22:17 23979 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

  /usr/local/mysql/bin/mysqladmin -u root password 'new-password'
  /usr/local/mysql/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:

  /usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

  cd . ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

  cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

WARNING: Found existing config file /usr/local/mysql/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /usr/local/mysql/my-new.cnf,
please compare it with your file and take the changes you need.

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

启动并设置mysql的登陆密码

[root@localhost support-files]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
. SUCCESS! 
[root@localhost support-files]# netstat -anput | grep LISTEN | grep 3306
tcp6       0      0 :::3306                 :::*                    LISTEN      24121/mysqld 

[root@localhost support-files]# mysqladmin -uroot password 123456
Warning: Using a password on the command line interface can be insecure.

[root@localhost support-files]# mysql -uroot -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.46 Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit
Bye

3. php的源码安装

  151  yum -y install gd libxml2-devel libjpeg-devel libpng-devel
  152  tar -zxf php-7.2.0.tar.gz 
  153  cd php-7.2.0
  154  ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/httpd/bin/apxs --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring
  155  make && make install
  156  cp php.ini-development /usr/local/php/php.ini

4. 整合httpd与php

[root@localhost ~]# vim /usr/local/httpd/conf/httpd.conf
389     AddType application/x-gzip .gz .tgz #在此行下添加一行内容
390     AddType application/x-httpd-php .php

252     DirectoryIndex index.php index.html

5. 编辑php页面 进行验证

[root@localhost ~]# cd /usr/local/httpd/htdocs/
[root@localhost htdocs]# vim index1.php

[root@localhost htdocs]# vim index2.php

查看httpd和mysql是否启动 如果已经启动 重启服务(httpd重启 建议先stop 再start) 如果没有启动 直接启动服务

[root@localhost htdocs]# netstat -anput | grep LISTEN | grep 80
[root@localhost htdocs]# netstat -anput | grep LISTEN | grep 3306

如上 两个都没启动 直接启动即可
[root@localhost htdocs]# /usr/local/httpd/bin/apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
[root@localhost htdocs]# /etc/init.d/mysqld start
Starting MySQL... SUCCESS! 

查看两个服务是否启动成功
[root@localhost htdocs]# netstat -anput | grep LISTEN | grep 80  
tcp6       0      0 :::80                   :::*                    LISTEN      113358/httpd        
[root@localhost htdocs]# netstat -anput | grep LISTEN | grep 3306          
tcp6       0      0 :::3306                 :::*                    LISTEN      113557/mysqld 

访问验证:

firefox http://192.168.20.133/index1.php

基于LAMP的Discuz论坛的实现(源码安装)_第1张图片

firefox http://192.168.20.133/index2.php

基于LAMP的Discuz论坛的实现(源码安装)_第2张图片

如上 验证两个都OK 就可以部署网络应用了

6. 部署Discuz论坛

[root@localhost ~]# ls ComsenzDiscuz-DiscuzX-master.zip 
ComsenzDiscuz-DiscuzX-master.zip
[root@localhost ~]# unzip ComsenzDiscuz-DiscuzX-master.zip 
[root@localhost ~]# cp -r DiscuzX/upload/* /usr/local/httpd/htdocs/
[root@localhost ~]# chmod -R 777 /usr/local/httpd/htdocs/

访问以下url 进行论坛安装
firefox http://192.168.20.133/install/index.php

基于LAMP的Discuz论坛的实现(源码安装)_第3张图片
基于LAMP的Discuz论坛的实现(源码安装)_第4张图片
基于LAMP的Discuz论坛的实现(源码安装)_第5张图片
基于LAMP的Discuz论坛的实现(源码安装)_第6张图片
基于LAMP的Discuz论坛的实现(源码安装)_第7张图片

基于LAMP的Discuz论坛的实现(源码安装)_第8张图片

基于LAMP的Discuz论坛的实现(源码安装)_第9张图片

7. 安装Discuz的异常处理

基于LAMP的Discuz论坛的实现(源码安装)_第10张图片
如上图 如果提醒已安装 可以删除安装锁 重新安装

[root@localhost ~]# rm -rf /usr/local/httpd/htdocs/data/install.lock

你可能感兴趣的:(linux)