ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

LAMP架构搭建

2021-07-27 14:35:02  阅读:174  来源: 互联网

标签:架构 -- apr LAMP usr install mysql local 搭建


一.搭建准备:

安装包:apr-1.5.1.tar    httpd-2.4.33.tar       mysql-5.6.47-linux-glibc2.12-x86_64.tar       php-5.6.39.tar      redis-2.2.3     apr-util-1.5.4.tar        

操作系统: 使用centos7系统

二.搭建LAMP架构

1.安装mysql:本次解压后的文件都放在/usr/local/src下

yum -y install autoconf (安装autoconf)

tar -zxvf mysql-5.6.47-linux-glibc2.12-x86_64.tar(解压MySQL安装包)

mv mysql-5.6.47-linux-glibc2.12-x86_64 /usr/local/mysql(转移位置)

useradd -s /sbin/nologin mysql (创建MySQL用户)

mkdir -p /usr/local/mysql/data (创建数据仓库)

chown -R mysql:mysql /mysql/data (更改用户权限)

./scripts/mysql_install_db --user=mysql --datadir=/data/mysql(运行)

cp support-file/my-default.cnf /etc/my.cnf(拷贝)

vim  my-default.cnf (修改配置文件)

Basedir=/usr/local/mysql(mysql包位置) 

Datadir=/data/mysql/datadir (数据存放位置)

Port=3306(端口号3306是默认端口号)

Server_id=10(服务ID我写的是主机地址)

socket = /tmp/mysql.sock 

cp  support-files/mysql.server  /etc/init.d/mysql(拷贝)

chmod  755  /etc/init.d/mysql(修改启动脚本文件的属性)

Vim /etc/init.d/mysql

定义basedir和datadir

chkconfig --add mysql(把服务添加到系统服务列表中)

chkconfig mysql on(设置开机自启)

 

 service mysql start(启动)

 

2.安装apache:

tar -zxvf httpd-2.4.33.tar

tar -zxvf apr-1.5.1.tar

tar -zxvf apr-util-1.5.4.tar

yum install -y expat-devel

yum install -y pcre pcre-devel

cd /usr/local/src/apr-1.5.1(到apr目录下)

./configure --prefix=/usr/local/apr

make &&make install

cd /usr/local/src/apr-util-1.5.4(到apr-util目录下)

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

make &&make install

cd /usr/local/src/httpd-2.4.33(到httpd下)

./configure  --prefix=/usr/1ocal/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so 

--enable-mods-shared=most

make && make install

/usr/local/apache2.4/bin/apachectl -M(查看配置文件有哪些)

 

3.安装PHP:

tar -jxvf php-5.6.39.tar.bz2

yum install -y libxml2-devel

yum install -y openssl openssl -devel

yum install -y bzip2 bzip2-devel

yum install -y libpng libpng-devel

yum install -y freetype freetype-devel

yum install -y epel-release

yum install -y libmcrypt-devel

cd  php-5.6.39

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-libxml-dir--with-gd --with-jpeg-dir --with-png-dir--with-freetype-dir --with-iconv-dir--with-zlib-dir --with-bz2 --with-openssl--with-mcrypt --enable-soap--enable-gd-native-ttf  --enable-mbstring--enable-sockets --enable-exif

make && make install

 

4.httpd解析php:

vim /usr/local/apache2.4/conf/httpd.conf

修改ServerName www.example.com:80把他之前的#去掉

把<Directory />

    AllowOverride none

    Require all denied

</Directory>中denied改成granted   目的是允许请求访问

搜索AddType application/x-gzip .gz .tgz,在下面添加一行 AddType application/x-httpd-php .php;

把<IfModule dir_module>

    DirectoryIndex index.html

</IfModule>中的DirectoryIndex index.html改成DirectoryIndex index.html index.php

/usr/local/apache2.4/bin/apachectl -t(测试文件是否正确如果出现Syntax OK则表示正确)

/usr/local/apache2.4/bin/apachectl start(启动httpd)

netstat -lnp |grep httpd(查看是否启动)

curl localhost(使用curl 命令)

<html><body><h1>It works!<h1><body><html>(使用curl命令的成功标志)

标签:架构,--,apr,LAMP,usr,install,mysql,local,搭建
来源: https://www.cnblogs.com/liwei-1-1-1-1/p/15065723.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有