在Linux中安装MYSQL并创建一个论坛
2021/11/3 19:11:58
本文主要是介绍在Linux中安装MYSQL并创建一个论坛,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
文章目录
- 在Linux中安装MYSQL并创建一个论坛
- 编译make
- 编译阿帕奇
- 安装MYSQL
- 安装PHP
- 安装论坛
在Linux中安装MYSQL并创建一个论坛
[root@localhost ~]# cd /opt/ [root@localhost opt]# rm -rf * #移动到/opt目录下清空所有文件
将这6个压缩包导入/opt
链接:https://pan.baidu.com/s/19ZSK1zsfy50gBWu_2q6c6A
提取码:1103
#请保证计算机有至少60G的容量,因为安装会占用大量的indo号,mysql可能安装不上
编译make
#将这些压缩包解压到当前文件夹 [root@localhost opt]# tar zxvf apr-1.6.2.tar.gz [root@localhost opt]# ls apr-1.6.2 apr-util-1.6.0.tar.gz httpd-2.4.29.tar.bz2 php-5.6.11.tar.bz2 apr-1.6.2.tar.gz Discuz_X2.5_SC_UTF8.zip mysql-5.6.26.tar.gz [root@localhost opt]# tar zxvf apr-util-1.6.0.tar.gz [root@localhost opt]# ls apr-1.6.2 apr-util-1.6.0 Discuz_X2.5_SC_UTF8.zip mysql-5.6.26.tar.gz apr-1.6.2.tar.gz apr-util-1.6.0.tar.gz httpd-2.4.29.tar.bz2 php-5.6.11.tar.bz2 [root@localhost opt]# tar jxf httpd-2.4.29.tar.bz2 [root@localhost opt]# ls apr-1.6.2 apr-util-1.6.0.tar.gz httpd-2.4.29.tar.bz2 apr-1.6.2.tar.gz Discuz_X2.5_SC_UTF8.zip mysql-5.6.26.tar.gz apr-util-1.6.0 httpd-2.4.29 php-5.6.11.tar.bz2 #将前两个压缩出来的文件移动到 httpd-2.4.29/srclib 目录下并改名 [root@localhost opt]# ls httpd-2.4.29/srclib/ Makefile.in [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/srclib/ apr apr-util Makefile.in #移动到这个目录下 [root@localhost opt]# cd httpd-2.4.29/ [root@localhost httpd-2.4.29]# ls ABOUT_APACHE buildconf httpd.dsp libhttpd.mak README.cmake acinclude.m4 CHANGES httpd.mak LICENSE README.platforms Apache-apr2.dsw CMakeLists.txt httpd.spec Makefile.in ROADMAP Apache.dsw config.layout include Makefile.win server apache_probes.d configure INSTALL modules srclib ap.d configure.in InstallBin.dsp NOTICE support build docs LAYOUT NWGNUmakefile test BuildAll.dsp emacs-style libhttpd.dep os VERSIONING BuildBin.dsp httpd.dep libhttpd.dsp README #安装一些工具 [root@localhost httpd-2.4.29]# yum -y install \ > gcc \ > gcc-c++ \ > make \ > pcre-devel \ > expat-devel \ > perl [root@localhost httpd-2.4.29]# ./configure \ > --prefix=/usr/local/httpd \ > --enable-so \ > --enable-rewrite \ > --enable-charset-lite \ > --enable-cgi #编译make,注:-j8是指我用8颗内核运行这个安装程序,不能比自己电脑的内核高 [root@localhost httpd-2.4.29]# make && make install -j8
编译阿帕奇
#移动到这条目录下的bin中 [root@localhost httpd-2.4.29]# cd /usr/local/httpd/ [root@localhost httpd]# ls bin cgi-bin error icons lib man modules build conf htdocs include logs manual [root@localhost httpd]# cd bin/ [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 #将bin中的apachectl复制到指定目录下 [root@localhost bin]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd #编辑这个脚本,将这两段插入 [root@localhost bin]# vim /etc/init.d/httpd # chkconfig: 35 85 21 //35级别自动运行 第85个启动 第21个关闭 # description: Apache is a World Wide Web server 这是注释 #将httpd加入到SERVICE管理器 [root@localhost bin]# chkconfig --add httpd [root@localhost bin]# vim /usr/local/httpd/conf/httpd.conf #编辑第51行,设置自己的IP地址,为了监听自己 Listen 192.168.254.10:80 #编辑第197行,写一个本机的域名地址,名字自起 ServerName www.rui.com:80 #如果不知道自己有没有做好,可以使用以下两条命令检查一下语法 [root@localhost bin]# httpd -t 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 Syntax OK [root@localhost bin]# apachectl -t 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 Syntax OK #如果出现以上现象按如下操作 [root@localhost bin]# vim /etc/httpd/conf/httpd.conf 找到这条 #ServerName www.example.com:80 改成这条 ServerName localhost:80 #再试一次,如果有问题则重启httpd:systemctl restart httpd [root@localhost bin]# apachectl -t Syntax OK [root@localhost bin]# httpd -t Syntax OK #做两条软链接,方便直接使用 [root@localhost bin]# ln -s /usr/local/httpd/conf/httpd.conf /etc/ [root@localhost bin]# ln -s /usr/local/httpd/bin/* /usr/local/bin/ #注意关闭防火墙 [root@localhost bin]# systemctl stop firewalld.service [root@localhost bin]# setenforce 0 [root@localhost bin]# service httpd start #使用grep过滤一下“80” [root@localhost bin]# ss -ntap |grep "80" LISTEN 0 128 192.168.254.10:80 *:* users:(("httpd",pid=88744,fd=3),("httpd",pid=88743,fd=3),("httpd",pid=88742,fd=3),("httpd",pid=88741,fd=3)) #至此阿帕奇编译完成
安装MYSQL
[root@localhost opt]# yum install -y ncurses-devel autoconf cmake [root@localhost opt]# tar zxvf mysql-5.6.26.tar.gz [root@localhost opt]# ls apr-1.6.2.tar.gz httpd-2.4.29 mysql-5.6.26.tar.gz apr-util-1.6.0.tar.gz httpd-2.4.29.tar.bz2 php-5.6.11.tar.bz2 Discuz_X2.5_SC_UTF8.zip mysql-5.6.26 [root@localhost opt]# cd mysql-5.6.26/ [root@localhost mysql-5.6.26]# ls BUILD dbug libmysqld regex unittest BUILD-CMAKE Docs libservices scripts VERSION client Doxyfile-perfschema man sql vio #cmake extra mysql-test sql-bench win CMakeLists.txt include mysys sql-common zlib cmd-line-utils INSTALL-SOURCE mysys_ssl storage config.h.cmake INSTALL-WIN-SOURCE packaging strings configure.cmake libevent plugin support-files COPYING libmysql README tests #cmake必须要有 [root@localhost mysql-5.6.26]# cmake \ > -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 -j8 #开始安装,过程漫长 [root@localhost mysql-5.6.26]# ls BUILD CTestTestfile.cmake make_dist.cmake sql-common BUILD-CMAKE dbug Makefile storage client Docs man strings cmake Doxyfile-perfschema mysql-test #support-files要有这个 CMakeCache.txt extra mysys tests CMakeFiles include mysys_ssl unittest cmake_install.cmake info_macros.cmake packaging VERSION CMakeLists.txt install_manifest.txt plugin VERSION.dep cmd-line-utils INSTALL-SOURCE README vio config.h.cmake INSTALL-WIN-SOURCE regex win configure.cmake libevent scripts zlib COPYING libmysql source_downloads CPackConfig.cmake libmysqld sql CPackSourceConfig.cmake libservices sql-bench [root@localhost mysql-5.6.26]# cp support-files/my-default.cnf /etc/my.cnf cp:是否覆盖"/etc/my.cnf"? y #将这个文件下的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 #再添加命令 [root@localhost mysql-5.6.26]# chkconfig --add /etc/init.d/mysqld #设置运行级别3和5的时候开机自启 [root@localhost mysql-5.6.26]# chkconfig mysqld --level 35 on #意思是将/usr/local/mysql/bin路径下的命令全部放进/etc/profile里 [root@localhost mysql-5.6.26]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile [root@localhost mysql-5.6.26]# source /etc/profile [root@localhost mysql-5.6.26]# echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin #新建一个mysql用户 [root@localhost mysql-5.6.26]# useradd -s /sbin/nologin mysql [root@localhost mysql-5.6.26]# useradd -s /sbin/nologin mysql useradd:用户“mysql”已存在 #再更改一下这个用户的属组属主 [root@localhost mysql-5.6.26]# chown -R mysql:mysql /usr/local/mysql/ [root@localhost mysql-5.6.26]# ll -d /usr/local/mysql/ drwxr-xr-x. 13 mysql mysql 213 11月 3 13:45 /usr/local/mysql/ #初始化一下这些配置 [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 ln -s /var/lib/mysql/mysql.sock /home/mysql/mysql.sock #在第46和第47行修改 [root@localhost mysql-5.6.26]# vim /etc/init.d/mysqld 46 basedir=/usr/local/mysql 47 datadir=/home/mysql [root@localhost mysql-5.6.26]# service mysqld start Starting MySQL. SUCCESS! [root@localhost mysql-5.6.26]# ss -ntap |grep "3306" LISTEN 0 80 :::3306 :::* users:(("mysqld",pid=104623,fd=10)) #给root用户设置密码 [root@localhost mysql-5.6.26]# mysqladmin -u root -p password "admin123" Enter password: #这里直接回车 Warning: Using a password on the command line interface can be insecure. [root@localhost mysql-5.6.26]# mysql -u root -p Enter password: #这里输入“admin123”,就是上面写的 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.6.26 Source distribution Copyright (c) 2000, 2015, 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> show databases; #这里只是一个空表,注意书写格式,“;”结尾 +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+ 4 rows in set (0.00 sec) mysql> exit #输入exit退出 Bye
安装PHP
[root@localhost mysql-5.6.26]# yum -y install \ > gd \ > libpng \ > libpng-devel \ > pcre \ > pcre-devel \ > libxml2-devel \ > libjpeg-devel [root@localhost opt]# tar jxf php-5.6.11.tar.bz2 [root@localhost opt]# ls apr-1.6.2.tar.gz httpd-2.4.29 mysql-5.6.26.tar.gz apr-util-1.6.0.tar.gz httpd-2.4.29.tar.bz2 php-5.6.11 Discuz_X2.5_SC_UTF8.zip mysql-5.6.26 php-5.6.11.tar.bz2 [root@localhost opt]# cd php-5.6.11/ [root@localhost php-5.6.11]# ls acinclude.m4 Makefile.frag README.SELF-CONTAINED-EXTENSIONS aclocal.m4 Makefile.gcov README.STREAMS build Makefile.global README.SUBMITTING_PATCH buildconf makerpm README.TESTING buildconf.bat missing README.TESTING2 CODING_STANDARDS mkinstalldirs README.UNIX-BUILD-SYSTEM config.guess netware README.WIN32-BUILD-SYSTEM config.sub NEWS run-tests.php configure pear sapi configure.in php5.spec.in scripts CREDITS php.gif server-tests-config.php ext php.ini-development server-tests.php EXTENSIONS php.ini-production snapshot footer README.EXT_SKEL stamp-h.in generated_lists README.GIT-RULES stub.c genfiles README.input_filter tests header README.MAILINGLIST_RULES travis INSTALL README.md TSRM install-sh README.namespaces UPGRADING LICENSE README.NEW-OUTPUT-API UPGRADING.INTERNALS ltmain.sh README.PARAMETER_PARSING_API vcsclean main README.REDIST.BINS win32 makedist README.RELEASE_PROCESS Zend [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 #安装过程漫长 #去bin下看看可执行文件 [root@localhost php-5.6.11]# cd /usr/local/php5/ [root@localhost php5]# ls bin etc include lib php [root@localhost php5]# cd bin [root@localhost bin]# ls pear peardev pecl phar phar.phar php php-cgi php-config phpize [root@localhost bin]# cd .. [root@localhost php5]# #做一个软链接 [root@localhost php5]# ln -s /usr/local/php5/bin/* /usr/local/bin/ [root@localhost php5]# vim /etc/httpd.conf #在合适的位置插入文字 256 DirectoryIndex index.html index.php 394 AddType application/x-httpd-php .php 395 AddType application/x-httpd-php-source .phps #编辑一个网页 [root@localhost php5]# vim /usr/local/httpd/htdocs/index.php <?php phpinfo(); ?> #重启一下,不要使用restart [root@localhost php5]# service httpd stop [root@localhost php5]# service httpd start #在浏览器上输入 http://192.168.254.10/index.php 测试 #成功的话会出现下图
安装论坛
#建立连接 [root@localhost php5]# mysql -u root -p Enter password: #输入密码 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.6.26 Source distribution Copyright (c) 2000, 2015, 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> CREATE DATABASE bbs; Query OK, 1 row affected (0.00 sec) #把bbs数据库里面所有表的权限授予给bbsuser,并设置密码 mysql> GRANT all ON bbs.* TO 'bbsuser'@'%' IDENTIFIED BY 'admin123'; Query OK, 0 rows affected (0.01 sec) #刷新一下数据库 mysql> flush privileges; #可以用show看一下创建的数据库 mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | bbs | #比上面多了一个bbs | mysql | | performance_schema | | test | +--------------------+ 5 rows in set (0.00 sec) mysql> exit Bye [root@localhost php5]# cd /opt/ [root@localhost opt]# [root@localhost opt]# ls apr-1.6.2.tar.gz httpd-2.4.29 mysql-5.6.26.tar.gz apr-util-1.6.0.tar.gz httpd-2.4.29.tar.bz2 php-5.6.11 Discuz_X2.5_SC_UTF8.zip mysql-5.6.26 php-5.6.11.tar.bz2 [root@localhost opt]# unzip /opt/Discuz_X2.5_SC_UTF8.zip -d /opt/dis [root@localhost opt]# cd dis/ [root@localhost dis]# ls readme upload utility [root@localhost dis]# cp -r upload/ /usr/local/httpd/htdocs/bbs #在网页上输入 http://192.168.254.10/bbs/install/ #得到下图
点击“我同意”,继续
#图上有红叉是权限问题,进去看看 [root@localhost dis]# cd /usr/local/httpd/htdocs/bbs [root@localhost bbs]# ll 总用量 76 -rw-r--r--. 1 root root 2603 11月 3 15:18 admin.php drwxr-xr-x. 11 root root 163 11月 3 15:18 api -rw-r--r--. 1 root root 727 11月 3 15:18 api.php drwxr-xr-x. 2 root root 23 11月 3 15:18 archiver drwxr-xr-x. 2 root root 90 11月 3 15:18 config -rw-r--r--. 1 root root 922 11月 3 15:18 connect.php -rw-r--r--. 1 root root 253 11月 3 15:18 cp.php -rw-r--r--. 1 root root 106 11月 3 15:18 crossdomain.xml drwxr-xr-x. 13 root root 216 11月 3 15:18 data -rw-r--r--. 1 root root 5558 11月 3 15:18 favicon.ico -rw-r--r--. 1 root root 2110 11月 3 15:18 forum.php -rw-r--r--. 1 root root 823 11月 3 15:18 group.php -rw-r--r--. 1 root root 1223 11月 3 15:18 home.php -rw-r--r--. 1 root root 5448 11月 3 15:18 index.php drwxr-xr-x. 5 root root 64 11月 3 15:18 install -rw-r--r--. 1 root root 1040 11月 3 15:18 member.php -rw-r--r--. 1 root root 1381 11月 3 15:18 misc.php -rw-r--r--. 1 root root 1757 11月 3 15:18 plugin.php -rw-r--r--. 1 root root 985 11月 3 15:18 portal.php -rw-r--r--. 1 root root 582 11月 3 15:18 robots.txt -rw-r--r--. 1 root root 1158 11月 3 15:18 search.php drwxr-xr-x. 10 root root 168 11月 3 15:18 source drwxr-xr-x. 6 root root 72 11月 3 15:18 static drwxr-xr-x. 3 root root 38 11月 3 15:18 template drwxr-xr-x. 6 root root 92 11月 3 15:18 uc_client drwxr-xr-x. 13 root root 241 11月 3 15:18 uc_server -rw-r--r--. 1 root root 1691 11月 3 15:18 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/ #再次查看 [root@localhost bbs]# ll 总用量 76 -rw-r--r--. 1 root root 2603 11月 3 15:18 admin.php drwxr-xr-x. 11 root root 163 11月 3 15:18 api -rw-r--r--. 1 root root 727 11月 3 15:18 api.php drwxr-xr-x. 2 root root 23 11月 3 15:18 archiver drwxr-xr-x. 2 daemon root 90 11月 3 15:18 config -rw-r--r--. 1 root root 922 11月 3 15:18 connect.php -rw-r--r--. 1 root root 253 11月 3 15:18 cp.php -rw-r--r--. 1 root root 106 11月 3 15:18 crossdomain.xml drwxr-xr-x. 13 daemon root 216 11月 3 15:18 data -rw-r--r--. 1 root root 5558 11月 3 15:18 favicon.ico -rw-r--r--. 1 root root 2110 11月 3 15:18 forum.php -rw-r--r--. 1 root root 823 11月 3 15:18 group.php -rw-r--r--. 1 root root 1223 11月 3 15:18 home.php -rw-r--r--. 1 root root 5448 11月 3 15:18 index.php drwxr-xr-x. 5 root root 64 11月 3 15:18 install -rw-r--r--. 1 root root 1040 11月 3 15:18 member.php -rw-r--r--. 1 root root 1381 11月 3 15:18 misc.php -rw-r--r--. 1 root root 1757 11月 3 15:18 plugin.php -rw-r--r--. 1 root root 985 11月 3 15:18 portal.php -rw-r--r--. 1 root root 582 11月 3 15:18 robots.txt -rw-r--r--. 1 root root 1158 11月 3 15:18 search.php drwxr-xr-x. 10 root root 168 11月 3 15:18 source drwxr-xr-x. 6 root root 72 11月 3 15:18 static drwxr-xr-x. 3 root root 38 11月 3 15:18 template drwxr-xr-x. 6 daemon root 92 11月 3 15:18 uc_client drwxr-xr-x. 13 root root 241 11月 3 15:18 uc_server -rw-r--r--. 1 root root 1691 11月 3 15:18 userapp.php #刷新一下网站
翻到最后点击下一步
下一步后会遇到一点小问题
将这里更改
[root@localhost bbs]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 12 Server version: 5.6.26 Source distribution Copyright (c) 2000, 2015, 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> select user,host from mysql.user; +---------+-----------------------+ | user | host | +---------+-----------------------+ | bbsuser | % | | root | 127.0.0.1 | | root | ::1 | | | localhost | | root | localhost | | | localhost.localdomain | | root | localhost.localdomain | +---------+-----------------------+ 7 rows in set (0.00 sec) #将空白的用户删除 mysql> delete from mysql.user where user=''; Query OK, 2 rows affected (0.00 sec) #刷新一下 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) #再次查看 mysql> select user,host from mysql.user; +---------+-----------------------+ | user | host | +---------+-----------------------+ | bbsuser | % | | root | 127.0.0.1 | | root | ::1 | | root | localhost | | root | localhost.localdomain | +---------+-----------------------+ 5 rows in set (0.00 sec) mysql> mysql> exit Bye #回到网页点击下一步
安装过后,再次安装会变成这样
创建一个用户
注册之后进入一个论坛
end.
这篇关于在Linux中安装MYSQL并创建一个论坛的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-19Mysql安装教程:新手必看的详细安装指南
- 2024-11-18Mysql安装入门:新手必读指南
- 2024-11-18MySQL事务MVCC原理入门详解
- 2024-11-16MySQL资料:新手入门教程
- 2024-11-16MySQL资料:新手入门教程
- 2024-11-15MySQL教程:初学者必备的MySQL数据库入门指南
- 2024-11-15MySQL教程:初学者必看的MySQL入门指南
- 2024-11-04部署MySQL集群项目实战:新手入门教程
- 2024-11-04如何部署MySQL集群资料:新手入门指南
- 2024-11-02MySQL集群项目实战:新手入门指南