CentOS 6.2 LNMP搭建

LAMP架构搭建

Mysql-5.5.21

Httpd-2.2.22

Php-5.3.8

###安装前的准备####

yum -y install gcc gcc-c++ autoconf libjpeglibjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-develzlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncursesncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidnlibidn-devel openssl openssl-devel openldap openldap-devel nss

  1. Httpd安装

tar zxvf httpd-2.2.22.tar.gz

cd httpd-2.2.22

./configure --prefix=/usr/local/apache--enable-deflate--enable-expires--enable-headers --enable-modules=most --enable-so --with-mpm=worker--enable-rewrite

make && make install

cp /usr/local/apache/bin/apachectl/etc/rc.d/init.d/httpd

vi /etc/rc.d/init.d/httpd

####! Bin/bash下添加####

# chkconfig: 2345 50 90

# description: Activates/Deactivates Apache WebServer

chkconfig --add httpd

chkconfig httpd on

service httpd start

/etc/init.d/iptables stop

二.Mysql安装

tarzxvf cmake-2.8.4.tar.gz

cdcmake-2.8.4

./configure

make&& make install

tarzxvf mysql-5.5.21.tar.gz

groupaddmysql

useradd-g mysql mysql -s /usr/sbin/nologin

mkdir/usr/local/mysql

mkdir/usr/local/mysql/data

cdmysql-5.5.21

cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DINSTALL_DATADIR=/usr/local/mysql/data

make&& make install

cpsupport-files/my-small.cnf /etc/my.cnf

chgrp-R mysql /usr/local/mysql

/usr/local/mysql/bin/mysqld_safe&

echo‘export PATH=$PATH:/usr/local/mysql/bin‘ >>/etc/profile

source/etc/profile

cd/udr/local/mysql/

scripts/mysql_install_db--basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

cpsupport-files/mysql.server /etc/init.d/mysqld

chmod755 /etc/init.d/mysqld

chkconfig--add mysqld

chkconfig--level 3 mysqld on

/etc/init.d/mysqldstart

netstat-lntp|grep mysqld

/usr/local/mysql/bin/mysqladmin-uroot password ‘123456‘

三.安装php的插件

tar zxvf libiconv-1.14.tar.gz

cd libiconv-1.14

./configure --prefix=/usr/local && make&& make install && cd ..

tar zxvf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8

./configure && make && makeinstall

cd libltdl/

./configure --enable-ltdl-install

make && make install && cd ..

tar zxvf mhash-0.9.9.9.tar.gz

cd mhash-0.9.9.9/

./configure && make && makeinstall

ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la

ln -s /usr/local/lib/libmcrypt.so/usr/lib/libmcrypt.so

ln -s /usr/local/lib/libmcrypt.so.4/usr/lib/libmcrypt.so.4

ln -s /usr/local/lib/libmcrypt.so.4.4.8/usr/lib/libmcrypt.so.4.l4.8

ln -s /usr/local/lib/libmhash.a/usr/lib/libmhash.a

ln -s /usr/local/lib/libmhash.la/usr/lib/libmhash.la

ln -s /usr/local/lib/libmhash.so/usr/lib/libmhash.so

ln -s /usr/local/lib/libmhash.so.2.0.1/usr/lib/libmhash.so.2.0.1

ln -s /usr/local/lib/libmhash.so.2/usr/lib/libmhash.so.2

ln -s /usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config

cd /opt

tar zxvf mcrypt-2.6.8.tar.gz

cd mcrypt-2.6.8/

/sbin/ldconfig

./configure

make && make install && cd ..

cp -frp /usr/lib64/libpng* /usr/lib/

cp -frp /usr/lib64/libldap* /usr/lib

cp -frp /usr/lib64/libjpeg.* /usr/lib/

cp -frp /usr/lib64/libldap* /usr/lib/

四.安装php

tar -zxvf php-5.3.8.tar.gz

cd php-5.3.8.tar.gz

./configure --prefix=/usr/local/php--with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql--with-ttf --with-xmlrpc --with-openssl --with-zlib --with-freetype-dir--with-gd --with-jpeg-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

make ZEND_EXTRA_LIBS=‘-liconv‘&&make install

cp php.ini-production /usr/local/php/lib/php.ini

五.配置http.conf,使之和php结合

vi /usr/local/apache/bin/httpd.conf +310

AddType application/x-compress .Z

AddType application/x-gzip .gz .tgz

添加

AddType application/x-httpd-php .php .php3

AddType application/x-httpd-php-source.phps

###############################################

<IfModule dir_module>

DirectoryIndex index.html添加index.php

<Directory />

Options FollowSymLinks

AllowOverride None###None改成ALL

Order deny,allow

Deny from all

</Directory>

User daemon

Group daemon

改成User apache

Group apache

cd/usr/local/apache/htdocs

vimindex.php

####添加

<?php

phpinfo();

?>

/usr/local/apache/bin/apachectlgraceful

####访问测试#####

192.168.6.57/index.php

六.apache配置虚拟主机

vim/usr/local/apache/conf/httpd.conf +388

把这行前面的#号去掉

#Includeconf/extra/httpd-vhosts.conf

vim/usr/local/apache/conf/extra/httpd-vhosts.conf

############################################

<VirtualHost *:80>

ServerAdmin webmaster@dummy-host.example.com#管理员邮箱

DocumentRoot"/usr/local/apache/docs/dummy-host.example.com" #网站根目录

ServerName dummy-host.example.com#域名

ServerAlias www.dummy-host.example.com#域名

ErrorLog"logs/dummy-host.example.com-error_log"#错误日志

CustomLog"logs/dummy-host.example.com-access_log" common

</VirtualHost>

<VirtualHost*:80>

ServerAdmin webmaster@dummy-host2.example.com#管理员邮箱

DocumentRoot"/usr/local/apache/docs/dummy-host2.example.com" #网站根目录

ServerName dummy-host2.example.com#域名

ErrorLog "logs/dummy-host2.example.com-error_log"#错误日志

CustomLog"logs/dummy-host2.example.com-access_log" common

然后再保存退出

在本地打开C:\Windows\System32\Drivers\etc修改host文件

添加

192.168.10.118www.ssssddd.com

192.168.10.118www.xxxvvv.com

/usr/local/apache/bin/apachectlrestart













本文出自 “运维” 博客,谢绝转载!

CentOS 6.2 LNMP搭建

上一篇:sccm安装客户端代理软件


下一篇:impala常见错误小结