lamp和lnmp环境的搭建

本次的实验环境是

LAMP环境的搭建

首先安装apache 

Apache的编译安装
rz -y(从主机上传软件包)
#wget http://mirrors.bit.edu.cn/apache/httpd-2.2.7.tar.gz
tar xvf httpd-2.2.27.tar.gz
cd httpd-2.2.27
yum install -y zlib zlib-devel
./configure \
--prefix=/application/apache \
#指定软件安装目录
--enable-deflate \
#提供对内容的压缩传输编码支持,使用此参数功能会大大提升传输速度,提升访问者的访问体验,在生产环境中,这是apache调优的一个重要选项
--enable-expires \
#激活允许通过配置文件控制HTTP的"Expires:"和"Cache-Control:"头内容,即对网站图片,js,css等内容,提供在客户端浏览器缓存设置,这是apache调优的一个重要选项
--enable-headers \
#提供允许对HTTP请求头的控制
--enable-modules=most \
--enable-so \
#激活apache服务的DSO(动态共享对象)的支持,即在以后可以以DSO方式编译安装共享模块
--with-mpm=worker \
#选择apache mpm模式为worker模式,因为worker模式的原理是更多的使用线程来处理请求,所以可以处理更多的并发请求
--enable-rewrite
#提供基于URL规则的重写功能,即工具已知URL地址,转换成其他想要的URL地址,这是apache的一个重要的功能
make
make install

ln -s /application/apache2.2.27 /application/apache

启动apache服务
/application/apache/bin/apachectl start

/application/apache/bin/apachectl -t 检查语法

重启apache服务
/application/apache/bin/apachectl graceful

MYSQL的编译安装

mysql下载地址:http://www.mysql.com

groupadd mysql
useradd mysql -g mysql -M -s /sbin/nologin

#可以从官网下载mysql软件包
rz -y
tar xvf mysql-5.1.72.tar.gz
yum -y install ncurses-devel
cd mysql-5.1.72

./configure \
--prefix=/application/mysql5.1.72 \
--with-unix-socket-path=/application/mysql5.1.72/tmp/mysql.sock \
--localstatedir=/application/mysql5.1.72/data \
--enable-assembler \
--enable-thread-safe-client \
--with-mysqld-user=mysql \
--with-big-tables \
--without-debug \
--with-pthread \
--enable-assembler \
--with-extra-charsets=complex \
--with-readline \
--with-ssl \
--with-embedded-server \
--enable-local-infile \
--with-plugins=partition,innobase \
--with-mysqld-ldflages=-all-static \
--with-client-ldflages=-all-static \
#--with-plugin-PLUGIN \
ln -s /application/mysql5.1.72/ /application/mysql

如果web服务和mysql不在同一台机子,则进行如下操作,可以不用如下操作

cd /home/oldboy/tools/mysql-5.1.72/support-files/
cp my-small.cnf /etc/my.cnf
创建mysql数据库文件
mkdir -p /application/mysql/data #建立mysql数据库目录
chown -R mysql.mysql /application/mysql/ #授权mysql用户访问mysql的安装目录

#安装初始化mysql数据库文件
/application/mysql/bin/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql

/application/mysql/bin/mysqld_safe & 启动mysql数据库
mysqladmin shutdown 关闭mysql数据库

/application/mysql/bin/mysql 进入mysql数据库

php的安装

安装前环境准备:
1.确认apache和mysql是否正常
2.查看apache和mysql是否在/application目录
ll /application/apache/
ll /application/mysql/
3检查安装PHP所需的lib库
rpm -qa zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel
yum install -y zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel
安装libiconv库
cd /home/oldboy/tools
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar xvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make
make install
cd ../
yum install openssl openssl-devel -y
yum install libxslt libxslt-devel -y

安装PHP:
rz -y(从主机下载php-5.3.27.tar.gz)
下载地址http://php.net/releases
tar xvf php-5.3.27.tar.gz
cd php-5.3.27

./configure \
--prefix=/application/php5.3.27 \ 表示指定安装php的路径为/application/php5.3.27
--with-apxs2=/application/apache/bin/apxs \ 这个需要apache的bin/apxs路径,通过apxs路径扩展模块到apache中
--with-mysql=/application/mysql \ 这个需要指定mysql的安装路径
#可以通过执行./configure -help,命令来详细查看以上个参数的用途
--with-xmlrpc \
--with-openssl \
--with-zlib \
--with-freetype-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-iconv=/usr/local/libiconv \
--enable-short-tags \
--enable-sockets \
--enable-zend-multibyte \
--enable-soap \
--enable-mbstring \
--enable-static \
--enable-gd-native-ttf \
--with-curl \
--with-xsl \
--enable-ftp \
--with-libxml-dir

make && make install

ln -s /application/php5.3.27/ /application/php

LNMP环境的搭建

Nginx的编译安装:
1.cd /home/oldboy
2.mkdir tools
3.cd tools
4.yum install pcre pcre-devel -y
5.yum install openssl openssl-devel -y
6.#wget -q http://nginx/org/download/nginx-1.6.3.tar.gz
wget -q http://nginx.org/download/nginx-1.8.1.tar.gz
7.useradd www -s /sbin/nologin -M
8.tar xf nginx-1.8.1.tar.gz
9.cd nginx-1.8.1
10.useradd -s /sbin/nologin -M www
10. ./configure --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --prefix=/application/nginx-1.8.1
参数:--prefix=PATH 设置暗转路径
--user=USER 远程用户权限
--group=GROUP 远程用户组权限
--with-http_ssl_module 激活ssl功能
--with-http_stub_status_module 激活状态信息

11.make
12.make install
13.ln -s /application/nginx-1.8.1/ /application/nginx
14.Nginx的启动
/application/nginx/sbin/nginx
15.Nginx停止和重启
nginx -s stop
nginx -s reload

MYSQL的二进制安装

useradd -s /sbin/nologin -M mysql
cd /home/oldboy/tools/
rz -y(从官网下载二进制包到windows)
tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz
mv mysql-5.5.32-linux2.6-x86_64 /application/mysql
mkdir -p /application/mysql/data
chown -R mysql.mysql /application/mysql/data
ll /application/mysql/data
#初始化数据库
cd /application/mysql/
./scripts/mysql_install_db --user=mysql --basedir=/application/mysql/ --datadir=/application/mysql/data/

cp support-files/my-small.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
vim /etc/init.d/mysqld
修改内容如下:
basedir=/application/mysql
datadir=/application/mysql/data

chmod +x /etc/init.d/mysqld
/etc/init.d/mysqld start

/application/mysql/bin/mysql 进入mysql
优化进入mysql的命令
PATH="/application/mysql/bin:$PATH"
which mysql
vim /etc/profile
添加:PATH="/application/mysql/bin:$PATH"
重新加载配置文件:. /etc/profile
mysql 进入mysql数据库

安装php

1.安装前确保nginx和mysql正常
2.检查安装PHP所需的lib库
rpm -qa zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel
yum install -y zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel
3.安装libiconv库
cd /home/oldboy/tools
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar xvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make
make install
cd ../
4.安装libmcrypt
wget "http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0"
tar zxf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
make install
sleep 2
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../
5.安装mhash
wget http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0
tar xf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure
make
make install
ln -s /usr/local/lib64/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib64/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib64/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib64/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib64/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib64/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib64/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib64/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib64/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin64/libmcrypt-config /usr/bin/limcrypt-config
6.安装mcrypt加密扩展库
wget http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&big_mirror=0
tar xf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
/sbin/ldconfig
./configure LD_LIBRARY_PATH=/usr/local/lib
make
make install
cd ../

安装php
rz -y(php-5.3.27.tar\(1\).gz)
tar xf php-5.3.27.tar\(1\).gz
yum install libxsl* -y
cd php-5.3.27
./configure \
--prefix=/application/php5.3.27 \
--with-mysql=/application/mysql \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-safe-mode \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--with-curlwrappers \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--enable-short-tags \
--enable-zend-multibyte \
--enable-static \
--with-xsl \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-ftp \
#注意,这里不能直接make,
ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/

make
make install
ln -s /application/php5.3.27/ /application/php

php的配置
cd /home/oldboy/tools/php5.3.27/
cp php.ini-production /application/php/lib/php.ini
cd /application/php/etc/
cp php-fpm.conf.default php-fpm.conf
mkdir /app/logs -p
启动php:
/application/php/sbin/php-fpm

原文地址:https://www.cnblogs.com/liuhui-xzz/p/9568871.html

时间: 2024-11-10 00:20:52

lamp和lnmp环境的搭建的相关文章

lamp or lnmp 环境搭建之独立安装mysql数据库

lamp or lnmp 环境搭建,如果mysql 是独立安装的则需要授权: 单独一台服务器独立安装mysql 安装后,优化服务器. 授权 实例如下: 创建用户 CREATE USER demo IDENTIFIED BY "passwd123"; 授权使用mysql数据库下面的所有表 GRANT ALL PRIVILEGES ON mysql.* TO 'demo'@'%'IDENTIFIED BY 'passwd123'WITH GRANT OPTION; FLUSH PRIVIL

LAMP、LNMP实战之四搭建mysql(持续更新)

LAMP.LNMP实战之四搭建mysql说明:服务器192.168.2.32 数据库版本mysql5.5.32 cmake版本2.8.8yum install -y gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* //安装编译环境gccyum install -y mysql-devel //安装msyqlkuyum install lrz

debian7.7快速构建lamp和lnmp环境

debian快速构建lamp和lnmp环境 操作系统环境:debian7.7 安装lamp环境 apt-get install apache2 mysql-server php5 php-pear php5-mysql php5-gd php5-curl php5-common php5-dev php5-xcache -y echo "<?php phpinfo(); ?>" > /var/www/index.php [email protected]:~# cur

LAMP、LNMP实战之八搭建nginxLB

LAMP.LNMP实战之七搭建nginxLB说明:服务器192.168.2.138 192.168.2.137 192.168.2.40 nginx版本nginx-1.6.2.tar.gz1.安装nginxyum install pcre pcre-devel openssl openssl-devel -y //安装pcre.opensslyum install gcc -y //安装gcccd /home/www/tools //进入tools目录将nginx压缩包放在此目录tar zxf

lnmp环境下搭建wordpress博客程序

本文档主要介绍如何在lnmp环境下搭建完整的wordpress程序. 基本流程: 1.开源博客程序WordPress介绍 2.WordPress博客程序的搭建准备 3.开始安装blog博客程序 4.实现WordPress博客程序URL静态化 ---------------------------------------------------------------------------------------------------------------------------------

源码搭建lamp和lnmp环境

1: lamp和lnmp解释 lampn分别代表:linux.apache.mysql.php.nginx.安装大概思路如下: linux环境安装就省略了. 1:mysql安装在两个环境都一样的. 2: lnmp环境下nginx的安装. 3: lamp环境下apache的安装. 4: php在安装的时候应该算最复杂的了吧.其中,针对不同环境的编译选项不同.apache的编译选项--with-apxs2=/usr/local/apache2/bin/apxs,这里apache的安装目录在/usr/

linux下LNMP环境的搭建

lamp=linux+apache+mysql+php; lnmp=Linux+nginx+mysql+php 他们的区别在于apache和nginx和php结合的模式不同,我们讲的这两个架构中,php在编译的时候以一个模块的形式和apache成为了一个整体,这种情况下我们是可以把php的安装目录/usr/local/php删除的.而lnmp中的php启动了一个服务php-fpm,这种模式相当于nginx处理php脚本时,直接把请求转发给了php-fpm,说白了就是一个代理.这个php的安装目录

[Linux] PHP程序员玩转Linux系列-lnmp环境的搭建

1.PHP程序员玩转Linux系列-怎么安装使用CentOS 在平常的工作中,我作为PHP程序员经常要搭建一下环境,这个环境就是Linux系统下安装nginx,php,mysql这三个软件,对软件进行配置,然后在浏览器上能够正常打开运行查看项目.CentOS中安装软件有好几种方式,我经常用的是包安装方式,因为这种非常简单一句命令就能安装成功,这也是与windows下安装软件最大的不同点.包安装方式就一个关键单词就是yum. 解决找不到nginx包的问题 我先安装一下web服务器nginx,按好这

LAMP和LNMP环境PHP缓存加速器的原理

LAMP环境PHP缓存加速器的原理      LAMP=Linux+Apache+MySQL+PHP 1. Apache接收客户的PHP程序请求,并根据规则过滤之. 2.Apache将PHP程序请求传送给PHP处理模块libphp5.so. 3.PHP引擎定位磁盘上的PHP文件,并将其加载到内存中解析. 4.PHP处理模块libphp5.so将PHP源代码编译成为操作码. 5.PHP处理模块libphp5.so执行操作码,然后把操作码缓存起来. 6. Apache接收客户端新的PHP程序请求,P