LAMP架构相关知识(一)

MYSQL5.7 安装操作参考:https://www.cnblogs.com/zero-gg/p/8875598.html

扩展知识:

mysql5.5源码编译安装  http://www.aminglinux.com/bbs/thread-1059-1-1.html

mysql5.7二进制包安装(变化较大)  http://www.apelearn.com/bbs/thread-10105-1-1.html

apache dso  https://yq.aliyun.com/articles/6298

apache apxs  https://wizardforcel.gitbooks.io/apache-doc/content/51.html

apache工作模式  http://www.cnblogs.com/fnng/archive/2012/11/20/2779977.html

php中mysql,mysqli,mysqlnd,pdo到底是什么  http://blog.csdn.net/u013785951/article/details/60876816

查看编译参数  http://ask.apelearn.com/question/1295

1. LAMP 架构介绍:

LAMP含义:Linux+Apache(httpd)+Mysql+PHP  这几大平台的简写

httpd、PHP、MySQL 三者如何工作:

2.MySQL_MariaDB介绍

    mysql  是关系型数据库。由mysql ab 公司开发,08年被SUN公司收购,09年SUN公司被oracle 公司收购。M

 MySQL  官网https://www.mysql.com ;Mariadb 是Mysql的一个分支,官网 https://mariadb.com

 MySQL 公司5.6 变化比较大,5.7性能上有很大提升。

Mariadb 5.5版本对应Mysql的5.5,10.0对应Mysql 5.6

Community 社区版本,enterprise 企业版,GA(Generally Available)指通用版本,在生成环境中用的,

DMR(Development Milestone Release)开发历程碑发布版,RC(Release Candidate)发行候选版本,Beta开放测试版本,

Alpha内部测试版本。本课程以MariaDB 居多。

3. MySQL安装(上)

Mysql 的几个常用安装包:rpm、源码、二进制免编译。

可以在 r.aminglinux.com 中去查看课程所用到的安装包。

1. 检查当前linux 系统版本 #uname -a 

2. 进入默认的安装下载路径。  #cd  /usr/local/src/

3. 在r.aminglinux.com 网站中找到系统对应的二进制编码包。然后进行下载:wget ***   回车

如果提示wget 没有安装,用yum install  wget 命令安装。

(提示:安装wget的过程中,网络不通。请到后台启动VM NAT或VM DHCP服务)

4.安装过程如下:

5.下载完安装包之后,第一步首先要解压。提示,一定要在/usr/local/src/路径下操作。解压的办法:MYSQL 5.7的方法是:

tar  xxvf mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz

6.解压完成之后,把解压的文件移动到 /usr/local/mysql 路径下。建立该目录,把解压好的文件包移动到该目录下:

mv mysql-5.7.25-linux-glibc2.12-x86_64   /usr/local/mysql

7.添加系统用户 添加 mysql 组和 mysql 用户:

            添加 mysql 组:[root@localhost ~]# groupadd mysql

           添加 mysql 用户:[root@localhost ~]# useradd -r -g mysql mysql

         扩展:

        查看是否存在 mysql 组:[root@localhost ~]# more /etc/roup | grep mysql

        查看 msyql 属于哪个组:[root@localhost ~]# groups mysql

        查看当前活跃的用户列表:[root@localhost ~]# w

8.检查是否安装了 libaio

yum -y install liboio

9. 进入/usr/local/mysql 目录

cd /usr/local/mysql

10. 建立安装目录

mkdir -p /data/mysql

chown mysql /data/mysql

11.安装mysql

./bin/mysqld  --initialize --user=mysql --datadir=/data/mysql

注意,这一步最后一行会有一个提示

[Note] A temporary password is generated for root@localhost: B*s1i(*,kXwg

最后面的字符串为root密码。

./bin/mysql_ssl_rsa_setup --datadir=/data/mysql

12. 拷贝配置文件和启动脚本

cp support-files/my-default.cnf  /etc/my.cnf  

vim /etc/my.cnf //编辑或者修改

basedir = /usr/local/mysql

datadir = /data/mysql

port = 3306

socket = /tmp/mysql.sock

cp support-files/mysql.server /etc/init.d/mysqld

vi /etc/init.d/mysqld   //编辑或者修改

basedir=/usr/local/mysql

datadir=/data/mysql

13. 启动服务

/etc/init.d/mysqld start

14.设置root密码

使用初始化密码登录

/usr/local/mysql/bin/mysql -uroot -p'B*s1i(*,kXwg'  //进入后直接设置密码

mysql>set password = password('mypass');   //一定要设置一下新密码

退出来,再使用新的密码登录就可以了

还有一种情况,就是不知道初始化密码

vi /etc/my.cnf

在[mysqld]下面增加一行

skip-grant-tables

重启  /etc/init.d/mysqld restart

/usr/local/mysql/bin/mysql -uroot 

mysql> update user set authentication_string=password('123333') where user='root';

退出来后,更改my.cnf,去掉刚加的 skip-grant-tables

重启 /etc/init.d/mysqld restart

此时就可以使用新的密码了。

提示:

老師,你最後改密碼的地方有點小問題,沒加上數據庫名,所以
修改後應該是 update mysql.user set authentication_string=password('123333') where user='root';

這樣修改,如果進mysql後操作數據庫時提示ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
則再執行SET PASSWORD = PASSWORD('123333');
就好。

4. MariaDB安装:安装步骤

安装的方法和步骤和mysql 类似。

5. 安装Apache 过程

下载安装包:

查看Apache都加载了哪些模块:

6. 安装PHP 过程

7. 安装PHP7  方法:

执行命令下载(php-7.2.3.tar.gz  中的  .tar.gz是打包并且压缩)

wget http://hk1.php.net/get/php-7.2.3.tar.gz/from/this/mirror

3、解压

tar -zxvf mirror

4、安装依赖包

第一步:

yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel gcc gcc++

第二步:

#创建local.conf

vi /etc/ld.so.conf.d/local.conf 

#添加输入

/usr/local/lib

#添加搜索路径到配置文件

echo '/usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64'>>/etc/ld.so.conf

#然后 更新配置

ldconfig -v

第三步:

# 查看 yum 安装的 libzip 版本

yum list installed | grep libzip

#先删除旧版本

yum remove -y libzip

#下载编译安装

wget https://nih.at/libzip/libzip-1.2.0.tar.gz

tar -zxvf libzip-1.2.0.tar.gz

cd libzip-1.2.0

./configure

make && make install

5、安装 FastCGI 进程管理器(FPM)

 

进入PHP目录

cd php-7.2.3/

编译(将PHP编译安装到 /usr/local/php目录下,带上上图的配置选项)(一下三种编译方式,推荐第三种)

./configure --prefix=/usr/local/php7 \--with-config-file-path=/usr/local/php7/etc \--with-config-file-scan-dir=/usr/local/php7/etc/php.d \--with-mcrypt=/usr/include \--enable-mysqlnd \--with-mysqli \--with-pdo-mysql \--enable-fpm \--with-fpm-user=nginx \--with-fpm-group=nginx \--with-gd \--with-iconv \--with-zlib \--enable-xml \--enable-shmop \--enable-sysvsem \--enable-inline-optimization \--enable-mbregex \--enable-mbstring \--enable-ftp \--enable-gd-native-ttf \--with-openssl \--enable-pcntl \--enable-sockets \--with-xmlrpc \--enable-zip \--enable-soap \--without-pear \--with-gettext \--enable-session \--with-curl \--with-jpeg-dir \--with-freetype-dir \--enable-opcache

./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-libxml-dir --with-xmlrpc --with-openssl --with-mcrypt --with-mhash --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --with-libmbfl --with-onig --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear --enable-opcache

./configure --prefix=/usr/local/php7 --with-fpm-user=nginx --with-fpm-group=nginx --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip --enable-fpm

在php-7.2.3中执行make

make完成后执行make install

错误:

若内存较小,比如1G,可手动设置虚拟内存

编译安装时出现下面的错误:

virtual memory exhausted: Cannot allocate memory

问题原因:由于物理内存本身很小,且阿里云服务器并没有分配swap空间,当物理内存不够用时,

              物理内存中暂时不用的内容没地方转存。

解决方法:手动分配一个swap空间

dd if=/dev/zero of=/swap bs=1024 count=1M    #创建一个大小为1G的文件/swap

mkswap /swap                                                   #将/swap作为swap空间

swapon /swap                                                    #enable /swap file  for paging and swapping

echo "/swap swap swap sw 0 0" >> /etc/fstab    #Enable swap on boot, 开机后自动生效

6.编译安装完后进行参数配置

    vim /etc/profile

方法一:

将 pathmunge /usr/local/php7/bin   加入到对应位置

 

要使改动立即生效执行

    . /etc/profile 或 source /etc/profile

方法二:

    在末尾加入

    PATH=$PATH:/usr/local/php7/bin

    export PATH

    要使改动立即生效执行

    . /etc/profile 或 source /etc/profile

    查看环境变量

    echo $PATH

可以在随便一个目录执行 php -v  来查看全局是否配置好

 

代表配置完成

7.配置php-fpm

    cd /usr/local/php7/etc

    cp php-fpm.conf.default php-fpm.conf

    cd /usr/local/php7/etc/php-fpm.d

    cp www.conf.default www.conf

启动php-fpm

    /usr/local/php7/sbin/php-fpm

8.配置php.ini

查看php启动是否加载php.ini

php -i | grep Configuration

 

执行

cd ~

cd php-7.2.4

cp php.ini-development /usr/local/php7/etc/php.ini

再次查看

查看php启动是否加载php.ini

php -i | grep Configuration

 

8.Apache和PHP结合

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值