Cent OS 6.5 LAMP(Apache+php+mysql+Xcache) 编译安装
详细编译安装LAMP环境安装OS及软件版本
OS:Cent OS 6.5
apache:httpd-2.4.10.tar.gz
php:php-5.4.31.tar.bz2
mysql:mysql-5.6.19.tar.gz
Xcache:xcache-3.1.0.tar.gz
phpmyadmin:phpMyAdmin-4.2.7-all-languages.zip
一、安装前准备
修改主机名
#sed -i 's/HOSTNAME=localhost.localdomain/HOSTNAME=linux.lamp.com/g' /etc/sysconfig/network
#vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.20.203 linux linux.topgloira.com.cn
关闭selinux
#sed -i 's@SELINUX=enforcing@SELINUX=disabled@g' /etc/sysconfig/selinux 设置防火墙,允许httpd:80和mysqld:3306端口访问
#vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT 二、创建一个YUM仓库
1.下载64位rpmforge的rpm包
#wget wget http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm 2.安装DAG的PGP Key
#rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt 3.验证rpmforge的rpm文件包
#rpm -K rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm: (sha1) dsa sha1 md5 gpg OK 4.安装rpmforge的rpm文件包
#rpm -i rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm 5.编辑自己服务器的YUM仓库
#vim /etc/yum.repos.d/rpmforge.repo
name=CentOS-6.5_X86-64_rpmforge
baseurl=http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/
baseurlextra=http://apt.sw.be/redhat/el6/en/x86_64/extras/
mirrorlist=http://apt.sw.be/redhat/el6/en/mirrors-rpmforge
mirrotextras=http://apt.sw.be/redhat/el6/en/mirrors-rpmforge-extras
enbaled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck=1 6.查看自己服务器YUM库
# yum repolist
Loaded plugins: fastestmirror, priorities, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* rpmforge: ftp.riken.jp
base | 3.7 kB 00:00
rpmforge | 1.9 kB 00:00
rpmforge/primary_db | 2.7 MB 00:02
15 packages excluded due to repository priority protections
repo id repo name status
base CentOS-6.5_X86-64_sohu 6,352+15
rpmforge CentOS-6.5_X86-64_rpmforge 4,718
repolist: 11,070
三、安装Apache
1.安装编译环境
#yum grouplist
#yum groupinstall desktop platform development development tools server platform development
#yum install -y pcre-devel openssl-devel 2.安装公共管理接口APR和APR-util
#tar xf apr-1.5.1.tar.gz
#cd apr-1.5.1
#./configure --prefix=/usr/local/apr
#make && make install
#cd ../
#tar xf apr-util-1.5.3.tar.gz
#cd apr-util-1.5.3
#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
#make && make install 3.编译安装Apache
#tar xf httpd-2.4.10.tar.gz
#cd httpd-2.4.10
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zilb --with-pcre --with-crypto --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpm-shared=all --with-mpm=event
make && make install 4.编辑配置文件
#cp /etc/rc.d/init.d/httpd /etc/rc.d/init.d/httpd24
#vim /etc/rc.d/init.d/httpd24 修改启动配置文件
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
pidfile=${PIDFILE-/usr/local/apache/logs/httpd.pid}
#vim /etc/profile.d/httpd
export PATH=/usr/local/apcahe/bin:$PATH
#chkconfig --add httpd24
#chkconfig httpd24 on
#service httpd24 start
Starting httpd:
四、编译安装mysql
1.安装依赖库
#yum install -y cmake curses-devel 2.添加mysql用户和数据库目录
#useradd -r mysql
#mkdir -p /mysql/data 3.编译配置msyql
#tar xf mysql-5.6.19.tar.gz
#cd mysql-5.6.19
#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mysql/data
Check size of pthread_t
-- Check size of pthread_t - done
-- Using cmake version 2.6.4
-- Not building NDB
-- Performing Test HAVE_PEERCRED
-- Performing Test HAVE_PEERCRED - Success
-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl
-- Googlemock was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an http proxy: export http_proxy=http://example.com:80
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl
-- Configuring done
-- Generating done
-- Build files have been written to: /mydata/software/mysql-5.6.19
(以上输出说明Cmake mysql 完成)
#make && make install To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /usr/local/mysql/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
(以上输出说明编译安装成功)
4.编辑配置mysql配置文件
#chown -R root:msyql /usr/local/mysql
#chown -R mysql:msyql /mysql/data
#cd /usr/local/mysql/support-files
#cp my-default.cnf /etc/my.cnf
#cp mysql.server /etc/rc.d/init.d/mysqld
#chkconfig --add mysqld
#chkconfig mysqld on
#vim /etc/profile.d/mysql.sh
export PATH=/usr/loocal/mysql/bin:$PATH
#cd ../scripts/
#./mysql_install_db --user=mysql --datadir=/mysql/data --basedir=/usr/local/mysql Installing MySQL system tables...2014-05-14 15:00:41 0 TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-05-14 15:00:42 12240 InnoDB: Using atomics to ref count buffer pool pages
2014-05-14 15:00:42 12240 InnoDB: The InnoDB memory heap is disabled
2014-05-14 15:00:42 12240 InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-05-14 15:00:42 12240 InnoDB: Compressed tables use zlib 1.2.3
2014-05-14 15:00:42 12240 InnoDB: Using CPU crc32 instructions
2014-05-14 15:00:42 12240 InnoDB: Initializing buffer pool, size = 128.0M
2014-05-14 15:00:43 12240 InnoDB: Completed initialization of buffer pool
2014-05-14 15:00:44 12240 InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2014-05-14 15:00:44 12240 InnoDB: Setting file ./ibdata1 size to 12 MB
2014-05-14 15:00:44 12240 InnoDB: Database physically writes the file full: wait...
2014-05-14 15:00:46 12240 InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2014-05-14 15:00:53 12240 InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2014-05-14 15:01:00 12240 InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2014-05-14 15:01:00 12240 InnoDB: New log files created, LSN=45781
2014-05-14 15:01:00 12240 InnoDB: Doublewrite buffer not found: creating new
2014-05-14 15:01:01 12240 InnoDB: Doublewrite buffer created
2014-05-14 15:01:01 12240 InnoDB: 128 rollback segment(s) are active.
2014-05-14 15:01:01 12240 InnoDB: Creating foreign key constraint system tables.
2014-05-14 15:01:01 12240 InnoDB: Foreign key constraint system tables created
2014-05-14 15:01:01 12240 InnoDB: Creating tablespace and datafile system tables.
2014-05-14 15:01:01 12240 InnoDB: Tablespace and datafile system tables created.
2014-05-14 15:01:01 12240 InnoDB: Waiting for purge to start
2014-05-14 15:01:01 12240 InnoDB: 5.6.19 started; log sequence number 0
2014-05-14 15:01:01 12240 RSA private key file not found: /mysql/data//private_key.pem. Some authentication plugins will not work.
2014-05-14 15:01:01 12240 RSA public key file not found: /mysql/data//public_key.pem. Some authentication plugins will not work.
2014-05-14 15:01:03 12240 Binlog end
2014-05-14 15:01:03 12240 InnoDB: FTS optimize thread exiting.
2014-05-14 15:01:03 12240 InnoDB: Starting shutdown...
2014-05-14 15:01:04 12240 InnoDB: Shutdown completed; log sequence number 1625977
OK
Filling help tables...2014-05-14 15:01:04 0 TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-05-14 15:01:04 12274 InnoDB: Using atomics to ref count buffer pool pages
2014-05-14 15:01:04 12274 InnoDB: The InnoDB memory heap is disabled
2014-05-14 15:01:04 12274 InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-05-14 15:01:04 12274 InnoDB: Compressed tables use zlib 1.2.3
2014-05-14 15:01:04 12274 InnoDB: Using CPU crc32 instructions
2014-05-14 15:01:04 12274 InnoDB: Initializing buffer pool, size = 128.0M
2014-05-14 15:01:04 12274 InnoDB: Completed initialization of buffer pool
2014-05-14 15:01:05 12274 InnoDB: Highest supported file format is Barracuda.
2014-05-14 15:01:05 12274 InnoDB: 128 rollback segment(s) are active.
2014-05-14 15:01:05 12274 InnoDB: Waiting for purge to start
2014-05-14 15:01:05 12274 InnoDB: 5.6.19 started; log sequence number 1625977
2014-05-14 15:01:05 12274 RSA private key file not found: /mysql/data//private_key.pem. Some authentication plugins will not work.
2014-05-14 15:01:05 12274 RSA public key file not found: /mysql/data//public_key.pem. Some authentication plugins will not work.
2014-05-14 15:01:06 12274 Binlog end
2014-05-14 15:01:06 12274 InnoDB: FTS optimize thread exiting.
2014-05-14 15:01:06 12274 InnoDB: Starting shutdown...
2014-05-14 15:01:06 12274 InnoDB: Shutdown completed; log sequence number 1625987
OK
(以上初始化数据库OK)
5.启动数据库mysql
#service mysqld start
Starting MySQL.........................
五、编译安装PHP
1.yum安装编译需要的库
#yum install -y libxml2-devel bzip2-devel libmcrypt-devel mhash-devel 2.编译安装PHP
#tar xf php-5.4.31.tar.bz2
#cdphp-5.4.31
#./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d--with-bz2 --enable-maintainer-zts
#make && make install
#service httpd24 restart
Stopping httpd:
Starting httpd: 六、配置LAMP环境
1.编辑httpd.conf文件
#vim /etc/httpd24/httpd.conf
DirectoryIndex index.php index.html
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
#vim /usr/local/apache/htdocs/index.php
#service httpd24 restart 2.访问http://ip测试php和mysql
(测试LAMP环境成功)
七、安装phpmyadmin管理mysql
1.解压phpmyadmin文件
#unzip phpMyAdmin-4.2.7-all-languages.zip 2.创建虚拟主机
#vim /etc/httpd24/httpd.conf
#DocumentRoot "/usr/local/apache/htdocs"
Include /etc/httpd24/extra/httpd-vhosts.conf
#mkdir -p /web/host/phpadmin
#vim /etc/httpd24/extra/httpd-vhosts.conf
ServerName linux.topgloria.com.cn
DocumentRoot "/web/host/phpadmin"
Optionsnone
AllowOverride none
Require all granted
#mv phpMyAdmin-4.2.7-all-languages/web/host/phpadmin
#service httpd24 restart 3.访问http://ip/phpadmin
八、编译安装Xcache
1.没有安装Xcache用ab工具测试服务器性能
# ab -c 100 -n 1000 http://10.0.20.203/index.php This is ApacheBench, Version 2.3
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 10.0.20.203 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: Apache/2.4.10
Server Hostname: 10.0.20.203
Server Port: 80
Document Path: /index.php
Document Length: 8555 bytes
Concurrency Level: 100
Time taken for tests: 18.177 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 9911000 bytes
HTML transferred: 8555000 bytes
Requests per second: 55.02 [#/sec] (mean)
Time per request: 1817.653 (mean)
Time per request: 18.177 (mean, across all concurrent requests)
Transfer rate: 532.48 received
Connection Times (ms)
minmean[+/-sd] median max
Connect: 0 3577.7 0 764
Processing: 287 1747 877.7 1534 13987
Waiting: 206 1588 881.7 1358 13728
Total: 287 1782 896.5 1552 14234
Percentage of the requests served within a certain time (ms)
50% 1552
66% 1754
75% 1980
80% 2134
90% 2779
95% 3577
98% 4386
99% 4738
100%14234 (longest request)
2.编译安装Xcache
#tar xf xcache-3.1.0.tar.gz
#cd xcache-3.1.0
#/usr/local/php/bin/phpize
#./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
#make && make install
#mkdir /etc/php.d
#cp xcache.ini /etc/php.d
#service httpd24 restart
3.安装完成Xcache后测试结果
# ab -c 100 -n 1000 http://10.0.20.203/index This is ApacheBench, Version 2.3
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 10.0.20.203 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: Apache/2.4.10
Server Hostname: 10.0.20.203
Server Port: 80
Document Path: /index
Document Length: 203 bytes
Concurrency Level: 100
Time taken for tests: 0.327 seconds
Complete requests: 1000
Failed requests: 0
Non-2xx responses: 1000
Total transferred: 392000 bytes
HTML transferred: 203000 bytes
Requests per second: 3057.14 [#/sec] (mean)
Time per request: 32.710 (mean)
Time per request: 0.327 (mean, across all concurrent requests)
Transfer rate: 1170.31 received
Connection Times (ms)
minmean[+/-sd] median max
Connect: 7 17 8.4 16 48
Processing: 7 15 4.0 14 25
Waiting: 0 10 6.0 10 24
Total: 26 32 8.1 29 57
Percentage of the requests served within a certain time (ms)
50% 29
66% 30
75% 31
80% 32
90% 34
95% 56
98% 57
99% 57
100% 57 (longest request)
以上安装LAMP和Xcache完成!
页:
[1]