LAMP 编译安装

1.安装cmake
 MySQL从5.5版本开始,通过./configure进行编译配置方式已经被取消,取而代之的是cmake工具。
 因此,我们首先要在系统中源码编译安装cmake工具。
 
# wget http://www.cmake.
org/files/v2.6/cmake-2.6.4.tar.gz
 
# tar zxvf cmake-2.8.4.tar.gz
 
# cd cmake-2.8.4
 
# ./configure
 # make
 # make install


3. 安装前的系统设置
 建立mysql安装目录及数据存放目录
 # mkdir /usr/local/mysql
 # mkdir /usr/local/mysql/data
#mkdir /usr/local/mysql/sockets
#mkdir /usr/local/mysql/etc
#mkdir /usr/local/mysql/log
 
创建用户和用户组
 # groupadd mysql
 # useradd -s /sbin/nologin -g mysql mysql 
 
赋予数据存放目录权限
 # chown mysql:mysql –R /usr/local/mysql/data
# chown mysql:mysql –R /usr/local/mysql/sockets


5.编译安装 MySQL 5.5.13
 通过http://www.mysql.com/downloads/mysql官方网址或国内的sohu镜像下载软件包。
configure 与 cmake 参数对照指南:
http://forge.mysql.com/wiki/Autotools_to_CMake_Transition_Guide
 
# wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.13.tar.gz
 
# tar zxvf mysql-5.5.13.tar.gz
 
# cd mysql-5.5.13
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/usr/local/mysql/etc -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/usr/local/mysql/sockets/mysqld.sock -DMYSQL_USER=mysql -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_unicode_ci -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1  -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_ZLIB=system -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_LIBWRAP=0 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1


# make
# make install




6.初始化数据库
 创建my.cnf配置文件
# cp support-files/my-medium.cnf /usr/local/mysql/etc/my.cnf
 
初始化数据库
 执行前需赋给scripts/mysql_install_db文件执行权限
 # chmod 755 scripts/mysql_install_db
 # scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
 
作为服务启动
 # cp support-files/mysql.server /etc/init.d/mysql
 # chmod 755 /etc/init.d/mysql
 # chkconfig mysql on
 #chkconfig –list mysql
 
配置MySQL环境变量
永久:vi /etc/profile
单用户:vi /home/guok/.bask_profile
零时:export PATH=/usr/local/mysql/bin:$PATH
#source /etc/profile


启动MySQL:
 # /etc/init.d/mysql start
 #ps -ef/grep mysql


用户登录:
 #mysql -u root -p -S /usr/local/mysql/sockets/mysql.sock


配置mysql:
 #mysqladmin -u root password '123456';
 #delete from user where password='';
 #update user set host='%' where user='root';




安装Apache
Apache编译安装
#tar -xzvf ***
#cd ***
#./configure --prefix=/usr/local/apache --enable-so --enable-mods-shared=all --with-mpm=worker --with-ssl --enable-ssl --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-rewrite --enable-deflate --enable-headers
worker:多进程多线程,系统基于线程安全。
prefork:多进程模式,系统基于非线程安全。
#make;make install


常用命令
apachectl start,stop,restart
apachectl graceful(完美重启)
apachectl configtest
apachectl status


修改配置httpd.conf
# vi /usr/local/apache/conf/httpd.conf
ServerAdmin 15989105677@139.com
DocumentRoot “/var/www/html”
<Directory “/var/www/html”>….</Directory>


Apache开机启动项
#vi /etc/rc.d/rc.local
 /usr/local/apache/bin/apachectl start


1,apache做为服务启动
2,启用SSL
3,启用命名虚拟主机,OK!
4,百万连接
5,启用压缩,OK!
6,地址重写
7,启用缓存,OK!


启用虚拟主机
Include conf/extra/httpd-vhosts.conf  //修改相应配置


启用页面压缩
在线检测工具(如:http://www.whatsmyip.org/http_compression/)来检测你的网站内容是否已经过Gzip压缩。
LoadModule deflate_module modules/mod_deflate.so
<IfModule mod_deflate.c> 
<Location /> 
#Insert filter 
SetOutputFilter DEFLATE 
# Netscape 4.x has some problems… 
BrowserMatch ^Mozilla/4 gzip-only-text/html 
# Netscape 4.06-4.08 have some more problems 
BrowserMatch ^Mozilla/4\.0[678] no-gzip 
# MSIE masquerades as Netscape, but it is fine 
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html 
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.59 
# the above regex won’t work. You can use the following 
# workaround to get the desired effect: 
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html force-gzip 
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html 


# Don’t compress images and other 
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary 
SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary 
SetEnvIfNoCase Request_URI .(?:pdf|doc)$ no-gzip dont-vary 
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE image/svg+xml
# Make sure proxies don’t deliver the wrong content 
Header append Vary User-Agent env=!dont-vary 


#DeflateFilterNote ratio ratio_info 
#LogFormat '"%v %h %l %u %t “%r" %>s %b "%{Referer}i" "%{User-Agent}i"" (%{ratio}n)' deflate 
#CustomLog logs/deflate_log deflate 
</Location>


启用缓存机制
Apache 的缓存实现主要依靠 mod_cache、mod_disk_cache、mod_file_cache 及 mod_mem_cache。
具体来说,Apache 的缓存方式有两种,一种是基于硬盘文件的 缓存,由 mod_disk_cache 实现,另一种是使用内存缓存,由 mod_mem_cache 实现,不过它们都是依赖mod_cache 模块的,mod_cache 模块提供了一些缓存配置的指令供它们使用,而 mod_file_cache 模块是搭配 mod_mem_cache 模块使用的,下面分别进行介绍。  


基于硬盘文件存储:  
CacheDefaultExpire 86400  
CacheEnable disk / 
CacheRoot /tmp/apacheCache 
CacheDirLevels 5 
CacheDirLength 5 
CacheMaxFileSize 1048576 
CacheMinFileSize 10 


基于内存的缓存: 
CacheEnable mem / 
MCacheMaxObjectCount 20000 
MCacheMaxObjectSize 1048576 
MCacheMaxStreamingBuffer 65536 
MCacheMinObjectSize 10 
MCacheRemovalAlgorithm GDSF 
MCacheSize 131072  
缓存文件内容或句柄到内存,需要重启或使用 graceful才能更新。
MMapFile /var/www/html/index.html /var/www/html/articles/index.html 
CacheFile /var/www/html/index.html /var/www/html/articles/index.html 




开启SSL支持
1,生成服务端,客户端和CA密钥对
# openssl genrsa -des3 -out server.key 1024(去除密码openssl rsa -in server.key -out server.key)
# openssl req -new -key server.key -out server.csr -config openssl.cnf
# openssl genrsa -des3 -out client.key 1024
# openssl req -new -key client.key -out client.csr -config openssl.cnf


# openssl req -new -x509 -keyout ca.key -out ca.crt -config openssl.cnf
2,自签证书
Openssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.key -config openssl.cnf
Openssl ca -in client.csr -out client.crt -cert ca.crt -keyfile ca.key -config openssl.cnf
3,修改apache配置文件
# vi httpd.conf
NameVirtualHost *:80
<virtualhost *:80>
        documentroot /var/www/html
        servername www.bk1.cn
<directory /var/www/html>
        AllowOverride none
        order deny,allow
</directory>
</virtualhost>
<virtualhost 192.168.1.101:443>
        documentroot /var/www/bk
        servername mail.bk1.cn
<directory /var/www/bk>
        AllowOverride all
        order deny,allow
</directory>
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/mail.bk1.cn.crt
SSLCertificateKeyFile /etc/pki/tls/private/mail.bk1.cn.key
</virtualhost>


安装PHP
yum -y install libmcrypt
yum -y install libmcrypt-devel
yum -y install freetds
yum -y install freetds-devel
yum -y install libXpm-devel


tar xzvf ...
cd ...
./configure --prefix=/usr/local/php --sysconfdir=/usr/local/php/etc --datadir=/usr/local/php/data --with-pear=/usr/local/php/pear --with-apxs2=/usr/local/apache/bin/apxs  --with-mssql --with-mysql=/usr/local/mysql --with-mysql-sock=/usr/local/mysql/sockets --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-embedded-mysqli --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-xpm-dir --with-ttf --with-freetype-dir  --enable-gd-native-ttf --enable-gd-jis-conv --enable-mbstring --with-openssl --with-kerberos --with-bz2 --with-zlib --enable-zip --with-iconv-dir --with-libxml-dir --with-xmlrpc --with-xsl --enable-soap --with-curl --with-curlwrappers --with-ldap --with-ldap-sasl --enable-ftp --enable-sockets --enable-pcntl --enable-bcmath --enable-shmop --enable-sysvsem --with-mcrypt --with-mhash 
make
make install


复制PHP配置文件
cp php.ini-dest /usr/local/php/etc/php.ini


配置apache支持php
      vi /etc/httpd/conf/httpd.conf
      DocumentRoot "C:/htdocs"
<Directory "C:/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
      DirectoryIndex index.php index.html 
      AddType application/x-httpd-php .php
启动服务
      apachectl start
添加服务
      chkconfig httpd on
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值