生產環境下的centos6.2 64位下LAMP安裝

全部機子添加/etc/profilephp

ulimit -SHn 65535mysql


設置軟硬件資源和打開文件數,linux

系統爲centos6.2,64位最小化安裝,因此,要先安裝所需的庫與軟件c++

==========================================
sql

[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
apache

####################################################################################################vim

#           1.安裝apache2.2.22          #windows

####################################################################################################centos

第一步:添加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"

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

相關文章
相關標籤/搜索