概述
LAMP架构部署
L:Linux
A:Apache
M:Mysql
P:PHP
Apache
(1) 下载阿帕奇rpm软件包
(2) Tar解包
tar zxvf apr-l.6.2.tar.gz
tar zxvf apr-util-l.6.0.tar.gz
tar jxvf httpd-2.4.29.tar.bz2
(3) 将rpm包移动到阿帕奇文件内
mv apr-1.6.2 httpd-2.4.29/srclib/apr
mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util
(4) Yum安装依赖包
yum -y install pcre pcre-devel zlib-devel perl expat-devel
(5),/configure配置
1) 进入阿帕奇主目录:
cd httpd-2.4.29/
2)配置,添加功能模块:
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
make && make install
3)实现开机自启:
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 //将httpd加入到SERVICE管理器
绑定域名:
ln -s /usr/local/httpd/conf/httpd.conf /etc/
vi /etc/httpd.conf
ServerName www.mcc.com:80
做映射:
vim /etc/hosts
192.168.17.10 www.mcc.com
ln -s /usr/local/httpd/bin/* /usr/bin/
systemctl start httpd
检查语法:
httpd -t
apachectl –t
检查监听端口是否正常:
netstat –anpt | grep 80
Mysql
1. 安装依赖包
yum -y install ncurses ncurses-devel bison cmake
2. 创建一个不可登录的mysql程序用户
useradd –s /sbin/nologin mysql
3. 下载并解压mysql的rpm软件包
tar zxvf mysql-boost-5.7.20.tar.gz
4. 进入mysql数据库的主文件;并开始cmake
cd mysql-5.7.20/
cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_UNIX_ADDR=/usr/local/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 && 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/localmysql/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_LERO,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
5. 给数据库初始化
cd /usr/local/mysql/
bin/mysqld --initialize-insercure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
cp usr/lib/systemd/system/mysql.service /usr/lib/systemd/system
systemctl daemon-reload //守护进程
systemctl start mysqld
netstart -anpt | grep 3306
systemctl enabled mysqld
6. 设置密码
mysqladmin -u用户名 -p旧密码 password 新密码
登录数据库:mysql -uroot –p123456
7. 如果忘记密码
vim /etc/my.cnf
[mysqld]末尾添加
skip_name_resolve
skip_grant_tables
bind-address=0.0.0.0
systemctl restart mysqld
PHP
1. 安装依赖包
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel curl curl-devel openssl openssl-devel
2. 下载并解压PHP的rpm软件包
tar jxvf php-7.1.10.tar.bz2
3. 进入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-fpm --enable-mbstring --enable-xml --enable-session --enable-ftp --enable-pdo --enable-tokenizer --enable-zip
make && make install
4. 拷贝文件
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 #此处通过/关键词查找
date.timezone = Asia/Shanghai
5. 验证安装的模块
/usr/local/php/bin/php –m
让Apache支持PHP
vi /etc/httpd.conf //进入文件在合适的位置添加如下内容;用/关键词查找
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.html
7. 在阿帕奇站点下创建一个PHP网页
vim /usr/local/httpd/htdocs/index.php
<?php
phpinfo();
?>
8. 重启阿帕奇
systemctl restart httpd
做数据库与PHP的联动
1) 测试数据库工作是否正常
mysql –u root –p 123456
create database myadm;
grant all privileges on myadm.* to 'myadm’@'%’ identified by 'admin123';
//授权 %表示任意地址 on作用在哪个库下面
grant all privileges on myadm.* to 'myadm’@’localhost' identified by 'admin123’;
grant all privileges on *.* to 'root’@'client’ identified by '123456';
flush privileges;//刷新权限
2) 修改PHP网页
vim /usr/local/httpd/htdocs/index.php
<?php
$link=mysqli_connect('192.168.17.10', 'myadm’, ' admin123');
if($link) echo "<h1>Success!</h1>";
else echo "Fail!!";
?>
安装phpMyadmin
unzip phpMyAdmin-4.7.6-all-languages.zip -d /opt/
cd /opt
mv phpMyAdmin-4.7.6-all-languages /usr/local/httpd/htdocs/myadm
//拷贝这个语言到http站点下面
cd /usr/local/httpd/htdocs/myadm
cp config.sample.inc.php config.inc.php //拷贝模板
vi config.inc.php
$cfg['servers'][$i]['host'] = '192.168.17.10'; //将IP地址改为本机地址,此处可用/关键词搜索
最后
以上就是落后刺猬为你收集整理的LAMP架构部署LAMP架构部署的全部内容,希望文章能够帮你解决LAMP架构部署LAMP架构部署所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复