码迷,mamicode.com
首页 > 其他好文 > 详细

lamp和lnmp环境的搭建

时间:2018-09-01 12:21:30      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:soc   创建   建立   工具   用户   regex   mod   windows   inno   

本次的实验环境是

技术分享图片

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

 

 

 

 

 

 

 

 

 

 

 

lamp和lnmp环境的搭建

标签:soc   创建   建立   工具   用户   regex   mod   windows   inno   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!