环境:

centos_7_x86_64_1804

mysql-5.7.23

httpd-2.4.34

apr-1.6.3

apr-util-1.6.1

php-5.6.37

centos下载地址:linuxdown.net

mysql下载地址:https://www.oracle.com/cn/mysql/resources.html

httpd、apr、apr-util下载地址:httpd.apache.org

php下载地址:www.php.net

安装mysql数据库

1.解压安装包

[root@localhost soft]# tar -zxvf mysql-5.7.23-el7-x86_64.tar.gz

2.解压的文件夹复制为/usr/local/mysql-5.7

[root@localhost soft]# cp -r mysql-5.7.23-el7-x86_64 /usr/local/mysql-5.7

3.初始化数据库

[root@localhost soft]# mkdir -p /data/mysql

[root@localhost soft]# cd /usr/local/mysql-5.7/bin/

[root@localhost bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql-5.7 --datadir=/data/mysql

2018-09-08T02:30:39.620042Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2018-09-08T02:30:43.513954Z 0 [Warning] InnoDB: New log files created, LSN=45790

2018-09-08T02:30:43.805205Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2018-09-08T02:30:43.871052Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 2f90f45a-b30f-11e8-b3bd-080027e98963.

2018-09-08T02:30:43.873135Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.

2018-09-08T02:30:43.873814Z 1 [Note] A temporary password is generated for root@localhost: SUIiuhu)G3fQ

执行完毕,最后一行末尾有初始化的root用户密码:SUIiuhu)G3fQ

4.修改配置文件

vim /etc/my.cnf

datadir=/data/mysql   修改这一行

pid-file=/var/run/mariadb/mariadb.pid 这一行注释掉

!includedir /etc/my.cnf.d 这一行注释掉

[root@localhost bin]# cp ../support-files/mysql.server /etc/init.d/mysqld

vim /etc/init.d/mysqld

basedir=/usr/local/mysql-5.7

datadir=/data/mysql

conf=/etc/my.cnf 修改这三行

5.启动数据库

[root@localhost bin]# service mysqld start

Starting MySQL. SUCCESS!

[root@localhost bin]# mysql -u root -p'SUIiuhu)G3fQ'

ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.

登录数据库,提示密码过期。

修改密码:

先停库

[root@localhost bin]# service mysqld stop

Shutting down MySQL.. SUCCESS!

[root@localhost bin]# /usr/local/mysql-5.7/bin/mysqld_safe --skip-grant-tables &

[1] 3213

[root@localhost bin]# 2018-09-08T02:36:25.438825Z mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.

2018-09-08T02:36:25.470298Z mysqld_safe Starting mysqld daemon with databases from /data/mysql                     跳过密码验证启动数据库

[root@localhost bin]# mysql -u root                                                                                                                                使用root直接登录,不用密码

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.7.23 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

MySQL [mysql]> select * from user where user='root' \G;

*************************** 1. row ***************************

Host: localhost

User: root

Select_priv: Y

Insert_priv: Y

Update_priv: Y

Delete_priv: Y

Create_priv: Y

Drop_priv: Y

Reload_priv: Y

Shutdown_priv: Y

Process_priv: Y

File_priv: Y

Grant_priv: Y

References_priv: Y

Index_priv: Y

Alter_priv: Y

Show_db_priv: Y

Super_priv: Y

Create_tmp_table_priv: Y

Lock_tables_priv: Y

Execute_priv: Y

Repl_slave_priv: Y

Repl_client_priv: Y

Create_view_priv: Y

Show_view_priv: Y

Create_routine_priv: Y

Alter_routine_priv: Y

Create_user_priv: Y

Event_priv: Y

Trigger_priv: Y

Create_tablespace_priv: Y

ssl_type:

ssl_cipher:

x509_issuer:

x509_subject:

max_questions: 0

max_updates: 0

max_connections: 0

max_user_connections: 0

plugin: mysql_native_password

authentication_string: *23AE809DDACAF96AF0FD78ED04B6A265E05AA257

password_expired: Y

password_last_changed: 2018-09-07 23:22:58

password_lifetime: NULL

account_locked: N

1 row in set (0.00 sec)

MySQL [mysql]> update user set password_expired='N' where user='root';                                        设置root密码永不过期

Query OK, 0 rows affected (0.00 sec)

Rows matched: 1  Changed: 0  Warnings: 0

MySQL [mysql]> update user set authentication_string=password('123') where   user='root';            设置一个新的root密码

Query OK, 1 row affected, 1 warning (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 1

MySQL [mysql]> flush privileges;

Query OK, 0 rows affected (0.00 sec)

MySQL [mysql]> exit

Bye

[root@localhost bin]# killall mysqld                关闭数据库

2018-09-08T02:43:34.127030Z mysqld_safe mysqld from pid file /data/mysql/localhost.localdomain.pid ended

[1]+  完成                  /usr/local/mysql-5.7/bin/mysqld_safe --skip-grant-tables

[root@localhost ~]# service mysqld start

Starting MySQL.. SUCCESS!

[root@localhost ~]# mysql -u root -p'123'

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.7.23 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| sys                |

+--------------------+

4 rows in set (0.00 sec)

MySQL [(none)]> exit

Bye

[root@localhost bin]#

mysql数据库安装完毕。

安装httpd

httpd依赖于apr和apr-util,所以要先装apr和apr-util-1

安装apr

[root@localhost apr-1.6.3]# tar -zxvf apr-1.6.3.tar.gz

[root@localhost apr-1.6.3]# cd apr-1.6.3/

[root@localhost apr-1.6.3]# ./configure --prefix=/usr/local/apr

rm: cannot remove 'libtoolT': No such file or directory 安装时遇见次错误。

网上搜索解决方法:

编辑configure文件

找到$RM "$cfgfile"这一行,将这一行注释掉。

再次执行configure命令成功

[root@localhost apr-1.6.3]# make && make install

安装apr-util

[root@localhost soft]# tar -zxvf apr-util-1.6.1.tar.gz

[root@localhost soft]# cd apr-util-1.6.1/

[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

[root@localhost apr-util-1.6.1]# make

xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录

编译时遇见此错误,网上搜索,缺少expat库,安装expat-devel包,重新编译成功

[root@localhost apr-util-1.6.1]# make install

安装httpd

[root@localhost soft]# tar -zxvf httpd-2.4.34.tar.gz

[root@localhost soft]# cd httpd-2.4.34/

[root@localhost httpd-2.4.34]# ./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

遇见错误,缺少pcre库,安装pcre-devel包,重新配置,配置成功

[root@localhost httpd-2.4.34]# make

[root@localhost httpd-2.4.34]# make install

apache到此安装完成

安装PHP

[root@localhost soft]# tar -zxvf php-5.6.37.tar.gz

[root@localhost soft]# cd php-5.6.37/

[root@localhost php-5.6.37]# ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/httpd/bin/apxs --with-config-file-path=/usr/local/php5/etc --with-mysql=/usr/local/mysql-5.7 --with-pdo-mysql=/usr/local/mysql-5.7 --with-mysqli=/usr/local/mysql-5.7/bin/mysql_config --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

configure: error: xml2-config not found. Please check your libxml2 installation.

遇见此错误,缺少xml2库,安装libxml2-devel包。安装完之后重新配置。

configure: error: Cannot find OpenSSL's <evp.h>

缺少openssl库,安装openssl-devel包,重新执行configure命令

configure: error: Please reinstall the BZip2 distribution

缺少bzip2库,安装bzip2-devel包

configure: error: jpeglib.h not found.

安装libjpeg-turbo-devel包

configure: error: png.h not found.

安装libpng-devel包

configure: error: freetype-config not found

安装freetype-devel包。

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

缺少libmcrypt库,在系统镜像中没有找到libmcrypt包,网上下载

下载网址:ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz

源码安装libmcrypt

tar -zxvf libmcrypt-2.5.7.tar.gz

cd libmcrypt-2.5.7

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

make && make install

修改php安装选项 --with-mcrypt=/usr/local/libmcrypt,重新配置

configure: error: Cannot find libmysqlclient_r under /usr/local/mysql-5.7.

Note that the MySQL client library is not bundled anymore!

没有找到libmysqlclient_r.so文件。mysql数据库默认的文件是libmysqlclient.so

php默认的是找libmysqlclient_r.so文件,所以提示找不到文件。进入mysql数据库安装目录,建立软连接

cd /usr/local/mysql-5.7/lib

[root@localhost lib]# ls

libmysqlclient.a   libmysqlclient.so.20       libmysqld.a        libmysqlservices.a  pkgconfig

libmysqlclient.so  libmysqlclient.so.20.3.10  libmysqld-debug.a  mecab               plugin

[root@localhost lib]# ln -s libmysqlclient.so.20.3.10 libmysqlclient_r.so

[root@localhost lib]# ls -l

总用量 923956

-rw-r--r-- 1 mysql mysql  20675802 9月   7 23:17 libmysqlclient.a

lrwxrwxrwx 1 root  root         25 9月   8 02:16 libmysqlclient_r.so -> libmysqlclient.so.20.3.10

lrwxrwxrwx 1 mysql mysql        20 9月   7 23:18 libmysqlclient.so -> libmysqlclient.so.20

lrwxrwxrwx 1 mysql mysql        25 9月   7 23:18 libmysqlclient.so.20 -> libmysqlclient.so.20.3.10

-rwxr-xr-x 1 mysql mysql   9587056 9月   7 23:18 libmysqlclient.so.20.3.10

-rw-r--r-- 1 mysql mysql 547940170 9月   7 23:18 libmysqld.a

-rw-r--r-- 1 mysql mysql 367873702 9月   7 23:17 libmysqld-debug.a

-rw-r--r-- 1 mysql mysql     42030 9月   7 23:17 libmysqlservices.a

drwxr-xr-x 4 mysql mysql        28 9月   7 23:18 mecab

drwxr-xr-x 2 mysql mysql        28 9月   7 23:17 pkgconfig

drwxr-xr-x 3 mysql mysql      4096 9月   7 23:18 plugin

建立完连接之后,重新配置php

此次配置成功。

[root@localhost php-5.6.37]# make

[root@localhost php-5.6.37]# make install

配置apache能解析php

修改httpd配置文件

/usr/local/httpd/conf/httpd.conf

1.

#ServerName     www.example.com:80        将这一行的注释去掉,或者将此行改为:ServerName    localhost:80

2.

<Directory />

AllowOverride none

Require all denied            将denied改为granted

</Directory>

3.

<IfModule dir_module>

DirectoryIndex index.html index.php        添加index.php项

</IfModule>

4.

AddType application/x-compress .Z

AddType application/x-gzip .gz .tgz

AddType application/x-httpd-php .php        添加这一行

转载于:https://blog.51cto.com/8469401/2171967

记一次LAMP环境搭建相关推荐

  1. LAMP攻略: LAMP环境搭建,Linux下Apache,MySQL,PHP安装与配置

    之前写过一个red hat 9下的LAMP环境的配置,不过由于版本比较旧,很多不适用了. 所以决定写一个新的LAMP环境搭建与配置教程.本配置是在 CentOS-5.3 下 httpd-2.2.11. ...

  2. 生产环境下的LAMP环境搭建

    生产环境下的LAMP环境搭建 V20 学习猿地  ww.lmonkey.com 一.LAMP环境介绍 Web服务器的主要功能是提供网上信息浏览服务.所有网页的集合被称为网站,网站也只有发布到网上才能被 ...

  3. 基于ECS部署LAMP环境搭建Drupal网站,云计算技术与应用报告

    实验环境: 建站环境:Windows操作系统,基于ECS部署LAMP环境,阿里云资源, Web服务器:Apache,关联的数据库:MySQ PHP:Drupal 8 要求的PHP版本為7.0.33的版 ...

  4. LAMP环境搭建之rpm软件包

    Linux+Apache+Mysql+Perl/PHP/Python一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个 ...

  5. 阿里云ubuntu14.04下lamp环境搭建の备忘

    以下内容大部分来自于网络上的收集,百度搜lamp能搜到很多文字教程.百度lamp搭建 推荐几个视频教程: 在Ubuntu Server下搭建LAMP环境 PHP环境LAMP/LNMP安装与配置 我收藏 ...

  6. LAMP环境搭建教程

    这里介绍一下LAMP环境的搭建,即Linux.Apache.MySQL.PHP环境. 一.首先安装操作系统 操作系统:centos6.3       (Linux平台的系统均可尝试) IP地址: 网关 ...

  7. 记一次docker环境搭建笔记

    记一次docker环境搭建笔记 1.docker安装 2.docker卸载 3.docker镜像制作使用 4.docker其他操作命令补充 1.docker安装 1-1.查看当前的系统的版本(确认下支 ...

  8. LAMP环境搭建之编译安装指南(php-5.3.27.tar.gz)

    测试环境:CentOS release 6.5 (Final) 软件安装:httpd-2.2.27.tar.gz   mysql-5.1.72.tar.gz   php-5.3.27.tar.gz 1 ...

  9. LAMP环境搭建步骤

    我们知道,如果我们安装的是应用服务软件,这个软件是给外网用户访问和使用的,那么应该使用源码包安装,因为源码包安装的软件经过了本机编译,性能更好.所以我们的 LAMP 环境搭建,在生产服务器上一般采用源 ...

最新文章

  1. python 问题不符合dcp rule_约束不遵循CVXPY中的DCP规则
  2. 总经费8.4亿的上海市脑科学重大专项进展如何?且看2019年度工作汇报会
  3. Java 多线程之 synchronized 和 volatile 的比较
  4. HttpURLConnection 中Cookie 使用
  5. 13_Android的生命周期
  6. 洛谷——P1781 宇宙总统
  7. [HEOI2016TJOI2016]排序(二分+线段树)
  8. golang学习之旅(1)
  9. Vijos 1334 ---- NASA的食物计划(01背包强化)
  10. linux修改默认python版本_Linux 升级 Python 并修改默认版本
  11. RHEL5.5学习--LAMP环境的安装顺序及主要软件
  12. java alarm api_JAVA抽象类及接口使用方法解析
  13. C++ 一个简单的基类
  14. 离职盗取代码、倒卖获利800万,北京西二旗程序员被逮捕
  15. 把html转换成PDF的手机软件,如何将MHTML转换为PDF(Convert MHTML to PDF)?
  16. Vue 3为什么要用 Proxy API 替代 DefineProperty API?
  17. 如何实现网易公开课的倍速播放?
  18. 分享两种证件照换背景方法,轻松把照片底色变白
  19. 计算机投针实验程序,蒲丰投针问题
  20. (实测可用)STM32CubeMX教程-STM32L431RCT6开发板研究串口通信(SPI flash)

热门文章

  1. 白话Elasticsearch61-进阶篇之基于Term Vectors深入探查数据的情况
  2. Spring Cloud【Finchley】-02服务发现与服务注册Eureka + Eureka Server的搭建
  3. Spring MVC-10循序渐进之文件下载
  4. java程序有连接数据库_Java程序连接数据库
  5. java对mysql排序_MySQL 排序
  6. WebMvcConfigurerAdapter过时了替代的方法
  7. extjs获取焦点和失去焦点_[NBA夏联]焦点单三连红,NBA夏季联赛同样精彩
  8. Matlab实用程序--图形应用-图形的叠加
  9. 2021-03-12 Python基础核心概念 变量和简单数据类型
  10. cocosc++怎么打印_Lua调用C++时打印堆栈信息