LAMP=Linux + Apache + MySQL/MariaDB + PHP
LAMP和LNMP是两种网站解决方案,而LAMP注重安全、更强大,对php的运行较为稳定。LNMP注重性能,处理高并发能力强、负载高。
Apache本身只处理静态页面,动态页面由libphp5.so模块处理。
Apache工作原理:Apache 本身只处理 html 静态语言页面,当客户端需要访问 php 页面的时候,Apache
会调用libphp5.so 这个模块去工作,这个模块会把 php 页面转换成 html 静态页面,让 Apache
处理,Apache处理后,会返回给客户端。
yum安装相关依赖包
[root@localhost ~]# yum -y install make gcc gcc-c++ openssl openssl-devel expat-devel
下载源码包到/usr/local/src/目录下
链接:/d/file/titlepic/1Qgt2ZppyakxOgBR_npR17gbr /> 提取码:8smn
[root@localhost ~]# cd /usr/local/src/[root@localhost src]# lsapr-1.6.2.tar.gz libmcrypt-2.5.8.tar.gz nginx-1.14.1.tar.gzapr-util-1.6.0.tar.gz mcrypt-2.6.8.tar.gz pcre-8.41boost_1_59_0 mhash-0.9.9.9.tar.gz pcre-8.41.tar.gzboost_1_59_0.tar.gz mysql-5.7.19 php-7.1.24httpd-2.4.37.tar.gz mysql-5.7.19.tar.gz php-7.1.24.tar.gzlibiconv-1.14.tar.gz nginx-1.14.1
[root@localhost ~]# cd /usr/local/src/[root@localhost src]# tar xzvf apr-1.6.2.tar.gz [root@localhost src]# cd apr-1.6.2/[root@localhost apr-1.6.2]# ./configure --prefix=/usr/local/apr/[root@localhost apr-1.6.2]# make && 混凝土裂缝的处理make install
[root@localhost ~]# cd /usr/local/src/[root@localhost src]# tar xzvf apr-util-1.6.0.tar.gz[root@l金榜题名对联ocalhost apr-util-1.6.0]# cd apr-util-1.6.0/[root@localhost apr-util-1.6.0]# ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/bin/apr-1-config[root@localhost apr-util-1.6.0]# make && make install
[root@localhost ~]# cd /usr/local/src/[root@localhost src]# tar xzvf pcre-8.41.tar.gz[root@localhost src]# cd pcre-8.41/[root@localhost pcre-8.41]# ./configure --prefix=/usr/local/pcre/[root@localhost pcre-8.41]# make && make install
[root@localhost ~]# cd /usr/local/src/[root@localhost src]# tar xzvf httpd-2.4.37.tar.gz [root@localhost src]# cd httpd-2.4.37/[root@localhost 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[root@localhost httpd-2.4.37]# make && make install
对应指定目录配置
–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路径
生成启动脚本,即是把启动程序放到/etc/init.d/目录下
[root@localhost ~]# cp /usr/local/apache/bin/apachectl /etc/init.d/[root@localhost ~]# chmod +x /etc/init.d/apachectl
调整 Apache系统服务脚本
[root@localhost ~]# 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@localhost ~]# chmod 754 /usr/lib/systemd/system/apache.rvice
启动apache服务并加入开机启动项
[root@bogon init.d]# systemctl restart apache.rvice [root@bogon init.d]# systemctl enabled apache.rvice [root@bogon init.d]# systemctl status apache.rvice ● apache.rvice - apache Loaded: loaded (/usr/lib/systemd/system/apache.rvice; disabled; vendor pret: disabled) Active: active (running) since Thu 2020-07-16 20:34:48 CST; 7s ago Process: 109459 ExecStart=/etc/init.d/apachectl start (code=exited, status=0/SUCCESS) Main PID: 109462 (httpd) Tasks: 82 CGroup: /system.slice/apache.rvice ├─109462 /usr/local/apache/bin/httpd -k start ├─109463 /usr/local/apache/bin/httpd -k start ├─109464 /usr/local/apache/bin/httpd -k start └─109465 /usr/local/apache/bin/httpd -k startJul 16 20:34:48 bogon systemd[1]: Starting apache...Jul 16 20:34:48 bogon apachectl[109459]: AH00558: httpd: Could not reliably determine the rve证书补办r...sageJul 16 20:34:48 bogon systemd[1]: Started apache.Hint: Some lines were ellipsized, u -l to show in full.
[root@bogon init.d]# firewall-cmd --permanent --add-port=80/tcpsuccess[root@bogon init.d]# firewall-cmd --reload success
输入本机IP地址验证apache服务是否正常开启
删除系统自带的boost-、mysql和mariadb-
[root@localhost ~]# yum -y remove boost-* remove mysql mariadb-*
yum安装make依赖包
[root@localhost ~]# yum install -y cmake make gcc gcc-c++ bison ncurs ncurs-devel
创建mysql用户
[root@localhost ~]# groupadd mysql[root@localhost ~]# uradd -M -s /sbin/nologin -g mysql mysql
解压mysql、boost
[root@localhost ~]# cd /usr/local/src[root@localhost src]# tar xzvf mysql-5.7.19.tar.gz[root@localhost src]# tar xzvf boost_1_59_0.tar.gz[root@localhost src]# lsboost_1_59_0 mhash-0.9.9.9.tar.gz pcre-8.41boost_1_59_0.tar.gz mysql-5.7.19 pcre-8.41.tar.gzlibiconv-1.14.tar.gz mysql-5.7.19.tar.gz php-7.1.24.tar.gzlibmcrypt-2.5.8.tar.gz nginx-1.14.1mcrypt-2.6.8.tar.gz nginx-1.14.1.tar.gz
安装目录: /var/lib/mysql
数据目录: /var/lib/mysql/data
[root@localhost ~]# mkdir -p /var/lib/mysql/data[root@localhost ~]# chown -R mysql:mysql /var/lib/mysql/[root@localhost ~]# ll -d /var/lib/mysql/drwxr-xr-x. 3 mysql mysql 18 6月 20 15:31 /var/lib/mysql/
编译前准备
[root@bogon src]# cd mysql-5.6.19/[root@bogon mysql-5.6.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_general_ci
#-DDOWNLOAD_BOOST=1
#-DWITH_BOOST=/usr/local/src/boost_1_59_0
生成二进制并安装
[root@bogon mysql-5.6.19]# make[root@bogon mysql-5.6.19]# make install
[root@master ~]# vim /etc/my.cnf[mysqld]skip-grant-tablesbadir=/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@localhost ~]# 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@localhost 天津大学校历~]# cp /var/lib/mysql/support-files/mysql.rver /etc/init.d/mysqld[root@localhost ~]# /var/lib/mysql/bin/mysqld --initialize-incure --ur=mysql --badir=/var/lib/mysql --datadir=/var/lib/mysql/data
启动mysql服务,加入开机启动项目
[root@localhost ~]# /etc/init.d/mysqld start[root@localhost ~]# chkconfig --add mysqld
若报错,删除数据目录下文件,重新初始化再启动服务
[root@localhost ~]# cd /var/lib/mysql/data/[root@localhost data]# lsauto.cnf ib_buffer_pool ibdata1 ib_logfile0 ib_logfile1[root@localhost data]# rm -rf *[root@localhost data]# /var/lib/mysql/bin/mysqld --initialize-incure --ur=mysql --badir=/var/lib/mysql --datadir=/var/lib/mysql/data2020-07-18 12:14:47 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Plea u --explicit_defaults_for_timestamp rver option (e documentation for more details).[root@localhost data]# /etc/init.d/mysqld startStarting MySQL. SUCCESS!
[root@localhost data]# mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 5Server version: 5.6.19 Source distributionCopyright (c) 2000, 2014, 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> flush privileges;Query OK, 0 rows affected (0.01 c)mysql> t password for root@localhost = password('123456');ERROR 1290 (HY000): The MySQL rver is running with the --skip-grant-tables option so it cannot execute this statementmysql> exitBye
添加epel服务的rpm包
[root@localhost ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-relea-latest-7.noarch.rpmRetrieving http://dl.fedoraproject.org/pub/epel/epel-relea-latest-7.noarch.rpmwarning: /var/tmp/rpm-tmp.xUH15R: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEYPreparing... ################################# [100%]Updating / installing... 1:epel-relea-7-12 ################################# [100%]
yum安装相关依赖包
[root@localhost ~]# 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
[root@localhost ~]# cd /usr/local/src/[root@localhost src]# tar xzvf php-7.1.24.tar.gz
指定php安装配置文件目录
[root@localhost src]# cd php-7.1.24/[root@localhost 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@localhost php宋庄美术馆-7.1.24]# make && make install
[root@localhost ~]# cp /usr/local/src/php-7.1.24/php.ini-production /usr/local/php/php.ini
[root@localhostr ~]# vim /usr/local/apache/conf/httpd.conf 393 AddType application/x-httpd-php .php394 AddType application/x-httpd-php-source .phps
重启apache服务
[root@localhost ~]# systemctl restart apache
创建测试php页面,开放80端口。
[root@localhost ~]# echo "<?php phpinfo(); ?>" > /usr/local/apache/htdocs/index.php[root@localhost ~]# firewall-cmd --permanent --add-port=80/tcpsuccess[root@localhost ~]# firewall-cmd --reload success
打开浏览器输入http://172.20.10.7/index.php
本文地址:https://blog.csdn.net/WX17520510319/article/details/107389923
本文发布于:2023-04-08 20:25:36,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/47ed674fc409ff4cb2059f5bf235a844.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:部署LAMP架构.doc
本文 PDF 下载地址:部署LAMP架构.pdf
留言与评论(共有 0 条评论) |