源码编译安装LAMP

目录

LAMP架构 

 各组件的主要作用如下:

安装apache

另一种方法

安装MySQL 

安装环境依赖包 

配置软件模块 

 修改mysql 配置文件

初始化数据库

安装PHP 

安装软件 

配置软件模块

编译及安装 

LAMP架构应用实例


 

LAMP架构 

LAMP架构是目前成熟的企业网站应用模式之一,指的是协同工作的一整套系统和相关软件,能够提供动态Web站点服务及其应用开发环境。LAMP是一个缩写词,具体包括Linux操作系统、Apache网站服务器、MySQL数据库服务器、PHP(或Perl、Python)网页编程语言。

 各组件的主要作用如下:

LAMP网站服务架构  同时提供静态页面和动态页面能力
Linux 提供网站服务应用的运行环境,也支持Windows作为 AMP 的运行环境
Apache作为前端网站服务,直接面向用户提供网站访问入口,并处理静态页面请求
MySQL 作为后端数据库,用于存储网站的业务数据、账户信息等,并提供访问接口给编程语言程序连接使用SQL语句进行数据的读写
PHP作为编程语言,负责处理解释动态页面文件;并作为中间件,负责沟通前端Web网站服务和后端数据库协同工作

ServerName www.xy101.com:80               #指定网站的主机名

DocumentRoot "/usr/local/httpd/htdocs"    #指定网页根目录的路径

<IfModule dir_module>
    DirectoryIndex abc.html index.html    #指定网站的默认访问的文件顺序,从左往右
</IfModule>


http://www.xy101.com/index.html             URL/URI访问路径
协议     域名                网站根目录 网页文件

http://www.xy101.com/   先访问 -->  http://www.xy101.com/abc.html    --> /usr/local/httpd/htdocs/abc.html
                        没有的话再访问 -->  http://www.xy101.com/index.html    --> /usr/local/httpd/htdocs/index.html


安装apache

[root@l1 ~]# systemctl disable --now firewalld  //关闭防火墙
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@l1 ~]# setenforce 0
[root@l1 ~]# 
[root@l1 ~]# vim /etc/selinux/config   //设置永久关闭

[root@l1 ~]# cd /opt/
[root@l1 opt]# ls
rh
[root@l1 opt]# rm -rf *
[root@l1 opt]# 
[root@l1 opt]# ls
[root@l1 opt]# mkdir apache  //新建一个阿帕奇的目录
[root@l1 opt]# cd apache/
[root@l1 apache]# 
[root@l1 opt]# ls    //把三个软件包拖进去
apache  apr-1.6.2.tar.gz  apr-util-1.6.0.tar.gz  httpd-2.4.29.tar.bz2
[root@l1 opt]# 
[root@l1 opt]# 
[root@l1 apache]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
devtmpfs                 2.4G     0  2.4G    0% /dev
tmpfs                    2.4G     0  2.4G    0% /dev/shm
tmpfs                    2.4G   13M  2.4G    1% /run
tmpfs                    2.4G     0  2.4G    0% /sys/fs/cgroup
/dev/mapper/centos-root   37G  5.2G   32G   15% /
/dev/sr0                 4.5G  4.5G     0  100% /mnt
/dev/sda1               1014M  187M  828M   19% /boot
tmpfs                    476M   20K  476M    1% /run/user/0
[root@l1 apache]# 
[root@l1 apache]# 
[root@l1 apache]# ls /etc/yum.repos.d/
local.repo  repo.bak
[root@l1 apache]# 
[root@l1 apache]# yum install -y gcc gcc-c++ make perl pcre pcre-devel expat-devel
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
软件包 gcc-4.8.5-44.el7.x86_64 已安装并且是最新版本
软件包 gcc-c++-4.8.5-44.el7.x86_64 已安装并且是最新版本
软件包 1:make-3.82-24.el7.x86_64 已安装并且是最新版本
软件包 4:perl-5.16.3-299.el7_9.x86_64 已安装并且是最新版本
软件包 pcre-8.32-17.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 expat-devel.x86_64.0.2.1.0-14.el7_9 将被 安装
---> 软件包 pcre-devel.x86_64.0.8.32-17.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

=================================================================================
 Package             架构           版本                     源             大小
=================================================================================
正在安装:
 expat-devel         x86_64         2.1.0-14.el7_9           local          58 k
 pcre-devel          x86_64         8.32-17.el7              local         480 k

事务概要
=================================================================================
安装  2 软件包

总下载量:538 k
安装大小:1.6 M
Downloading packages:
---------------------------------------------------------------------------------
总计                                                 10 MB/s | 538 kB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : pcre-devel-8.32-17.el7.x86_64                                1/2 
  正在安装    : expat-devel-2.1.0-14.el7_9.x86_64                            2/2 
  验证中      : expat-devel-2.1.0-14.el7_9.x86_64                            1/2 
  验证中      : pcre-devel-8.32-17.el7.x86_64                                2/2 

已安装:
  expat-devel.x86_64 0:2.1.0-14.el7_9       pcre-devel.x86_64 0:8.32-17.el7      

完毕!
[root@l1 apache]# 
[root@l1 apache]# ls
apr-1.6.2.tar.gz  apr-util-1.6.0.tar.gz  httpd-2.4.29.tar.bz2

[root@l1 apache]# tar xf httpd-2.4.29.tar.bz2 //解压三个解压包
[root@l1 apache]# tar xf apr-1.6.2.tar.gz
[root@l1 apache]# tar xf apr-util-1.6.0.tar.gz
[root@l1 apache]# 
[root@l1 apache]# ls
apr-1.6.2         apr-util-1.6.0         httpd-2.4.29
apr-1.6.2.tar.gz  apr-util-1.6.0.tar.gz  httpd-2.4.29.tar.bz2
[root@l1 apache]# 

[root@l1 apache]# cd httpd-2.4.29/
[root@l1 httpd-2.4.29]# ls
ABOUT_APACHE     buildconf       httpd.dsp       libhttpd.mak   README.cmake
acinclude.m4     CHANGES         httpd.mak       LICENSE        README.platforms
Apache-apr2.dsw  CMakeLists.txt  httpd.spec      Makefile.in    ROADMAP
Apache.dsw       config.layout   include         Makefile.win   server
apache_probes.d  configure       INSTALL         modules        srclib
ap.d             configure.in    InstallBin.dsp  NOTICE         support
build            docs            LAYOUT          NWGNUmakefile  test
BuildAll.dsp     emacs-style     libhttpd.dep    os             VERSIONING
BuildBin.dsp     httpd.dep       libhttpd.dsp    README
[root@l1 httpd-2.4.29]# 
[root@l1 httpd-2.4.29]# cd srclib/
[root@l1 srclib]# ls
Makefile.in
[root@l1 srclib]# 

[root@l1 srclib]# pwd
/opt/apache/httpd-2.4.29/srclib
[root@l1 srclib]# cd ../
[root@l1 httpd-2.4.29]# cd ..
[root@l1 apache]# ls
apr-1.6.2         apr-util-1.6.0         httpd-2.4.29
apr-1.6.2.tar.gz  apr-util-1.6.0.tar.gz  httpd-2.4.29.tar.bz2
[root@l1 apache]# mv apr-1.6.2 httpd-2.4.29/srclib/apr   //移动到
[root@l1 apache]# mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util  //移动到
[root@l1 apache]# 

[root@l1 apache]# cd httpd-2.4.29/
[root@l1 httpd-2.4.29]# ls
ABOUT_APACHE     buildconf       httpd.dsp       libhttpd.mak   README.cmake
acinclude.m4     CHANGES         httpd.mak       LICENSE        README.platforms
Apache-apr2.dsw  CMakeLists.txt  httpd.spec      Makefile.in    ROADMAP
Apache.dsw       config.layout   include         Makefile.win   server
apache_probes.d  configure       INSTALL         modules        srclib
ap.d             configure.in    InstallBin.dsp  NOTICE         support
build            docs            LAYOUT          NWGNUmakefile  test
BuildAll.dsp     emacs-style     libhttpd.dep    os             VERSIONING
BuildBin.dsp     httpd.dep       libhttpd.dsp    README
[root@l1 httpd-2.4.29]# 
[root@l1 httpd-2.4.29]# ls srclib/
apr  apr-util  Makefile.in
[root@l1 httpd-2.4.29]# 

./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi

[root@l1 httpd-2.4.29]# make -j 2

 

[root@l1 httpd-2.4.29]# cd /usr/local/httpd/
[root@l1 httpd]# ls   //里面就有阿帕奇的程序目录
bin    cgi-bin  error   icons    lib   man     modules
build  conf     htdocs  include  logs  manual
[root@l1 httpd]# 
[root@l1 httpd]# ls bin/   //可执行程序
ab            apu-1-config  dbmmanage    fcgistarter   htdigest  httxt2dbm
apachectl     apxs          envvars      htcacheclean  htpasswd  logresolve
apr-1-config  checkgid      envvars-std  htdbm         httpd     rotatelogs
[root@l1 httpd]# 

[root@l1 httpd]# cd bin/
[root@l1 bin]# ls
ab            apu-1-config  dbmmanage    fcgistarter   htdigest  httxt2dbm
apachectl     apxs          envvars      htcacheclean  htpasswd  logresolve
apr-1-config  checkgid      envvars-std  htdbm         httpd     rotatelogs
[root@l1 bin]# cp apachectl /etc/init.d/httpd   //apachectl 复制到 /etc/init.d/ 并改名httpd
[root@l1 bin]# 
[root@l1 bin]# cd /etc/init.d/
[root@l1 init.d]# ls
functions  httpd  netconsole  network  README
[root@l1 init.d]# vim httpd 

[root@l1 init.d]# chkconfig --add httpd   //添加httpd
[root@l1 init.d]# cd /usr/local/httpd/
[root@l1 httpd]# ls
bin      conf    icons    logs    modules
build    error   include  man
cgi-bin  htdocs  lib      manual
[root@l1 httpd]# cd conf/
[root@l1 conf]# 
[root@l1 conf]# vim httpd.conf 

[root@l1 conf]# ln -s /usr/local/httpd/bin/* /usr/local/bin/  //软链接
[root@l1 conf]# apachectl -t  //检测阿帕奇语法是否有误
Syntax OK
[root@l1 conf]# 
[root@l1 conf]# service httpd start   //启动服务
[root@l1 conf]# service httpd status  /查看状态
/etc/init.d/httpd: line 100: lynx: command not found
[root@l1 conf]# 

[root@l1 conf]# netstat -lntp | grep :80  //80端口已开启
tcp6       0      0 :::80                   :::*                    LISTEN      43894/httpd         
[root@l1 conf]# 

[root@l1 conf]# service httpd stop  //关闭
[root@l1 conf]# netstat -lntp | grep :80
[root@l1 conf]# 

另一种方法

[root@l1 conf]# netstat -lntp | grep :80
[root@l1 conf]# cd /etc/init.d/
[root@l1 init.d]# ls
functions  httpd  netconsole  network  README
[root@l1 init.d]# rm -f httpd   //删除
[root@l1 init.d]# 
[root@l1 init.d]# netstat -lntp | grep :80
[root@l1 init.d]# cd /usr/lib/systemd/system
[root@l1 system]# vim httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/httpd/logs/httpd.pid
ExecStart=/usr/local/bin/apachectl $OPTIONS
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target

[root@l1 system]# systemctl daemon-reload
[root@l1 system]# systemctl start httpd
[root@l1 system]# netstat -lntp | grep :80
tcp6       0      0 :::80                   :::*                    LISTEN      44672/httpd         
[root@l1 system]# systemctl stop httpd
[root@l1 system]# netstat -lntp | grep :80
[root@l1 system]# 
[root@l1 system]# systemctl enable --now httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@l1 system]# netstat -lntp | grep :80
tcp6       0      0 :::80                   :::*                    LISTEN      44821/httpd         
[root@l1 system]# 

[root@l1 system]# cd /usr/local/httpd/
[root@l1 httpd]# ls
bin    cgi-bin  error   icons    lib   man     modules
build  conf     htdocs  include  logs  manual
[root@l1 httpd]# 
[root@l1 httpd]# cd htdocs
[root@l1 htdocs]# ls
index.html
[root@l1 htdocs]# vim index.html

[root@l1 htdocs]# touch abc.html
[root@l1 htdocs]# ls
abc.html  index.html
[root@l1 htdocs]# cp index.html abc.html
cp:是否覆盖"abc.html"? yes
[root@l1 htdocs]# vim abc.html

安装MySQL 

安装环境依赖包 

[root@l1 htdocs]# yum -y install gcc gcc-c++ ncurses ncurses-devel bison cmake openssl-devel
[root@l1 htdocs]# cd /opt/
[root@l1 opt]# ls
apache
[root@l1 opt]# mkdir mysql
[root@l1 opt]# cd mysql/
[root@l1 mysql]# rz -E
rz waiting to receive.

[root@l1 mysql]# ls
mysql-boost-5.7.44.tar.gz
[root@l1 mysql]# 

[root@l1 mysql]# ls
mysql-boost-5.7.44.tar.gz
[root@l1 mysql]# 
[root@l1 mysql]# tar xf mysql-boost-5.7.44.tar.gz  //解压
[root@l1 mysql]# ls
mysql-5.7.44  mysql-boost-5.7.44.tar.gz
[root@l1 mysql]# cd mysql-5.7.44/
[root@l1 mysql-5.7.44]# ls
boost                extra                mysql-test        sql
BUILD                include              mysys             sql-common
client               INSTALL              mysys_ssl         storage
cmake                libbinlogevents      packaging         strings
CMakeLists.txt       libbinlogstandalone  plugin            support-files
config.h.cmake       libmysql             rapid             testclients
configure.cmake      libmysqld            README            unittest
dbug                 libservices          regex             VERSION
Docs                 LICENSE              scripts           vio
Doxyfile-perfschema  man                  source_downloads  win
[root@l1 mysql-5.7.44]# 

配置软件模块 

3.配置软件模块
tar zxvf mysql-5.7.17.tar.gz
tar zxvf boost_1_59_0.tar.gz

cd /opt
mv boost_1_59_0 /usr/local/boost		#重命名

cd /opt/mysql-5.7.17/
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \		#指定mysql的安装路径
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \ #指定mysql进程监听套接字文件(数据库连接文件)的存储路径
-DSYSCONFDIR=/etc \                             #指定配置文件的存储路径
-DSYSTEMD_PID_DIR=/usr/local/mysql \            #指定进程文件的存储路径
-DDEFAULT_CHARSET=utf8  \                       #指定默认使用的字符集编码,如 utf8
-DDEFAULT_COLLATION=utf8_general_ci \			#指定默认使用的字符集校对规则
-DWITH_EXTRA_CHARSETS=all \						#指定支持其他字符集编码
-DWITH_INNOBASE_STORAGE_ENGINE=1 \              #安装INNOBASE存储引擎
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \               #安装ARCHIVE存储引擎 
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \             #安装BLACKHOLE存储引擎 
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \            #安装FEDERATED存储引擎 
-DMYSQL_DATADIR=/usr/local/mysql/data \         #指定数据库文件的存储路径
-DWITH_BOOST=/usr/local/boost \          #指定boost的路径,若使用mysql-boost集成包安装则-DWITH_BOOST=boost
-DWITH_SYSTEMD=1								#生成便于systemctl管理的文件

存储引擎选项:
MYISAM,MERGE,MEMORY,和CSV引擎是默认编译到服务器中,并不需要明确地安装。
静态编译一个存储引擎到服务器,使用-DWITH_engine_STORAGE_ENGINE= 1
可用的存储引擎值有:ARCHIVE, BLACKHOLE, EXAMPLE, FEDERATED, INNOBASE (InnoDB), PARTITION (partitioning support), 和PERFSCHEMA (Performance Schema)

[root@l1 mysql-5.7.44]# 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_EXTRA_CHARSETS=all \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DMYSQL_DATADIR=/usr/local/mysql/data \
> -DWITH_BOOST=boost \
> -DWITH_SYSTEMD=1
[root@l1 mysql-5.7.44]# make -j 2   //进行编译

[root@l1 mysql-5.7.44]# cd /usr/local/
[root@l1 local]# ls
bin  etc  games  httpd  include  lib  lib64  libexec  mysql  sbin  share  src
[root@l1 local]# useradd -M -s /bin/nologin mysql   //创建用户不创建家目录,指定类型
[root@l1 local]# 
[root@l1 local]# rpm -qa | grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64
[root@l1 local]# yum remove -y mariadb*  //删除mariadb相关内容

 修改mysql 配置文件

[root@l1 local]# vim /etc/my.cnf   //修改mysql 配置文件

修改mysql 配置文件
vim /etc/my.cnf								#删除原配置项,再重新添加下面内容
[client]									#客户端设置
port = 3306
socket = /usr/local/mysql/mysql.sock			

[mysql]										#服务端设置
port = 3306
socket = /usr/local/mysql/mysql.sock
auto-rehash									#开启自动补全功能

[mysqld]									#服务全局设置
user = mysql       							#设置管理用户
basedir=/usr/local/mysql					#指定数据库的安装目录
datadir=/usr/local/mysql/data				#指定数据库文件的存储路径
port = 3306									#指定端口
character-set-server=utf8					#设置服务器字符集编码格式为utf8
pid-file = /usr/local/mysql/mysqld.pid		#指定pid 进程文件路径
socket=/usr/local/mysql/mysql.sock			#指定数据库连接文件
bind-address = 0.0.0.0						#设置监听地址,0.0.0.0代表允许所有,如允许多个IP需空格隔开
skip-name-resolve							#禁止域名解析,包括主机名,所以授权的时候要使用 IP 地址
max_connections=4096						#设置mysql的最大连接数
default-storage-engine=INNODB				#指定默认存储引擎
max_allowed_packet=32M						#设置在网络传输中一次消息传输量的最大值。系统默认值为 1MB,最大值是 1GB,必须设置 1024 的倍数。
server-id = 1								#指定服务ID号

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
[root@l1 local]# ll !$  //修改mysql的归属
ll /etc/my.cnf
-rw-r--r--. 1 root root 625 5月  26 00:15 /etc/my.cnf
[root@l1 local]# ll
总用量 4
drwxr-xr-x.  2 root root 4096 5月  25 11:46 bin
drwxr-xr-x.  2 root root    6 4月  11 2018 etc
drwxr-xr-x.  2 root root    6 4月  11 2018 games
drwxr-xr-x. 15 root root  175 5月  24 16:54 httpd
drwxr-xr-x.  2 root root    6 4月  11 2018 include
drwxr-xr-x.  2 root root    6 4月  11 2018 lib
drwxr-xr-x.  2 root root    6 4月  11 2018 lib64
drwxr-xr-x.  2 root root    6 4月  11 2018 libexec
drwxr-xr-x. 11 root root  177 5月  26 00:07 mysql
drwxr-xr-x.  2 root root    6 4月  11 2018 sbin
drwxr-xr-x.  5 root root   49 4月  30 23:03 share
drwxr-xr-x.  2 root root    6 4月  11 2018 src
[root@l1 local]# 
[root@l1 local]# chown -R mysql:mysql mysql/
[root@l1 local]# ll
总用量 4
drwxr-xr-x.  2 root  root  4096 5月  25 11:46 bin
drwxr-xr-x.  2 root  root     6 4月  11 2018 etc
drwxr-xr-x.  2 root  root     6 4月  11 2018 games
drwxr-xr-x. 15 root  root   175 5月  24 16:54 httpd
drwxr-xr-x.  2 root  root     6 4月  11 2018 include
drwxr-xr-x.  2 root  root     6 4月  11 2018 lib
drwxr-xr-x.  2 root  root     6 4月  11 2018 lib64
drwxr-xr-x.  2 root  root     6 4月  11 2018 libexec
drwxr-xr-x. 11 mysql mysql  177 5月  26 00:07 mysql
drwxr-xr-x.  2 root  root     6 4月  11 2018 sbin
drwxr-xr-x.  5 root  root    49 4月  30 23:03 share
drwxr-xr-x.  2 root  root     6 4月  11 2018 src
[root@l1 local]# 

[root@l1 local]# chown mysql:mysql /etc/my.cnf
[root@l1 local]# ll !$
ll /etc/my.cnf
-rw-r--r--. 1 mysql mysql 625 5月  26 00:15 /etc/my.cnf
[root@l1 local]# 
[root@l1 local]# cd mysql/
[root@l1 mysql]# pwd
/usr/local/mysql
[root@l1 mysql]# ls
bin   include  LICENSE  mysql-test  README-test  support-files
docs  lib      man      README      share        usr
[root@l1 mysql]# ls bin/
innochecksum                mysql_config               mysqlslap
lz4_decompress              mysql_config_editor        mysql_ssl_rsa_setup
myisamchk                   mysqld                     mysqltest
myisam_ftdump               mysqld_pre_systemd         mysqltest_embedded
myisamlog                   mysqldump                  mysql_tzinfo_to_sql
myisampack                  mysqldumpslow              mysql_upgrade
my_print_defaults           mysql_embedded             mysqlxtest
mysql                       mysqlimport                perror
mysqladmin                  mysql_install_db           replace
mysqlbinlog                 mysql_plugin               resolveip
mysqlcheck                  mysqlpump                  resolve_stack_dump
mysql_client_test           mysql_secure_installation  zlib_decompress
mysql_client_test_embedded  mysqlshow
[root@l1 mysql]# 
[root@l1 mysql]# vim /etc/profile

[root@l1 mysql]# 
[root@l1 mysql]# source /etc/profile
[root@l1 mysql]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin
[root@l1 mysql]# 

 

初始化数据库

9.初始化数据库
cd /usr/local/mysql/bin/
./mysqld \
--initialize-insecure \				#生成初始化密码为空
--user=mysql \                      #指定管理用户
--basedir=/usr/local/mysql \        #指定数据库的安装目录
--datadir=/usr/local/mysql/data		#指定数据库文件的存储路径
[root@l1 mysql]# cd bin/
[root@l1 bin]# ls
innochecksum                mysql_config               mysqlslap
lz4_decompress              mysql_config_editor        mysql_ssl_rsa_setup
myisamchk                   mysqld                     mysqltest
myisam_ftdump               mysqld_pre_systemd         mysqltest_embedded
myisamlog                   mysqldump                  mysql_tzinfo_to_sql
myisampack                  mysqldumpslow              mysql_upgrade
my_print_defaults           mysql_embedded             mysqlxtest
mysql                       mysqlimport                perror
mysqladmin                  mysql_install_db           replace
mysqlbinlog                 mysql_plugin               resolveip
mysqlcheck                  mysqlpump                  resolve_stack_dump
mysql_client_test           mysql_secure_installation  zlib_decompress
mysql_client_test_embedded  mysqlshow
[root@l1 bin]# pwd
/usr/local/mysql/bin
[root@l1 bin]# cd /usr/local/mysql/
[root@l1 mysql]# ls
bin   include  LICENSE  mysql-test  README-test  support-files
docs  lib      man      README      share        usr
[root@l1 mysql]# cd usr/
[root@l1 usr]# ls
lib
[root@l1 usr]# cd lib/
[root@l1 lib]# ls
systemd  tmpfiles.d
[root@l1 lib]# cd systemd/
[root@l1 systemd]# ls
system
[root@l1 systemd]# cd system/
[root@l1 system]# pwd
/usr/local/mysql/usr/lib/systemd/system
[root@l1 system]# ls
mysqld.service  mysqld@.service
[root@l1 system]# 
[root@l1 system]# cp mysqld.service /usr/lib/systemd/system   //复制
[root@l1 system]# systemctl daemon-reload   //刷新识别
[root@l1 system]# systemctl start mysqld  //开启服务
[root@l1 system]# systemctl enable mysqld  //开机自启动
Created symlink from /etc/systemd/system/multi-user.target.wants/mysqld.service to /usr/lib/systemd/system/mysqld.service.
[root@l1 system]# 

[root@l1 system]# netstat -lntp | grep :3306  //查看端口
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      67762/mysqld        
[root@l1 system]# 


[root@l1 system]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.44 Source distribution

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> 

[root@l1 system]# mysqladmin -u root password "abc123"  //设置密码为abc123
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
mysqladmin: 
You cannot use 'password' command as mysqld runs
 with grant tables disabled (was started with --skip-grant-tables).
Use: "mysqladmin flush-privileges password '*'" instead
[root@l1 system]# 
[root@l1 system]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.44 Source distribution

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> 

安装PHP 

安装软件 

[root@l1 system]# yum -y install \
> gd \
> libjpeg libjpeg-devel \
> libpng libpng-devel \
> freetype freetype-devel \
> libxml2 libxml2-devel \
> zlib zlib-devel \
> curl curl-devel \
> openssl openssl-devel

[root@l1 system]# cd /opt/
[root@l1 opt]# ls
apache  mysql
[root@l1 opt]# mkdir php
[root@l1 opt]# cd php/
[root@l1 php]# ls

[root@l1 php]# rz -E
rz waiting to receive.
[root@l1 php]# ls
php-7.1.10.tar.bz2
[root@l1 php]# 

[root@l1 php]# tar xf php-7.1.10.tar.bz2   //解压
[root@l1 php]# ls
php-7.1.10  php-7.1.10.tar.bz2
[root@l1 php]# cd php-7.1.10/
[root@l1 php-7.1.10]# ls
acinclude.m4      makedist                      README.SELF-CONTAINED-EXTENSIONS
aclocal.m4        Makefile.frag                 README.STREAMS
appveyor          Makefile.gcov                 README.SUBMITTING_PATCH
build             Makefile.global               README.TESTING
buildconf         makerpm                       README.TESTING2
buildconf.bat     missing                       README.UNIX-BUILD-SYSTEM
CODING_STANDARDS  mkinstalldirs                 README.WIN32-BUILD-SYSTEM
config.guess      netware                       run-tests.php
config.sub        NEWS                          sapi
configure         pear                          scripts
configure.in      php7.spec.in                  server-tests-config.php
CONTRIBUTING.md   php.gif                       server-tests.php
CREDITS           php.ini-development           snapshot
ext               php.ini-production            stamp-h.in
EXTENSIONS        README.EXT_SKEL               stub.c
footer            README.GIT-RULES              tests
generated_lists   README.input_filter           travis
genfiles          README.MAILINGLIST_RULES      TSRM
header            README.md                     UPGRADING
INSTALL           README.namespaces             UPGRADING.INTERNALS
install-sh        README.NEW-OUTPUT-API         vcsclean
LICENSE           README.PARAMETER_PARSING_API  win32
ltmain.sh         README.REDIST.BINS            Zend
main              README.RELEASE_PROCESS
[root@l1 php-7.1.10]# 

配置软件模块

配置软件模块
cd /opt
tar xf php-7.1.10.tar.bz2
cd /opt/php-7.1.10/
./configure \
--prefix=/usr/local/php \							#指定将 PHP 程序的安装路径
--with-apxs2=/usr/local/httpd/bin/apxs \			#指定Apache httpd服务提供的apxs 模块支持程序的文件位置
--with-mysql-sock=/usr/local/mysql/mysql.sock \		#指定mysql 数据库连接文件的存储路径
--with-config-file-path=/usr/local/php/lib			#设置 PHP 的配置文件 php.ini 将要存放的位置
--with-mysqli \										#添加 MySQL 扩展支持,mysqli扩展技术不仅可以调用MySQL的存储过程、处理MySQL事务,而且还可以使访问数据库工作变得更加稳定
--with-zlib \										#支持zlib功能,提供数据压缩
--with-curl \										#开启curl扩展功能,实现HTTP的Get下载和Post请求的方法
--with-gd \											#激活gd 库的支持
--with-jpeg-dir \									#激活jpeg 的支持
--with-png-dir \									#激活png 的支持
--with-freetype-dir \
--with-openssl \
--enable-mbstring \									#启用多字节字符串功能,以便支持中文等代码
--enable-xml \										#开启扩展性标记语言模块
--enable-session \									#会话
--enable-ftp \										#文本传输协议
--enable-pdo \										#函数库
--enable-tokenizer \								#令牌解释器
--enable-zip										#ZIP压缩格式

[root@l1 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-config-file-path=/usr/local/php/lib \
> --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

编译及安装 

 

[root@l1 php-7.1.10]# make install

[root@l1 php-7.1.10]# cd /usr/local/
[root@l1 local]# ls
bin  games  include  lib64    mysql  sbin   src
etc  httpd  lib      libexec  php    share
[root@l1 local]# cd php/
[root@l1 php]# ls
bin  etc  include  lib  php  var
[root@l1 php]# ls bin/
[root@l1 php]# ln -s /usr/local/php/bin/* /usr/local/bin/   //软链接

[root@l1 php]# cd /opt/
[root@l1 opt]# cd php/
[root@l1 php]# ls
php-7.1.10  php-7.1.10.tar.bz2
[root@l1 php]# 
[root@l1 php-7.1.10]# ls
acinclude.m4      LICENSE                   README.namespaces
aclocal.m4        ltmain.sh                 README.NEW-OUTPUT-API
appveyor          main                      README.PARAMETER_PARSING_API
build             makedist                  README.REDIST.BINS
buildconf         Makefile                  README.RELEASE_PROCESS
buildconf.bat     Makefile.frag             README.SELF-CONTAINED-EXTENSIONS
CODING_STANDARDS  Makefile.fragments        README.STREAMS
config.guess      Makefile.gcov             README.SUBMITTING_PATCH
config.log        Makefile.global           README.TESTING
config.nice       Makefile.objects          README.TESTING2
config.status     makerpm                   README.UNIX-BUILD-SYSTEM
config.sub        meta_ccld                 README.WIN32-BUILD-SYSTEM
configure         missing                   run-tests.php
configure.in      mkinstalldirs             sapi
CONTRIBUTING.md   modules                   scripts
CREDITS           netware                   server-tests-config.php
ext               NEWS                      server-tests.php
EXTENSIONS        pear                      snapshot
footer            php7.spec                 stamp-h.in
generated_lists   php7.spec.in              stub.c
genfiles          php.gif                   tests
header            php.ini-development       travis
include           php.ini-production        TSRM
INSTALL           README.EXT_SKEL           UPGRADING
install-sh        README.GIT-RULES          UPGRADING.INTERNALS
libphp7.la        README.input_filter       vcsclean
libs              README.MAILINGLIST_RULES  win32
libtool           README.md                 Zend
[root@l1 php-7.1.10]# 

[root@l1 php-7.1.10]# php --ini
Configuration File (php.ini) Path: /usr/local/php/lib
Loaded Configuration File:         (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)
[root@l1 php-7.1.10]# 
[root@l1 php-7.1.10]# cp php.ini-production /usr/local/php/lib/php.ini
[root@l1 php-7.1.10]# cd /usr/local/php/lib/
[root@l1 lib]# ls
php  php.ini
[root@l1 lib]# vim php.ini 

[root@l1 lib]# cd /usr/local/httpd/
[root@l1 httpd]# ls
bin    cgi-bin  error   icons    lib   man     modules
build  conf     htdocs  include  logs  manual
[root@l1 httpd]# cd conf/
[root@l1 conf]# ls
extra  httpd.conf  httpd.conf.bak  magic  mime.types  original
[root@l1 conf]# 
[root@l1 conf]# vim httpd.conf

 

[root@l1 conf]# systemctl restart httpd  //重启
[root@l1 conf]# ls
extra  httpd.conf  httpd.conf.bak  magic  mime.types  original
[root@l1 conf]# 
[root@l1 conf]# cd ..
[root@l1 httpd]# ls
bin    cgi-bin  error   icons    lib   man     modules
build  conf     htdocs  include  logs  manual
[root@l1 httpd]# cd htdocs/
[root@l1 htdocs]# ls
abc.html  index.html
[root@l1 htdocs]# 

[root@l1 htdocs]# vim index.php

 

LAMP架构应用实例

[root@l1 conf]# cd /opt/
[root@l1 opt]# ls
apache  mysql  php
[root@l1 opt]# rz -E  //传文件
rz waiting to receive.
[root@l1 opt]# ls
apache  Discuz_X3.4_SC_UTF8.zip  mysql  php  wordpress-4.9.4-zh_CN.tar.gz
[root@l1 opt]# 

[root@l1 opt]# unzip Discuz_X3.4_SC_UTF8.zip  //解压
[root@l1 opt]# ls
apache       Discuz_X3.4_SC_UTF8.zip  php                           说明.htm
dir_SC_UTF8  mysql                    wordpress-4.9.4-zh_CN.tar.gz

[root@l1 opt]# cd dir_SC_UTF8/
[root@l1 dir_SC_UTF8]# ls
readme  upload  utility
[root@l1 dir_SC_UTF8]# 
[root@l1 dir_SC_UTF8]# 

[root@l1 dir_SC_UTF8]# ls upload/
admin.php  connect.php      group.php  member.php  search.php  uc_server
api        crossdomain.xml  home.php   misc.php    source
api.php    data             index.php  plugin.php  static
archiver   favicon.ico      install    portal.php  template
config     forum.php        m          robots.txt  uc_client
[root@l1 dir_SC_UTF8]# ls
readme  upload  utility
[root@l1 dir_SC_UTF8]# cp -a upload/ /usr/local/httpd/htdocs/discuz
[root@l1 dir_SC_UTF8]# cd /usr/local/httpd/htdocs/
[root@l1 htdocs]# ls
abc.html  discuz  index.html  index.php
[root@l1 htdocs]# mysql -u root -pabc123
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> create database discuz;
Query OK, 1 row affected (0.00 sec)

mysql> 
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| discuz             |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值