




已阅读5页,还剩10页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
lamp总结第一章 基于httpd加载php模块的方式编译安装lamp1.1 安装二进制mysql环境准备:rootlvs02 tools# pwd/home/oldboy/toolsrootlvs02 tools# ls apr-1.5.2.tar.bz2 apr-util-1.5.4.tar.bz2 httpd-2.4.18.tar.bz2 mysql-5.5.48-linux2.6-x86_64.tar.gz php-5.4.26.tar.gzrootlvs02 tools# tar xf mysql-5.5.48-linux2.6-x86_64.tar.gz -C /usr/local/rootlvs02 tools# cd /usr/local/mysql-5.5.48-linux2.6-x86_64/rootlvs02 mysql-5.5.48-linux2.6-x86_64# ln -s /usr/local/mysql-5.5.48-linux2.6-x86_64 /usr/local/mysqlrootlvs02 local# cd /usr/local/mysqlrootlvs02 mysql# ls bin data include lib mysql-test scripts sql-benchCOPYING docs INSTALL-BINARY man README share support-files初始化数据库rootlvs02 mysql# useradd -s /sbin/nologin -M mysql rootlvs02 mysql# mkdir /data rootlvs02 mysql# scripts/mysql_install_db -datadir=/data -user=mysqlInstalling MySQL system tables.160328 9:51:34 Note ./bin/mysqld (mysqld 5.5.48) starting as process 10595 .OKFilling help tables.160328 9:51:35 Note ./bin/mysqld (mysqld 5.5.48) starting as process 10602 .OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands:./bin/mysqladmin -u root password new-password./bin/mysqladmin -u root -h lvs02 password new-passwordAlternatively you can run:./bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default. This isstrongly recommended for production servers.See the manual for more instructions.You can start the MySQL daemon with:cd . ; ./bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.plcd ./mysql-test ; perl mysql-test-run.plPlease report any problems at /复制mysql的配置文件到/etc/frootlvs02 mysql# cp support-files/f /etc/f cp: overwrite /etc/f? y复制mysql的启动脚本rootlvs02 mysql# cp support-files/mysql.server /etc/init.d/mysqld rootlvs02 mysql# chmod +x /etc/init.d/mysqld更该/etc/f的配置文件vim /etc/f38 datadir=/data 因为我们初始化数据改成了/data目录启动mysqlrootlvs02 mysql# /etc/init.d/mysqld start Starting MySQL. OK 加载mysql客户端登入mysql服务器的环境变量至全局变量rootlvs02 mysql# echo PATH=/usr/local/mysql/bin:$PATH /etc/profilerootlvs02 mysql# . /etc/profile客户端登入mysql,删除不必要的用户rootlvs02 mysql# mysqlWelcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 1Server version: 5.5.48 MySQL Community Server (GPL)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.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 select user,host from mysql.user;+-+-+| user | host |+-+-+| root | | root | :1 | | localhost | root | localhost | | lvs02 | root | lvs02 |+-+-+6 rows in set (0.00 sec)mysql drop user localhost;Query OK, 0 rows affected (0.00 sec)mysql drop user lvs02;Query OK, 0 rows affected (0.00 sec)mysql drop user rootlvs02;Query OK, 0 rows affected (0.00 sec)mysql drop user root;Query OK, 0 rows affected (0.00 sec)mysql drop user root:1;Query OK, 0 rows affected (0.00 sec)mysql select user,host from mysql.user;+-+-+| user | host |+-+-+| root | localhost |+-+-+1 row in set (0.00 sec)给登录mysql的用户设置密码rootlvs02 mysql# mysqladmin -u root password pcwangjixuan登录mysqlrootlvs02 mysql# mysql -u root ppcwangjixuan1.2 编译安装httpd2.4 安装httpd依赖的库rootlvs02 httpd-2.4.18# yum install openssl-devel -yrootlvs02 httpd-2.4.18# yum install pcre-devel -y安装httpd2.4在linux平台运行所需要依赖库aprrootlvs02 tools# ls apr-1.5.2.tar.bz2 apr-util-1.5.4.tar.bz2 httpd-2.4.18.tar.bz2 mysql-5.5.48-linux2.6-x86_64.tar.gz php-5.4.26.tar.gzrootlvs02 tools# tar xf apr-1.5.2.tar.bz2 rootlvs02 tools# ls apr-1.5.2 apr-util-1.5.4.tar.bz2 mysql-5.5.48-linux2.6-x86_64.tar.gzapr-1.5.2.tar.bz2 httpd-2.4.18.tar.bz2 php-5.4.26.tar.gzrootlvs02 tools# cd apr-1.5.2rootlvs02 apr-1.5.2# ./configure -prefix=/usr/local/aprrootlvs02 apr-1.5.2# make & make install安装apr库所依赖的工具apr-utilrootlvs02 tools# ls apr-1.5.2 apr-util-1.5.4.tar.bz2 mysql-5.5.48-linux2.6-x86_64.tar.gzapr-1.5.2.tar.bz2 httpd-2.4.18.tar.bz2 php-5.4.26.tar.gzrootlvs02 tools# tar xf apr-util-1.5.4.tar.bz2 rootlvs02 tools# ls apr-1.5.2 apr-util-1.5.4 httpd-2.4.18.tar.bz2 php-5.4.26.tar.gzapr-1.5.2.tar.bz2 apr-util-1.5.4.tar.bz2 mysql-5.5.48-linux2.6-x86_64.tar.gzrootlvs02 tools# cd apr-util-1.5.4rootlvs02 apr-util-1.5.4# ./configure -prefix=/usr/local/apr-util -with-apr=/usr/local/aprrootlvs02 apr-util-1.5.4# make & make install编译安装httpd2.4rootlvs02 httpd-2.4.18# ./configure -prefix=/usr/local/apache -sysconfdir=/etc/httpd -enable-ssl -enable-cgi -enable-rewrite -with-zlib -with-pcre -with-apr=/usr/local/apr -with-apr-util=/usr/local/apr-util/ -enable-modules=most -enable-mpms-shared=all -with-mpm=eventrootlvs02 httpd-2.4.18# make & make install加载启动httpd服务的环境变量至全局变量rootlvs02 httpd-2.4.18# echo PATH=/usr/local/apache/bin:$PATH /etc/profilerootlvs02 httpd-2.4.18# . /etc/profile启动httpd服务rootlvs02 httpd-2.4.18# apachectl start rootlvs02 httpd-2.4.18# lsof -i :80COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEhttpd 43454 root 4u IPv6 80980 0t0 TCP *:http (LISTEN)httpd 43455 daemon 4u IPv6 80980 0t0 TCP *:http (LISTEN)httpd 43456 daemon 4u IPv6 80980 0t0 TCP *:http (LISTEN)httpd 43457 daemon 4u IPv6 80980 0t0 TCP *:http (LISTEN)浏览器测试httpd是否成功1.3 编译安装php模块加载至httpd中,及连接mysqlrootlvs02 tools# ls apr-1.5.2 apr-util-1.5.4 httpd-2.4.18 mysql-5.5.48-linux2.6-x86_64.tar.gzapr-1.5.2.tar.bz2 apr-util-1.5.4.tar.bz2 httpd-2.4.18.tar.bz2 php-5.4.26.tar.gzrootlvs02 tools# tar xf php-5.4.26.tar.gz rootlvs02 tools# ls apr-1.5.2 apr-util-1.5.4 httpd-2.4.18 mysql-5.5.48-linux2.6-x86_64.tar.gz php-5.4.26.tar.gzapr-1.5.2.tar.bz2 apr-util-1.5.4.tar.bz2 httpd-2.4.18.tar.bz2 php-5.4.26rootlvs02 tools# cd php-5.4.26rootlvs02 php-5.4.26# ./configure -prefix=/usr/local/php/ -with-mysql=/usr/local/mysql -with-openssl -with-mysqli=/usr/local/mysql/bin/mysql_config -enable-mbstring -with-freetype-dir -with-jpeg-dir -with-png-dir -with-zlib -with-libxml-dir=/usr -enable-xml -enable-sockets -with-apxs2=/usr/local/apache/bin/apxs -with-config-file-path=/etc -with-config-file-scan-dir=/etc/php.d -with-bz2 -enable-maintainer-zts -disable-fileinfo-with-mysqli=/usr/local/mysql/bin/mysql_config 连接mysql的另一通道-with-apxs2=/usr/local/apache/bin/apxs 把php编译成模块通过httpd的apxs工具加载至httpd中-enable-maintainer-zts 以为httpd支持的events模型,所以需要此步骤-with-mysql=/usr/local/mysql 连接mysql-disable-fileinfo 因为在虚拟机编译php,内存小于1G,所以需要加此参数rootlvs02 php-5.4.26#make & make install rootlvs02 modules# pwd/usr/local/apache/modulesrootlvs02 modules# ls -l libphp5.so -rwxr-xr-x. 1 root root 25838833 Mar 28 11:12 libphp5.so 从这里看出php的模块加载到了httpd中查看httpd.conf文件已经加载了php的模块rootlvs02 httpd# pwd/etc/httpdrootlvs02 httpd# vim httpd.conf157 LoadModule php5_module modules/libphp5.so复制php的配置文件rootlvs02 php-5.4.26# cp php.ini-production /etc/php.ini 在httpd,conf文件加入下面几行使httpd支持以php结尾的url,并且设置站点首页是index.phprootlvs02 httpd# pwd/etc/httpdrootlvs02 httpd# vim httpd.conf256 257 DirectoryIndex index.php index.html258 378 AddType application/x-httpd-php .php379 AddType application/x-httpd-php-source .phps在站点目录下面设置index.php文件,测试是否能解析以php结尾的urlrootlvs02 htdocs# pwd/usr/local/apache/htdocsrootlvs02 htdocs# vim index.php 通过浏览器测试测试成功1.4 设置一个站点wordpressrootlvs02 httpd# pwd/etc/httpdrootlvs02 httpd# vim httpd.conf223 #DocumentRoot /usr/local/apache/htdocs 关闭中心站点476 Include /etc/httpd/extra/httpd-vhosts.conf 打开包含的配置文件设置一个站点rootlvs02 extra# pwd/etc/httpd/extrarootlvs02 extra# vim httpd-vhosts.conf # Virtual Hosts# Required modules: mod_log_config# If you want to maintain multiple domains/hostnames on your# machine you can setup VirtualHost containers for them. Most configurations# use only name-based virtual hosts so the server doesnt need to worry about# IP addresses. This is indicated by the asterisks in the directives below.# Please see the documentation at # # for further details before you try to setup virtual hosts.# You may use the command line option -S to verify your virtual host# configuration.# VirtualHost example:# Almost any Apache directive may go into a VirtualHost container.# The first VirtualHost section is used for all requests that do not# match a ServerName or ServerAlias in any block.# ServerAdmin 529292664 DocumentRoot /var/www/html/www ServerName ServerAlias ErrorLog logs/www-error_logCustomLog logs/www-access_log common 注意:httpd2.4版本站点目录需要设置黄色部分内容,用户才能访问 Options None Require all granted重启apache服务rootlvs02 www# apachectl graceful在mysql数据库中创建wordpress,并授权用户可以管理wordpressrootlvs02 www# mysql -u root -ppcwangjixuan Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 4Server version: 5.5.48 MySQL Community Server (GPL)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.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 create database wordpress;Query OK, 1 row affected (0.10 sec)mysql grant all on wordpress.* to wordpress192.168.1.% identified by wordpress; Query OK, 0 rows affected (0.13 sec)添加站点wordpressrootlvs02 www# pwd/var/www/html/wwwrootlvs02 www# ls index.php wp-activate.php wp-comments-post.php wp-cron.php wp-load.php wp-settings.php xmlrpc.phplicense.txt wp-admin wp-config-sample.php wp-includes wp-login.php wp-signup.phpreadme.html wp-blog-header.php wp-content wp-links-opml.php wp-mail.php wp-trackback.php更改站点目录里面的配置文件:rootlvs02 www# pwd/var/www/html/wwwrootlvs02 www# vim wp-config.php22 /* WordPress数据库的名称 */ 23 define(DB_NAME, wordpress); 24 25 /* MySQL数据库用户名 */ 26 define(DB_USER, wordpress); 27 28 /* MySQL数据库密码 */ 29 define(DB_PASSWORD, wordpress); 30 31 /* MySQL主机 */ 32 define(DB_HOST, 21);在windows的etc目录下面的host文件里面做域名解析浏览器输入站点目录点击安装wordpress点击登录,输入用户名,密码站点设置成功1.5 为php扩展第三方模块xcache,缓存加速rootlvs02 tools# ls apr-1.5.2 apr-util-1.5.4.tar.bz2 mysql-5.5.48-linux2.6-x86_64.tar.gz xcache-3.2.0apr-1.5.2.tar.bz2 httpd-2.4.18 php-5.4.26 xcache-3.2.0.tar.bz2apr-util-1.5.4 httpd-2.4.18.tar.bz2 php-5.4.26.tar.gzrootlvs02 tools# cd xcache-3.2.0rootlvs02 xcache-3.2.0# /usr/local/php/bin/phpize Configuring for:PHP Api Version: 20100412Zend Module Api No: 20100525Zend Extension Api No: 220100525rootlvs02 xcache-3.2.0# ./configure -enable-xcache -with-php-config=/usr/local/php/bin/php-configrootlvs02 xcache-3.2.0# make & make install查看xcache安装的位置rootlvs02 xcache-3.2.0# ls -l /usr/local/php/lib/php/extensions/no-debug-zts-20100525/total 580-rwxr-xr-x. 1 root root 593765 Mar 28 13:29 xcache.so编辑php.ini ,整合php和xcachemkdir /etc/php.d/cp xcache.ini /etc/php.d/ xcache.ini在xcache的源码目录中在xcache.ini配置文件中更改一行rootlvs02 xcache-3.2.0# vim /etc/php.d/xcache.ini ; this is an example, it wont work unless properly configured into php.inixcache-common; non-Windows example:extension = /usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so重启apacherootlvs02 xcache-3.2.0# apachectl graceful第二章 配置apache-2.4.9与fpm方式的php-5.4.261.1 apache、mysql的安装与上面安装相同1.2 编译安装php-5.4.26停掉之前的httpd服务rootlvs02 # apachectl stop rootlvs02 # lsof -i :80rootlvs02 tools# ls apr-1.5.2 apr-util-1.5.4.tar.bz2 mysql-5.5.48-linux2.6-x86_64.tar.gz xcache-3.2.0apr-1.5.2.tar.bz2 httpd-2.4.18 php-5.4.26 xcache-3.2.0.tar.bz2apr-util-1.5.4 httpd-2.4.18.tar.bz2 php-5.4.26.tar.gzrootlvs02 tools# rm -rf php-5.4.26编译安装phprootlvs02 tools# tar xfv php-5.4.26.tar.gzrootlvs02 php-5.4.26# ./configure -prefix=/usr/local/php/ -with-mysql=/usr/local/mysql -with-openssl -with-mysqli=/usr/local/mysql/bin/mysql_config -enable-mbstring -with-freetype-dir -with-jpeg-dir -with-png-dir -with-zlib -with-libxml-dir=/usr -enable-xml -enable-sockets -enable-fpm -with-config-file-path=/etc -with-config-file-scan-dir=/etc/php.d -with-bz2 -enable-maintainer-zts -disable-fileinfo-enable-fpm 基于fpm的方式安装php为php提供配置文件rootlvs02 php-5.4.26# cp php.ini-production /etc/php.ini为php-fpm提供配置脚本rootlvs02 php-5.4.26# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm为php-fpm提供配置文件rootlvs02 php-5.4.26# cp /usr/local/php5/etc/php-fpm.conf.default /usr/local/php5/etc/php-fpm.conf编辑php-fpm的配置文件rootlvs02 etc# pwd/usr/local/php5/etcrootlvs02 etc# vim php-fpm.conf25 pid = /usr/local/php5/var/run/php-fpm.pid225 pm.max_children = 50230 pm.start_servers = 5235 pm.min_spare_servers = 2240 pm.max_spare_servers = 8启动php-fpmrootlvs02 etc# /etc/init.d/php-fpm start Starting php-fpm donerootlvs02 etc# lsof -i :9000COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEphp-fpm 3342 root 7u IPv4 275489 0t0 TCP localhost:cslistener (LISTEN)php-fpm 3343 nobody 0u IPv4 275489 0t0 TCP localhost:cslistener (LISTEN)php-fpm 3344 nobody 0u IPv4 275489 0t0 TCP localhost:cslistener (LISTEN)php-fpm 3345 nobody 0u IPv4 275489 0t0 TCP localhost:cslistener (LISTEN)php-fpm 3346 nobody 0u IPv4 275489 0t0 TCP localhost:cslistener (LISTEN)php-fpm 3347 nobody 0u IPv4 275489 0t0 TCP localhost:cslistener (LISTEN)默认是监听在本机的9000的端口rootlvs02 etc# netstat -lntup |grep php-fpmtcp 0 0 :9000 :* LISTEN 3342/php-fpm注意:如果apache和php是在不同主机上的话要更改php监听的ip地址:rootlvs02 etc# pwd/usr/local/php5/etcrootlvs02 etc# vim php-fpm.conf159 listen = :9000 监听
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 个体户食品安全培训课件
- 2025年东莞市镇机关大院第一饭堂招聘考试笔试试题【答案】
- 网络信息安全保护与技术咨询服务合同
- 儿童画手工课件图片
- 人物事迹介绍课件下载
- 网络游戏开发保密协议合同书
- 舞蹈教师线上培训课件
- 合肥42中一模数学试卷
- 2026版《全品高考》选考复习方案生物02 第13讲 人造卫星 宇宙速度含答案
- 国际高中九年级数学试卷
- 《思想道德与法治》学习通课后章节答案期末考试题库2025年
- 清廉讲堂活动方案
- 家居落地活动方案
- 2025年医保知识考试题库及答案:医保信息化建设应用法律法规试题
- 环境现场采样培训
- 2025年 汕头市公安局警务辅助人员招聘考试笔试试卷附答案
- 车辆伤害事故桌面功能演练方案、脚本
- 老旧厂房改造-洞察及研究
- XX公司年产10万吨阳极铜及5万吨铜杆项目环境影响报告书
- 陕西省专业技术人员继续教育2025公需课《党的二十届三中全会精神解读与高质量发展》20学时题库及答案
- 财务考试试题及答案大全
评论
0/150
提交评论