1.搭建Apache
2.搭建MySQL
3.修改mysql密码
4.忘记密码
5.搭建pbp
6.使用图形化工具管理MySQL数据库
7.需要6个压缩包
8.安装论坛
1. 解压论坛压缩包
2. 更改论坛目录的属主
3. 设置论坛数据库
4. 论坛后台管理员页面
实验
搭建lamp服务
上传压缩包
解压三个软件包
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
设置chkconfig管理http
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
编辑配置文件
vi /etc/init.d/httpd
添加两行命令
添加:
#chkconfig:45
87 31
#description: Apache is a World Wide Web server
用chkconfig管理http
chkconfig –add httpd
查看服务开关状态
chkconfig –list
修改配置文件
vi /usr/local/httpd/conf/httpd.conf
将ServerName前面#号删除
优化配置文件路径,并把httpd服务的可执行程序文件放入路径环境变量的目录中便于系统识别
ln -s /usr/local/httpd/conf/httpd.conf /etc/
ln -s /usr/local/httpd/bin/* /usr/local/bin/
将this is my 重定向输入到index.html中
echo ”
this is my” >
/usr/local/httpd/htdocs/index.html
重启服务 查看端口
systemctl stop firewalld
setenforce 0
service httpd start
netstat -anpt | grep 80
测试使用浏览器访问
2.搭建MySQL
切换目录 安装依赖关系
cd /
yum -y install
ncurses
ncurses-devel
bison
cmake
创建一个不可登录的用户
useradd -s /sbin/nologin mysql
上传压缩包
在/root目录下解压mysql安装包
tar zxvf 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
配置cmake安装服务详细信息(同上红色字体内容不需要操作只是解释)
cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql #安装目录
安装路径
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock #指定套接字文件的存储路径套接字:客户端访问mysql数据库的一个接口
-DSYSCONFDIR=/etc #配置my. cnf的目录
配置文件路径,(根目录)
-DSYSTEMD_PID_DIR=/usr/local/mysql #主服务进程所在路径
(进程文件目录)
-DDEFAULT_CHARSET=utf8 #默认字符集
-DDEFAULT_COLLATION=utf8_general_ci #默认编码
-DWITH_INNOBASE_STORAGE_ENGINE=1 #启用InnoDB引擎
-DWITH_ARCHIVE_STORAGE_ENGINE=1 #启用ARCHIVE引擎
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 #启用BLACKHOLE引擎
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 #启用perfschema引擎
-DMYSQL_DATADIR=/usr/local/mysql/data #数据存储路径 (数据库目录)
-DWITH_BOOST=boost
#boost库是为C++语言标准库提供扩展的一些C++程序库的总称
-DWITH_SYSTEMD=1 #这是mysql5.7原生支持systemd的选项,如果用systemctl启动,就必须开启
编译安装
make -j 8 && make install
设置属主属组(因为要运行权限)
cd
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
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 #服务器设置字符
socket =/usr/local/mysql/mysql.sock #进程文件
pid-file = /usr/local/mysql/mysql.pid
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
将/usr/local/mysql/bin和/usr/local/mysql/lib追加到变量PATH
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/
初始化设置
cp usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system
systemctl daemon-reload 守护进程
systemctl start mysqld
cd
netstat -anpt | grep 3306
systemctl enable mysqld
mysqladmin -u root -p password “abc123” 默认回车
修改mysql密码
在数据库中修改密码
[root@server1~]# mysql -u root -p
mysql >set password for root@localhost =password(‘123456’);
Query OK,0 rows affected, 1 warning (0.00 sec)
将密码在修改为abc123
mysql >set password for root@localhost = password(‘abc123’);
忘记密码
编辑配置文件
vi /usr/local/httpd/bin/apxsq
#!/usr/bin/perl -w
搭建php
上传压缩包
安装依赖
yum -y
install
libjpeg
libjpeg-devel
libpng
libpng-devel
freetype
freetype-devel
libxml2
libxml2-devel
zlib
zlib-devel
curl
curl-devel
openssl
openssl-devel
在/root目录下解压安装包
cd / tar xjvf php-7.1.10.tar.bz2
php配置选项
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
验证php模块有没有安装成功
/usr/local/php/bin/php -m
添加php功能
vi /etc/httpd.conf
搜索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
文章来源于互联网:搭建LAMP服务(Apache、Mysql、Php)论坛this is mySuccess!!Success!!!