设为首页 收藏本站
查看: 880|回复: 0

[经验分享] Cent OS 6.5 LAMP(Apache+php+mysql+Xcache) 编译安装

[复制链接]

尚未签到

发表于 2018-11-22 10:47:59 | 显示全部楼层 |阅读模式
  详细编译安装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
  一、安装前准备
  修改主机名
   [root@linux ~]#sed -i 's/HOSTNAME=localhost.localdomain/HOSTNAME=linux.lamp.com/g' /etc/sysconfig/network
   [root@linux ~]#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
   [root@linux ~]#sed -i 's@SELINUX=enforcing@SELINUX=disabled@g' /etc/sysconfig/selinux  设置防火墙,允许httpd:80和mysqld:3306端口访问  
   [root@linux ~]#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包      

   [root@linux ~]#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
   [root@linux ~]#rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt  3.验证rpmforge的rpm文件包
   [root@linux ~]#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文件包

   [root@linux ~]#rpm -i rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm  5.编辑自己服务器的YUM仓库
   [root@linux ~]#vim /etc/yum.repos.d/rpmforge.repo
   [rpmforge]
   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库
    [root@linux ~]# 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.安装编译环境
     [root@linux ~]#yum grouplist
     [root@linux ~]#yum groupinstall desktop platform development development tools server platform development
     [root@linux ~]#yum install -y pcre-devel openssl-devel  2.安装公共管理接口APR和APR-util
     [root@linux ~]#tar xf apr-1.5.1.tar.gz
     [root@linux ~]#cd apr-1.5.1
     [root@linux ~]#./configure --prefix=/usr/local/apr
     [root@linux ~]#make && make install
     [root@linux ~]#cd ../
     [root@linux ~]#tar xf apr-util-1.5.3.tar.gz
     [root@linux ~]#cd apr-util-1.5.3
     [root@linux ~]#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
     [root@linux ~]#make && make install  3.编译安装Apache
     [root@linux ~]#tar xf httpd-2.4.10.tar.gz
     [root@linux ~]#cd httpd-2.4.10
     [root@linux httpd]./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
     [root@linux httpd]make && make install  4.编辑配置文件
     [root@linux ~]#cp /etc/rc.d/init.d/httpd /etc/rc.d/init.d/httpd24
     [root@linux ~]#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}
     [root@linux ~]#vim /etc/profile.d/httpd
     export PATH=/usr/local/apcahe/bin:$PATH
     [root@linux ~]#chkconfig --add httpd24
     [root@linux ~]#chkconfig httpd24 on
     [root@linux ~]#service httpd24 start
     Starting httpd:                                            [  OK  ]  

  四、编译安装mysql
  1.安装依赖库
     [root@linux ~]#yum install -y cmake curses-devel  2.添加mysql用户和数据库目录
     [root@linux ~]#useradd -r mysql
     [root@linux ~]#mkdir -p /mysql/data  3.编译配置msyql
     [root@linux ~]#tar xf mysql-5.6.19.tar.gz
     [root@linux ~]#cd mysql-5.6.19     
     [root@linux 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 完成)   

     [root@linux mysql-5.6.19]#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配置文件
      [root@linux ~]#chown -R root:msyql /usr/local/mysql
      [root@linux ~]#chown -R mysql:msyql /mysql/data
      [root@linux ~]#cd /usr/local/mysql/support-files
      [root@localhost scripts]#cp my-default.cnf /etc/my.cnf
      [root@localhost scripts]#cp mysql.server /etc/rc.d/init.d/mysqld
      [root@localhost scripts]#chkconfig --add mysqld
      [root@localhost scripts]#chkconfig mysqld on
      [root@localhost scripts]#vim /etc/profile.d/mysql.sh
      export PATH=/usr/loocal/mysql/bin:$PATH
      [root@localhost scripts]#cd ../scripts/
      [root@localhost scripts]#./mysql_install_db --user=mysql --datadir=/mysql/data --basedir=/usr/local/mysql  Installing MySQL system tables...2014-05-14 15:00:41 0 [Warning] 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 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-05-14 15:00:42 12240 [Note] InnoDB: The InnoDB memory heap is disabled
2014-05-14 15:00:42 12240 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-05-14 15:00:42 12240 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-05-14 15:00:42 12240 [Note] InnoDB: Using CPU crc32 instructions
2014-05-14 15:00:42 12240 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-05-14 15:00:43 12240 [Note] InnoDB: Completed initialization of buffer pool
2014-05-14 15:00:44 12240 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2014-05-14 15:00:44 12240 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2014-05-14 15:00:44 12240 [Note] InnoDB: Database physically writes the file full: wait...
2014-05-14 15:00:46 12240 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2014-05-14 15:00:53 12240 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2014-05-14 15:01:00 12240 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2014-05-14 15:01:00 12240 [Warning] InnoDB: New log files created, LSN=45781
2014-05-14 15:01:00 12240 [Note] InnoDB: Doublewrite buffer not found: creating new
2014-05-14 15:01:01 12240 [Note] InnoDB: Doublewrite buffer created
2014-05-14 15:01:01 12240 [Note] InnoDB: 128 rollback segment(s) are active.
2014-05-14 15:01:01 12240 [Warning] InnoDB: Creating foreign key constraint system tables.
2014-05-14 15:01:01 12240 [Note] InnoDB: Foreign key constraint system tables created
2014-05-14 15:01:01 12240 [Note] InnoDB: Creating tablespace and datafile system tables.
2014-05-14 15:01:01 12240 [Note] InnoDB: Tablespace and datafile system tables created.
2014-05-14 15:01:01 12240 [Note] InnoDB: Waiting for purge to start
2014-05-14 15:01:01 12240 [Note] InnoDB: 5.6.19 started; log sequence number 0
2014-05-14 15:01:01 12240 [Note] RSA private key file not found: /mysql/data//private_key.pem. Some authentication plugins will not work.
2014-05-14 15:01:01 12240 [Note] RSA public key file not found: /mysql/data//public_key.pem. Some authentication plugins will not work.
2014-05-14 15:01:03 12240 [Note] Binlog end
2014-05-14 15:01:03 12240 [Note] InnoDB: FTS optimize thread exiting.
2014-05-14 15:01:03 12240 [Note] InnoDB: Starting shutdown...
2014-05-14 15:01:04 12240 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK
Filling help tables...2014-05-14 15:01:04 0 [Warning] 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 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-05-14 15:01:04 12274 [Note] InnoDB: The InnoDB memory heap is disabled
2014-05-14 15:01:04 12274 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-05-14 15:01:04 12274 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-05-14 15:01:04 12274 [Note] InnoDB: Using CPU crc32 instructions
2014-05-14 15:01:04 12274 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-05-14 15:01:04 12274 [Note] InnoDB: Completed initialization of buffer pool
2014-05-14 15:01:05 12274 [Note] InnoDB: Highest supported file format is Barracuda.
2014-05-14 15:01:05 12274 [Note] InnoDB: 128 rollback segment(s) are active.
2014-05-14 15:01:05 12274 [Note] InnoDB: Waiting for purge to start
2014-05-14 15:01:05 12274 [Note] InnoDB: 5.6.19 started; log sequence number 1625977
2014-05-14 15:01:05 12274 [Note] RSA private key file not found: /mysql/data//private_key.pem. Some authentication plugins will not work.
2014-05-14 15:01:05 12274 [Note] RSA public key file not found: /mysql/data//public_key.pem. Some authentication plugins will not work.
2014-05-14 15:01:06 12274 [Note] Binlog end
2014-05-14 15:01:06 12274 [Note] InnoDB: FTS optimize thread exiting.
2014-05-14 15:01:06 12274 [Note] InnoDB: Starting shutdown...
2014-05-14 15:01:06 12274 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK
  (以上初始化数据库OK)

  5.启动数据库mysql
      [root@linux ~]#service mysqld start
      Starting MySQL.........................                    [  OK  ]  

  五、编译安装PHP
  1.yum安装编译需要的库   

      [root@linux ~]#yum install -y libxml2-devel bzip2-devel libmcrypt-devel mhash-devel  2.编译安装PHP
      [root@linux ~]#tar xf php-5.4.31.tar.bz2
      [root@linux ~]#cd  php-5.4.31
      [root@linux php-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
      [root@linux php-5.4.31]#make && make install
      [root@linux ~]#service httpd24 restart
      Stopping httpd:                                            [  OK  ]
      Starting httpd:                                            [  OK  ]  六、配置LAMP环境
  1.编辑httpd.conf文件
      [root@linux ~]#vim /etc/httpd24/httpd.conf
      DirectoryIndex index.php index.html
      AddType application/x-httpd-php .php
      AddType application/x-httpd-php-source .phps
      [root@linux ~]#vim /usr/local/apache/htdocs/index.php
      
      [root@linux ~]#service httpd24 restart  2.访问http://ip测试php和mysql

DSC0000.jpg

  

  (测试LAMP环境成功)
  七、安装phpmyadmin管理mysql
  1.解压phpmyadmin文件
       [root@linux ~]#unzip phpMyAdmin-4.2.7-all-languages.zip  2.创建虚拟主机
       [root@linux ~]#vim /etc/httpd24/httpd.conf
       #DocumentRoot "/usr/local/apache/htdocs"
       Include /etc/httpd24/extra/httpd-vhosts.conf
       [root@linux ~]#mkdir -p /web/host/phpadmin
       [root@linux ~]#vim /etc/httpd24/extra/httpd-vhosts.conf
      
                     ServerName linux.topgloria.com.cn
                     DocumentRoot "/web/host/phpadmin"
                        
                             Options  none
                             AllowOverride none
                             Require all granted
                        
      
       [root@linux ~]#mv phpMyAdmin-4.2.7-all-languages  /web/host/phpadmin
       [root@linux ~]#service httpd24 restart  3.访问http://ip/phpadmin

DSC0001.jpg

  八、编译安装Xcache
  1.没有安装Xcache用ab工具测试服务器性能
      [root@linux ~]# 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 [ms] (mean)
Time per request:       18.177 [ms] (mean, across all concurrent requests)
Transfer rate:          532.48 [Kbytes/sec] received
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   35  77.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
       [root@linux ~]#tar xf xcache-3.1.0.tar.gz
       [root@linux ~]#cd xcache-3.1.0
       [root@linux xcache-3.1.0]#/usr/local/php/bin/phpize
       [root@linux xcache-3.1.0]#./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
       [root@linux xcache-3.1.0]#make && make install
       [root@linux xcache-3.1.0]#mkdir /etc/php.d
       [root@linux xcache-3.1.0]#cp xcache.ini /etc/php.d
       [root@linux xcache-3.1.0]#service httpd24 restart  

  

DSC0002.jpg

  3.安装完成Xcache后测试结果   

        [root@linux ~]# 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 [ms] (mean)
Time per request:       0.327 [ms] (mean, across all concurrent requests)
Transfer rate:          1170.31 [Kbytes/sec] received
Connection Times (ms)
              min  mean[+/-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、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-638144-1-1.html 上篇帖子: Maven+Appfuse+Apache+Subversion+ViewVC+Jira+Confluence安装手记 下篇帖子: Apache常见问题汇总 (转)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表