[root@stw2 httpd-2.4.54]# cd[root@stw2 ~]# /usr/local/apache/bin/apachectl start[root@stw2 ~]# cd /usr/local/apache/[root@stw2 apache]# ls
bin build cgi-bin error htdocs icons include logs man manual modules
[root@stw2 apache]# cd htdocs/[root@stw2 htdocs]# ls
index.html //网页存放位置
[root@stw2 htdocs]# cd /etc/httpd24/ //配置文件存放位置[root@stw2 httpd24]# ls
extra httpd.conf magic mime.types original
4、mysql包(二进制安装、不需要编译)
(1)创建一个mysql的服务用户
[root@stw2 ~]# useradd -r -M -s /sbin/nologin mysql-r -M :不创建用户的家目录,并且uid要小于1000
[root@stw2 ~]# id mysql
uid=988(mysql) gid=982(mysql) groups=982(mysql)
(2)安装依赖包libncurses*
[root@stw2 ~]# yum -y install libncurses*
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: pubmirror1.math.uh.edu
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Package ncurses-libs-5.9-14.20130511.el7_4.x86_64 already installed and latest version
Nothing to do
(3)解压(直接解压到/usr/local)
[root@stw2 ~]# tar -xzvf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz -C /usr/local/[root@stw2 local]# ls
apache apr-util etc include lib64 mysql-5.7.37-linux-glibc2.12-x86_64 share
apr bin games lib libexec sbin src
[root@stw2 ~]# /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --datadir=/opt/data/
2025-08-19T07:00:02.326950Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2025-08-19T07:00:02.925170Z 0 [Warning] InnoDB: New log files created, LSN=45790
2025-08-19T07:00:03.008938Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2025-08-19T07:00:03.045682Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 212f130b-7cca-11f0-a5fb-000c29a41fc0.
2025-08-19T07:00:03.047652Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2025-08-19T07:00:03.497719Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2025-08-19T07:00:03.497756Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2025-08-19T07:00:03.501263Z 0 [Warning] CA certificate ca.pem is self signed.
2025-08-19T07:00:04.046454Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.[root@stw2 local]# ln -sv /usr/local/mysql/include/ /usr/local/include/mysql //软连接
‘/usr/local/include/mysql’ -> ‘/usr/local/mysql/include/’
[root@stw2 local]# cd /usr/local/include/[root@stw2 include]# ls
mysql
[root@stw2 ~]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf[root@stw2 ~]# vim /etc/ld.so.conf.d/mysql.conf [root@stw2 ~]# ldconfig //没有报错说明配置文件没有问题
(2)编辑mysql配置文件(/etc/my.cnf)
[root@stw2 ~]# vim /etc/my.cnf[root@stw2 ~]# cd /usr/local/mysql[root@stw2 mysql]# ls
bin docs include lib LICENSE man README share support-files
[root@stw2 mysql]# cd support-files/[root@stw2 support-files]# ls
magic mysqld_multi.server mysql-log-rotate mysql.server
[root@stw2 support-files]# vim mysql.server
(3)定义mysql服务可以使用systemd来进行管理
[root@stw2 ~]# vim /usr/lib/systemd/system/mysqld.service[root@stw2 ~]# systemctl daemon-reload [root@stw2 ~]# systemctl enable --now mysqld
Created symlink from/etc/systemd/system/multi-user.target.wants/mysqld.service to /usr/lib/systemd/system/mysqld.service.
(4)设置环境变量
[root@stw2 ~]# vim /etc/profile[root@stw2 ~]# source /etc/profile
(5)设置密码
[root@stw2 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.37 MySQL Community Server (GPL)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
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> set password=password('123456');
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> exit
Bye
[root@stw2 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.37 MySQL Community Server (GPL)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
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>
[root@stw2 php-7.1.10]# cp php.ini-development /usr/local/php/lib/php.ini[root@stw2 php-7.1.10]# vim /usr/local/php/lib/php.ini
让httpd支持index.php网页
[root@stw2 ~]# cd /etc/httpd24/[root@stw2 httpd24]# ls
extra httpd.conf httpd.conf.bak magic mime.types original
[root@stw2 httpd24]# vim httpd.conf[root@stw2 httpd24]# cd /usr/local/apache/[root@stw2 apache]# ls
bin build cgi-bin error htdocs icons include logs man manual modules
[root@stw2 apache]# cd htdocs/[root@stw2 htdocs]# ls
index.html
[root@stw2 htdocs]# rm -rf index.html[root@stw2 htdocs]# vim index.php[root@stw2 htdocs]# ls
index.php