生产环境下的centos6.2 64位下LAMP安装

所有机子添加/etc/profile
ulimit -SHn 65535

设置软硬件资源和打开文件数,
系统为centos6.2,64位最小化安装,所以,要先安装所需的库与软件
==========================================
[root@localhost httpd-2.2.22]# yum -y install make apr* autoconf cmake lrzsz automake curl curl-devel gcc* zlib zlib-devel openssl openssl-devel pcre-devel gd kernel keyutils perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel libXpm* freetype freetype-devel libjpeg* libpng* php-common php-gd ncurses* libtool* glib2 glib2-devel bzip2 bzip2-devel autoconf kernel-devel libxml2 libxml2-devel patch unzip vim* libnl* wget
####################################################################################################
# 1.安装apache2.2.22 #
####################################################################################################
第一步:添加apache用户
[root@localhost httpd-2.2.22]# useradd apache -s /sbin/nologin
第二步:进入解压目录中的
[root@localhost ~]# cd /usr/local/src/httpd.2.2.22/srclib/apr
[root@localhost apr]# ./configure --prefix=/usr/local/apr
[root@localhost apr]# make && make install
[root@localhost apr]# cd ../apr-util
[root@localhost apr-util]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@localhost apr-util]# make && make install
第三步:进入httpd.2.2.22目录
[root@localhost httpd-2.2.22]# ./configure --prefix=/usr/local/httpd --enable-track-vars --enable-cgi --enable-modules=all --enable-mods-shared=all --enable-file-cache --enable-disk-cache --enable-cache --enable-mem-cache --enable-dumpio --enable-logio --enable-mime-magic --enable-headers --enable-usertrack --enable-version --enable-ssl --enable-http --enable-rewrite --enable-proxy --enable-proxy-connect --enable-proxy-http --enable-proxy-ftp --enable-proxy-ajp --enable-proxy-balancer --enable-so --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
[root@localhost httpd-2.2.22]# make && make install
第四步: 改变程序目录属组属主
[root@localhost httpd-2.2.22]# chown apache. -R /usr/local/httpd
第五步:修改配置文件用户和组为:
[root@localhost httpd-2.2.22]# vim /usr/local/httpd/conf/httpd.conf
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User apache
Group apache

</IfModule>
</IfModule>

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
第六步:添加主机名到IP对应
[root@localhost httpd-2.2.22]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.219 localhost localhost.com
第七步:添加环境变量
[root@localhost httpd-2.2.22]# vim /etc/profile
PATH=$PATH:/usr/local/httpd/bin/
export PATH
####################################################################################################
# 2.Mysql(mysql-5.5.23)安装 # #################################################################################################### 创建mysql用户:
[root@localhost mysql-5.5.22]# useradd mysql -s /sbin/nologin
第一步:进入解压目录后
[root@localhost mysql-5.5.22]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.sock -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1
[root@localhost mysql-5.5.22]# gmake && make install
改变程序目录属组属主:
[root@localhost mysql-5.5.22]# chown mysql. -R /usr/local/mysql
第二步:拷贝解压后目录
[root@localhost mysql-5.5.22]# cd support-files/
[root@localhost support-files]# cp my-huge.cnf /etc/my.cnf
第三步:安装默认库文件
[root@localhost mysql-5.5.22]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/
第四步:
[root@localhost mysql-5.5.22]# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@localhost mysql-5.5.22]# chkconfig --add mysqld
[root@localhost mysql-5.5.22]# service mysqld start
第五步:添加环境变量到系统,追加到末尾就可以了
vim /etc/profile
PATH=$PATH:/usr/local/mysql/bin/
export PATH

####################################################################################################
# 安装PHP #
#################################################################################################### 第一步:
[root@localhost libmcrypt-2.5.7]# ./configure --prefix=/usr/local/libmcrypt
[root@localhost libmcrypt-2.5.7]# make && make install
第二步:
[root@localhost php-5.3.10]# ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-curl --with-libxml-dir --with-config-file-path=/usr/local/php5/etc --enable-ftp --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-zip --with-mcrypt=/usr/local/libmcrypt --with-gd --enable-soap

第三步:
[root@localhost php-5.3.10]# cp php.ini-production /usr/local/php5/etc/php.ini

第四步:
修改httpd.conf,添加php支持,添加index.php 添加:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
[root@localhost php-5.3.10]# vim /usr/local/httpd/conf/httpd.conf
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

#
# AddHandler allows you to map certain file extensions to "handlers":

第四步:修改ServerName
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80
ServerName 192.168.1.219:80

#
# DocumentRoot: The directory out of which you will serve your

12.安装 libevent
[root@localhost libevent-2.0.14-stable]# ./configure --prefix=/usr/local/libevent && make && make install

13.安装 memcached
[root@localhost memcached-1.4.4]#./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
[root@localhost memcached-1.4.4]# make && make install

[root@localhost memcached-1.4.4]# /usr/local/memcached/bin/memcached -d -m 20 -p 11211 -u apache

-d选项是启动一个守护进程,
-m是分配给Memcache使用的内存数量,单位是MB,我这里是10MB,
-u是运行Memcache的用户,我这里是root,
-l是监听的服务器IP地址,如果有多个地址的话,我这里指定了服务器的IP地址192.168.0.200,
-p是设置Memcache监听的端口,我这里设置了12000,最好是1024以上的端口,
-c选项是最大运行的并发连接数,默认是1024,我这里设置了256,按照你服务器的负载量来设定,
-P是设置保存Memcache的pid文件,我这里是保存在 /tmp/memcached.pid,

想开机自动启动的话,只需在/etc/rc.d/rc.local中加入一行,上面命令
有人用以下命令:
/usr/local/memcached/bin/memcached -d -m 20 -p 11211 -u apache
上面有些东西可以参考一下:即,ip不指定时,默认是本机,用户,最好选择是:apache 或 deamon
这样,也就是属于哪个用户的服务,由哪个用户启动。

14.安装 memcache
[root@localhost ~]# cd /usr/local/src/memcache-2.2.5
[root@localhost memcache-2.2.5]# /usr/local/php5/bin/phpize
[root@localhost memcache-2.2.5]# ./configure --enable-memcache --with-php-config=/usr/local/php5/bin/php-config
[root@localhost memcache-2.2.5]# make && make install

第三步:在/usr/local/php5/etc/php.ini中添加 安装完后生成的路径
[root@localhost memcache-2.2.5]# vim /usr/local/php5/etc/php.ini
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
extension_dir = "/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626"
extension = memcache.so

; On windows:
; extension_dir = "ext"


===============================================================

本文出自 “杜云龙” 博客,谢绝转载!

你可能感兴趣的:(生产环境下的LAMP安装)