配置:
虚拟机恢复初始化
配置VM1网卡
配置永久IP地址(关闭防火、关闭安全linux)
使用远程连接软件
挂载好磁盘到mnt目录
配置好yum仓库
修改虚拟机内存和处理器
点Upload
将6个压缩软件添加到
进入远程连接软件 进入到/目录 查看软件包
配置yum仓库
安装Apache
解压缩
tar xf apr-1.6.2.tar.gz
tar xf apr-util-1.6.0.tar.gz
tar -xjf httpd-2.4.29.tar.bz2
mv apr-1.6.2 httpd-2.4.29/srclib/apr
mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util
安装服务
yum -y install \
gcc \
gcc-c++ \
make \
pcre-devel \
expat-devel \
perl \
zlib-devel \
zlib
进入目录
cd /httpd-2.4.29
安装服务
./configure \
--prefix=/usr/local/httpd \
--enable-so \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi
编译安装
make -j 8 && make install
复制
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
编辑服务
vi /etc/init.d/httpd
将命令添加到文件的第二行第三行
# chkconfig: 35 85 21 //35级别自动运行 第85个启动 第21个关闭
# description: Apache is a World Wide Web server
chkconfig --add httpd
chkconfig --list
编辑文件 将ServerName前面#号删除
vi /usr/local/httpd/conf/httpd.conf
优化操作
ln -s /usr/local/httpd/conf/httpd.conf /etc/
ln -s /usr/local/httpd/bin/* /usr/local/bin/
systemctl stop firewalld.service
setenforce 0
service httpd start
netstat -anpt | grep 80
安装mysql
安装服务
yum -y install \
gcc \
gcc-c++ \
make \
pcre-devel \
expat-devel \
perl \
zlib-devel \
zlib
安装服务
cd /
yum -y install \
ncurses \
ncurses-devel \
bison \
cmake
添加用户
useradd -s /sbin/nologin mysql
解压缩
tar xzvf mysql-boost-5.7.20.tar.gz
切换目录
cd mysql-5.7.20/
安装服务
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DSYSCONFDIR=/etc \
-DSYSTEMD_PID_DIR=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_BOOST=boost \
-DWITH_SYSTEMD=1
编译安装
make -j 4 && make install
报错解决方法 将这个命令在敲几遍make -j 4 && make install
修改权限
chown -R mysql.mysql /usr/local/mysql/
编辑配置文件
vi /etc/my.cnf 将里面内容全部删除
插入
[client]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock
[mysql]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock
[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
character_set_server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket = /usr/local/mysql/mysql.sock
server-id = 1
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
修改权限
chown mysql:mysql /etc/my.cnf
echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile
echo 'export PATH' >> /etc/profile
source /etc/profile
切换目录
cd /usr/local/mysql/
安装服务
bin/mysqld \
--initialize-insecure \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data
cp usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
systemctl daemon-reload
systemctl start mysqld
netstat -anpt | grep 3306
systemctl enable mysqld
mysqladmin -u root -p password "abc123" 默认回车
mysql -u root -p ctrl+d 退出 密码 abc123
安装服务
yum -y install \
libjpeg \
libjpeg-devel \
libpng libpng-devel \
freetype freetype-devel \
libxml2 \
libxml2-devel \
zlib zlib-devel \
curl curl-devel \
openssl openssl-devel
编辑配置文件
vi /usr/local/httpd/bin/apxs
#!/usr/bin/perl -w
切换目录 解压缩 安装
cd /
tar xjvf php-7.1.10.tar.bz2
cd php-7.1.10
./configure \
--prefix=/usr/local/php \
--with-apxs2=/usr/local/httpd/bin/apxs \
--with-mysql-sock=/usr/local/mysql/mysql.sock \
--with-mysqli \
--with-zlib \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-openssl \
--enable-mbstring \
--enable-xml \
--enable-session \
--enable-ftp \
--enable-pdo \
--enable-tokenizer \
--enable-zip
编译安装
make -j 8 && make install
复制
cp php.ini-development /usr/local/php/lib/php.ini
编辑配置文件
vi /usr/local/php/lib/php.ini
插入 修改配置文件
mysqli.default_socket = /usr/local/mysql/mysql.sock
搜索mysqli.default_socket
搜索date.timezone
date.timezone = Asia/Shanghai
/usr/local/php/bin/php -m //验证安装的模块
vi /etc/httpd.conf //在合适位置新增
添加到.tgz下面
搜索AddType application
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
搜索DirectoryIndex
在html后面添加index.php
DirectoryIndex index.php index.html
rm -f /usr/local/httpd/htdocs/index.html
编辑配置文件
vi /usr/local/httpd/htdocs/index.php
phpinfo();
?>
systemctl start httpd
systemctl restart httpd
--------下面测试数据库工作是否正常-----
mysql -u root -p 密码 abc123
CREATE DATABASE myadm;
GRANT all ON myadm.* TO 'myadm'@'%' IDENTIFIED BY 'admin123';
GRANT all ON myadm.* TO 'myadm'@'localhost' IDENTIFIED BY 'admin123';
flush privileges;
退出
编辑配置文件
vi /usr/local/httpd/htdocs/index.php
$link=mysqli_connect('192.168.123.15','myadm','admin123'); IP地址修改为本地虚拟机ip
if($link) echo "
else echo "Fail!!";
?>
---以下安装phpMyadmin------
切换目录
cd /
解压缩
unzip phpMyAdmin-4.7.6-all-languages.zip
解压完成
cp -r phpMyAdmin-4.7.6-all-languages /usr/local/httpd/htdocs/
cd /usr/local/httpd/htdocs/
ll查看
cd phpMyAdmin-4.7.6-all-languages/
cp config.sample.inc.php config.inc.php
编辑配置文件
vi config.inc.php
$cfg['Servers'][$i]['host'] = '127.0.0.1'; //把localhost 改成IP 31行
cd /usr/local/httpd/htdocs/
ll查看
mv phpMyAdmin-4.7.6-all-languages/ myadm
重启服务
systemctl start httpd
systemctl restart httpd
用户名myadm
密码 admin123