• Linux中apache服务安装与mysql安装


    目录

    一、apache安装

    二、MySQL安装


    一、apache安装

    准备环境:一台虚拟机、三个安装包(apr-1.6.2.tar.gz、apr-util-1.6.0.tar.gz、httpd-2.4.29.tar.bz2)

    安装过程:

    1. tar xf apr-1.6.2.tar.gz
    2. tar xf apr-util-1.6.0.tar.gz
    3. tar xf httpd-2.4.29.tar.bz2
    4. mv apr-1.6.2 httpd-2.4.29/srclib/apr
    5. mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util
    6. yum -y install \
    7. gcc \
    8. gcc-c++ \
    9. make \
    10. pcre-devel \
    11. expat-devel \
    12. perl
    13. cd /opt/httpd-2.4.29/
    14. ./configure \
    15. --prefix=/usr/local/httpd \
    16. --enable-so \
    17. --enable-rewrite \
    18. --enable-charset-lite \
    19. --enable-cgi
    20. make -j 2 && make install
    21. ln -s /usr/local/httpd/conf/httpd.conf /etc/
    22. ln -s /usr/local/httpd/bin/* /usr/local/bin/
    23. vim /lib/systemd/system/httpd.service
    24. [Unit]
    25. Description=The Apache HTTP Server #描述
    26. After=network.target #描述服务类别
    27. [Service]
    28. Type=forking #后台运行方式
    29. PIDFile=/usr/local/httpd/logs/httpd.pid #PID文件位置
    30. ExecStart=/usr/local/bin/apachectl $OPTIONS #启动服务
    31. ExecReload=/bin/kill -HUP $MAINPID
    32. vi /usr/local/httpd/conf/httpd.conf
    33. --197行--取消注释,修改
    34. ServerName 192.168.10.80:80
    35. --221行--默认首页存放路径
    36. DocumentRoot "/usr/local/httpd/htdocs" 以后 有存储
    37. --255行--默认首页文件名设置
    38. DirectoryIndex index.html
    39. ---》wq
    40. httpd -t
    41. cat /usr/local/httpd/htdocs/index.html
    42. service httpd restart
    43. netstat -anpt | grep 80

    二、MySQL安装

    安装环境:一台虚拟机、两个安装包(boost_1_59_0.tar.gz、mysql-5.7.17.tar.gz)

    安装步骤:

    1. yum -y install gcc gcc-c++ ncurses ncurses-devel bison cmake
    2. useradd -s /sbin/nologin mysql
    3. tar zxvf mysql-5.7.17.tar.gz -C /opt
    4. tar zxvf boost_1_59_0.tar.gz -C /usr/local/
    5. mv /usr/local/boost_1_59_0 /usr/local/boost
    6. cd /opt/mysql-5.7.17/
    7. cmake \
    8. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
    9. -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
    10. -DSYSCONFDIR=/etc \
    11. -DSYSTEMD_PID_DIR=/usr/local/mysql \
    12. -DDEFAULT_CHARSET=utf8 \
    13. -DDEFAULT_COLLATION=utf8_general_ci \
    14. -DWITH_EXTRA_CHARSETS=all \
    15. -DWITH_INNOBASE_STORAGE_ENGINE=1 \
    16. -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
    17. -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
    18. -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
    19. -DMYSQL_DATADIR=/usr/local/mysql/data \
    20. -DWITH_BOOST=/usr/local/boost \
    21. -DWITH_SYSTEMD=1
    22. make -j3 && make install
    23. chown -R mysql:mysql /usr/local/mysql/ #更改管理主/组
    24. chown mysql:mysql /etc/my.cnf
    25. vim /etc/my.cnf #删除文件下所有内容
    26. [client]
    27. port = 3306
    28. default-character-set=utf8
    29. socket=/usr/local/mysql/mysql.sock
    30. [mysql]
    31. port = 3306
    32. default-character-set=utf8
    33. socket=/usr/local/mysql/mysql.sock
    34. auto-rehash
    35. [mysqld]
    36. user = mysql
    37. basedir=/usr/local/mysql
    38. datadir=/usr/local/mysql/data
    39. port = 3306
    40. character-set-server=utf8
    41. pid-file = /usr/local/mysql/mysqld.pid
    42. socket=/usr/local/mysql/mysql.sock
    43. bind-address = 0.0.0.0
    44. skip-name-resolve
    45. max_connections=2048
    46. default-storage-engine=INNODB
    47. max_allowed_packet=16M
    48. server-id = 1
    49. sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES
    50. echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
    51. source /etc/profile
    52. cd /usr/local/mysql/bin/
    53. ./mysqld \
    54. --initialize-insecure \
    55. --user=mysql \
    56. --basedir=/usr/local/mysql \
    57. --datadir=/usr/local/mysql/data
    58. cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
    59. systemctl daemon-reload
    60. systemctl start mysqld.service
    61. systemctl enable mysqld
    62. mysqladmin -u root -p password "123456"
    63. mysql -u root -p123456 #登录查看

  • 相关阅读:
    Linux网络服务之ftp
    京东数据平台:2023年服饰行业销售数据分析
    下拉框判断是否重复选中值
    责任链模式
    19-CSS弹性盒布局
    ClickHouse配置Hdfs存储数据
    Debian11安装MySQL8.0,链接Navicat
    Python中的Tkinter(Python的GUI编程)
    在Gradio实现分栏、分页的效果(二)
    IDEA-SVN合并分支到主干
  • 原文地址:https://blog.csdn.net/qq_63994746/article/details/140959236