源码包下载
httpd下载:http://archive.apache.org/dist/httpd/httpd-2.4.37.tar.gz
php下载:https://www.php.net/distributions/php-7.1.24.tar.gz
mysql下载:http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.7/
其他依赖包安装
http://archive.apache.org/dist/apr/apr-1.6.2.tar.gz
http://archive.apache.org/dist/apr/apr-util-1.6.0.tar.gz
http://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz
源码包下载后放在**/usr/local/src/**路径下
# 下载httpd[root@master src]# wget /d/file/titlepic/httpd-2.4.37.tar.gz 下载Apache依赖包[root@master src]# wget http://archive.apache.org/dist/apr/apr-1.6.2.tar.gz[root@master src]# wget /d/file/titlepic/apr-util-1.6.0.tar.gz 下载pcre包[root@master src]# wget http://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz# 查看已下载的包[root@localhost ~]# cd /usr/local/src/[root@localhost src]# ls[root@master src]# lsapr-1.6.2.tar.gz libiconv-1.14.tar.gz mysql-5.7.19.tar.gz zabbix-3.4.3.tar.gzapr-util-1.6.0.tar.gz libmcrypt-2.5.8.tar.gz nginx-1.14.1.tar.gzboost_1_59_0.tar.gz mcrypt-2.6.8.tar.gz pcre-8.41.tar.gzhttpd-2.4.37.tar.gz mhash-0.9.9.9.tar.gz php-7.1.24.tar.gz
# 安装前准备[root@master ~]# yum -y install make gcc gcc-c++ openssl openssl-devel expat-devel# apr包编译环境准备及编译[root@master src]# tar xzvf apr-1.6.2.tar.gz[root@master src]# cd apr-1.6.2/[root@master apr-1.6.2]# ./configure --prefix=/usr/local/apr/[root@master apr-1.6.2]# make && make install# apr-utils包编译环境准备及编译[root@master apr-1.6.2]# cd ..[root@master src]# tar xzvf apr-util-1.6.0.tar.gz[root@master apr-util-1.6.0]# cd apr-util-1.6.0/[root@master apr-util-1.6.0]# ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/bin/apr-1-config[root@master apr-util-1.6.0]# make && make install# pcre包编译环境准备及编译[root@master apr-util-1.6.0]# cd ..[root@master src]# tar xzvf pcre-8.41.tar.gz[root@master src]# cd pcre-8.41/[root@master pcre-8.41]# ./configure --prefix=/usr/local/pcre/[root@master pcre-8.41]# make && make install# Apache编译前环境准备及编译[root@master pcre-8.41]# cd ..[root@master src]# tar xzvf httpd-2.4.37.tar.gz[root@master src]# cd httpd-2.4.37/[root@master httpd-2.4.37]# ./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --enable-ssl --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --enable-modules=most --enable-mpms-shared=all --with-mpm=event# --prefix=/usr/local/apache #安装路径# --enable-so #支持动态加载模块# --enable-rewrite #支持网站地址重写# --enable-ssl #支持SSL加密# --with-pcre=/usr/local/pcre #pcre 路径# --with-apr=/usr/local/apr #apr路径# --with-apr-util=/usr/local/apr-util 寓言四则教案 #apr-util路径[root@master httpd-2.4.37]# make && make install
# 查看httpd配置文件[root@master ~]# ll /usr/local/apache/conf/httpd.conf -rw-r--r--. 1 root root 18535 6月 20 21:27 /usr/local/apache/中秋节幽默短信conf/httpd.conf# 查看httpd网站根目录[root@master ~]# ls /usr/local/apache/htdocs/index.html# 生成启动脚本,即是把启动程序放到/etc/init.d/目录下[root@master ~]# cp /usr/local/apache/bin/apachectl /etc/init.d/[root@master ~]# chmod +x /etc/init.d/apachectl# Apache系统服务脚本,权限为754,以便使用systemctl命令管理服务[root@master ~]# vim /usr/lib/systemd/system/apache.rvice[Unit]Description=apacheAfter=network.target[Service]Type=forkingExecStart=/etc/init.d/apachectl startExecReload=/etc/init.d/apachectl restartExecStop=/etc/init.d/apachectl stopPrivateTmp=true[Install]WantedBy=multi-ur.target[root@master ~]# chmod 754 /usr/lib/systemd/system/apache.rvice# 启动apache服务,并设置自启动[root@master ~]# /etc/init.d/apachectl startAH00558: httpd: Could not reliably determine the rver's fully qualified domain name, using fe80::10f0:9c1d:4678:d1de. Set the 'ServerName' directive globally to suppress this messagehttpd (pid 21416) already running#出现上面的报错信息,需要修改httpd.conf配置文件中的“ServerName”[root@master ~]# vim /usr/local/apache/conf/httpd.conf#ServerName www.example.com:80ServerName localhost:80# 重启Apache后,报错消除[root@master ~]# /etc/init.d/apachectl restart# 启动apache服务,并设置自启动[root@master ~]# systemctl start apache[root@master ~]# systemctl enable apacheCreated symlink from /etc/systemd/system/multi-ur.target.wants/apache.rvice to /usr/lib/systemd/system/apache.rvice.[root@master ~]# ps aux | grep apacheroot 26130 0.0 0.2 72812 2196 ? Ss 16:18 0:00 /usr/local/apache/bin/httpd -k startapache 26131 0.0 0.4 361776 4172 ? Sl 16:18 0:00 /usr/local/apache/bin/httpd -k startapache 26132 0.0 0.4 361776 4172 ? Sl 16:18 0:00 /usr/local/apache/bin/httpd -k startapache 26133 0.0 0.4 361776 4172 ? Sl 16:18 0:00 /usr/local/apache/bin/httpd -k startroot 26240 0.0 0.0 112812 972 pts/1 R+ 16:18 0:00 grep --color=auto apache# 创建用户apache,用来运行httpd服务,修改httpd服务的配置文件,设置运行用户名和组名为apache[root@master ~]# uradd -M -s /sbin/nologin apache[root@master ~]# vim /usr/local/apache/conf/httpd.conf166 Ur apache167 Group apache# 修改源码包安装位置的用户权限,所有者和所属组为apache[root@master ~]# chown -R apache:apache /usr/local/apache/# 清空防火墙,用IP地址在浏览器上测试# 若不清空防火墙,用iptables或者firewall开放http服务的80端口号也是可以的,这里为了方便,直接清空了。[root@master ~]# iptables -F[root@master ~]# systemctl stop firewalld[root@master ~]# systemctl disable firewalldRemoved symlink /etc/systemd/system/multi-ur.target.wants/firewalld.rvice.Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.rvice.# 出现以下界面,表示httpd服务已经安装成功了。
# 删除系统自带的boost-*[root@master ~]# yum -y remove boost-*# 删除系统自带的mysql和mariadb-*[root@master ~]# yum -y remove mysql mariadb-*# 安装mysql依赖包[root@master ~]# yum install -y cmake make gcc gcc-c++ bison ncurs ncurs-devel# 创建mysql组和mysql用户[root@master ~]# groupadd mysql[root@master ~]# uradd -M -s /sbin/nologin -g mysql mysql
# 解压boost包和mysql包[root@master ~]# cd /usr/local/srcroot@master src]# tar xzvf mysql-5.农奴制改革7.19.tar.gzroot@master src]# tar xzvf boost_1_59_0.tar.gz[root@master src]# lsapr-1.6.2 boost_1_59_0.tar.gz mcrypt-2.6.8.tar.gz pcre-8.41apr-1.6.2.tar.gz httpd-2.4.37 mhash-0.9.9.9.tar.gz pcre-8.41.tar.gzapr-util-1.6.0 httpd-2.4.37.tar.gz mysql-5.7.19 php-7.1.24.tar.gzapr-util-1.6.0.tar.gz libiconv-1.14.tar.gz mysql-5.7.19.tar.gz zabbix-3.4.3.tar.gzboost_1_59_0 libmcrypt-2.5.8.tar.gz nginx-1.14.1.tar.gz
# 规划安装目录# 数据目录最好是一个单独的分区或者RAID或者LVM,便于日后的磁盘维护和扩容# 对于读写频繁的业务,可采用SSD固态硬盘存储数据安装目录: /var/lib/mysql数据目录: /var/lib/mysql/data[root@master src]# mkdir -p /var/lib/mysql/data[root@master src]# chown -R mysql:mysql /var/lib/mysql/[root@master src]# ll -d /var/lib/mysql/drwxr-xr-x. 3 mysql mysql 18 Jul 15 16:30 /var/lib/mysql/
[root@master mysql-5.7.19]# pwd/usr/local/src/mysql-5.7.19# 编译前准备,整个mysql的编译过程耗时较长,需要耐心等待哦[root@master mysql-5.7.19]# cmake -DCMAKE_INSTALL_PREFIX=/var/lib/mysql -DMYSQL_DATADIR=/var/lib/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/src/boost_1_59_0# -DCMAKE_INSTALL_PREFIX=/var/lib/mysql 指定MySQL程序的安装目录,默认/usr/local/mysql# -DMYSQL_DATADIR=/var/lib/mysql/data 数据文件目录# -DSYSCONFDIR=/etc 初始化参数文件目录# -DWITH_MYISAM_STORAGE_ENGINE=1 指定静态编译到 mysql 的存储引擎,MyISAM,MERGE# -DWITH_INNOBASE_STORAGE_ENGINE=1 # -DWITH_MEMORY_STORAGE_ENGINE=1 # -DWITH_READLINE=1 # -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock socket文件路径,默认/tmp/mysql.sock# -DMYSQL_TCP_PORT=3306 服务端口号,默认 3306# -DENABLED_LOCAL_INFILE=1 指定是否允许本地执行# -DWITH_PARTITION_STORAGE_ENGINE=1 # -DEXTRA_CHARSETS=all # -DDEFAULT_CHARSET=utf8 指定服务器默认字符集,默认 latin1# -DDEFAULT_COLLATION=utf8_general_ci 指定服务器默认的校对规则,默认 latin1_ge中医是什么neral_ci# -DDOWNLOAD_BOOST=1 # -DWITH_BOOST=/usr/local/src/boost_1_59_0# 编译# -j 用来指定CPU核心数,可加快编译速度。 加 -j 4 用4核心来编译的,可以提高编译速度;要确定CPU有多少核先。# 查看服务器 CPU 核心数[root@master mysql-5.7.19]# grep processor /proc/cpuinfo | wc -l1[root@master mysql-5.7.19]# make -j 1# 编译安装[root@master mysql-5.7.19]# make install
# 修改mysql配置文件[root@master ~]# vim /etc/my.cnf[mysqld]badir=/var/lib/mysqldatadir=/var/lib/mysql/dataport=3306socket=/var/lib/mysql/mysql.sockcharacter-t-rver=utf8log-error=/var/log/mysqld.logpid-file=/tmp/mysqld.pid[mysql]socket=/var/lib/mysql/mysql.sock [client]socket=/var/lib/mysql/mysql.sock
# 添加环境变量[root@master ~]# vim /etc/profile.d/mysql.shexport PATH=/var/lib/mysql/bin:$PATH# 使环境变量生效root@master ~]# chmod +x /etc/profile.d/mysql.sh # 生成服务启动脚本[root@master ~]# /etc/profile.d/mysql.sh # 如果上一步的生成服务启动脚本的命令没有执行,下一步就会复制不到[root@maste率的多音字r ~]# cp /var/lib/mysql/support-files/mysql.rver /etc/init.d/mysqld# 初始化数据库[root@master ~]# /var/lib/mysql/bin/mysqld --initialize-incure --ur=mysql --badir=/var/lib/mysql --datadir=/var/lib/mysql/data# 启动mysqld服务[root@master ~]# /etc/init.d/mysqld startStarting MySQL.. ERROR! The rver quit without updating PID file (/tmp/mysqld.pid).# 若报错,删除数据目录下文件,重新初始化再启动服务[root@master ~]# cd /var/lib/mysql/data/[root@master data]# lsauto.cnf ib_buffer_pool ibdata1 ib_logfile0 ib_logfile1[root@master data]# rm -f *[root@master data]# /var/lib/mysql/bin/mysqld --initialize-incure --ur=mysql --badir=/var/lib/mysql --datadir=/var/lib/mysql/data[root@master data]# /etc/init.d/mysqld startStarting MySQL. SUCCESS! # 登录mysql并设置root用户密码[root@master ~]# mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.7.19 Source distributionCopyright (c) 2000, 2017, Oracle and/or its affiliates. All rights rerved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> t password for root@localhost = password('123456');Query OK, 0 rows affected, 1 warning (0.00 c)mysql> flush privileges;Query OK, 0 rows affected (0.00 c)mysql> exitBye[root@master ~]#
到这一步,MySQL已安装部署成功。
# 添加epel服务的rpm包[root@master ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-relea-latest-7.noarch.rpm获取http://dl.fedoraproject.org/pub/epel/epel-relea-latest-7.noarch.rpm准备中... (10################################# [100%]软件包 epel-relea-7-12.noarch 已经安装# epel已安装后,可不运行以下两个命令。[root@master ~]# yum clean all[root@master ~]# yum list# 解决包依赖[root@master ~]# yum -y install php-mcrypt libmcrypt libmcrypt-devel autoconf freetype gd libmcrypt libpng libpng-devel libjpeg libxml2 libxml2-devel zlib curl curl-devel re2c php-pear
# 解压php源码包[root@master ~]# cd /usr/local/src/[root@master src]# tar xzvf php-7.1.24.tar.gz # 编译前准备[root@master src]# cd php-7.1.24/[root@master php-7.1.24]# ./configure --prefix=/usr/local/php/ --with-apxs2=/usr/local/apache/bin/apxs --enable-mbstring --with-curl --with-gd --enable-fpm --enable-mysqlnd --with-pdo-mysql=mysqlnd --with-config-file-path=/usr/local/php/etc/ --with-mysqli=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --enable-maintainer-zts# --with-apxs2 #将 php 编译为 Apache 的一个模块进行使用# --enable-mbstring #多字节字符串的支持# --with-curl #支持 cURL# --with-gd #支持 gd 库# --enable-fpm #支持构建 fpm# --enable-mysqlnd #启用 mysqlnd# --with-pdo-mysql #支持 pdo:MySQL 支持# --with-config-file-path #设置配置文件路径# --with-mysqli #支持 MySQLi# --with-mysql-sock #关联 mysql 的 socket 文件# --enable-maintainer-zts #如果 Apache 是 event 模型,那需要指定 zts# 编译并安装[root@master php-7.1.24]# make -j 1 && make install
#生成php自身配置文件[root@master ~]# cp /usr/local/src/php-7.1.24/php.ini-production /usr/local/php/php.ini# 编辑Apache的配置文件,以支持php[root@master ~]# vim /usr/local/apache/conf/httpd.conf 393 AddType application/x-httpd-php .php394 AddType application/x-httpd-php-source .phps# 重启apache服务[root@master ~]# systemctl restart apache#在重启apache服务的时候,若是报错。可以使用命令systemctl status apache看看因为什么报错。# 我这里是因为nginx占用了80端口号,暂时停掉nginx服务。[root@master ~]# netstat -antup | grep nginxtcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 9362/nginx: master [root@master ~]# /etc/init.d/nginx stop[root@master ~]# netstat -antup | grep nginx[root@master ~]# systemctl restart apache# 创建测试php页面,并清空防火墙。# 如果不清空防火墙,也可以开放http服务的80端口号。[root@master ~]# echo "<?php phpinfo(); ?>" > /usr/local/apache/htdocs/index.php[root@master ~]# iptables -F# 打开地址,可以看到下图界面,说明LAMP已经安装完毕了。http://192.168.164.102/index.php
参考文档:https://blog.csdn.net/weixin_36522099/article/details/106889068
本文地址:https://blog.csdn.net/qq_38566096/article/details/107356778
本文发布于:2023-04-08 20:14:43,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/5d0d0d950c2cf419d05575a8e0f151bf.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:LAMP环境部署(CentOS7+源码包).doc
本文 PDF 下载地址:LAMP环境部署(CentOS7+源码包).pdf
留言与评论(共有 0 条评论) |