码迷,mamicode.com
首页 > 其他好文 > 详细

LAMP源码编译安装实录

时间:2018-04-17 17:01:41      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:apache http   mysql   php   

[root@king01 ~]# rpm -ivh epel-release-6-8.noarch.rpm [root@king01 ~]# yum install -y expat-devel openssl openssl-devel pcre pcre-devel


[root@king01 ~]# groupadd apache
[root@king01 ~]# useradd apache -g apache -s /bin/nologin


[root@king01 ~]# tar zxvf apr-1.6.3.tar.gz
[root@king01 ~]# cd apr-1.6.3
[root@king01 apr-1.6.3]# ./configure --prefix=/usr/local/apr 
[root@king01 apr-1.6.3]# make
[root@king01 apr-1.6.3]# make install


[root@king01 ~]# tar zxvf apr-util-1.6.1.tar.gz
[root@king01 ~]# cd apr-util-1.6.1
[root@king01 apr-util-1.6.1]# ./configure --with-apr=/usr/local/apr/bin/apr-1-config
[root@king01 apr-util-1.6.1]# make
[root@king01 apr-util-1.6.1]# make install


[root@king01 ~]# tar zxvf httpd-2.4.29.tar.gz 
[root@king01 ~]# cd httpd-2.4.29
[root@king01 httpd-2.4.29]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-ssl --enable-so --enable-cgi --enable-rewrite --with-pcre --with-zlib --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-mpm=worker --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config

[root@king01 httpd-2.4.29]# make
[root@king01 httpd-2.4.29]# make install


[root@king01 ~]# vim /etc/httpd/httpd.conf
PidFile  "/var/run/httpd.pid"
ServerName 192.168.40.35:80
User apache
Group apache


[root@king01 ~]# vim /etc/man.config
MANPATH /usr/local/apache/man


[root@king01 ~]# vi /etc/init.d/httpd
#!/bin/bash
 #
 # httpd        Startup script for the Apache HTTP Server
 #
 # chkconfig: - 85 15
 # description: Apache is a World Wide Web server.  It is used to serve  #        HTML files and CGI.
 # processname: httpd
 # config: /etc/httpd/conf/httpd.conf
 # config: /etc/sysconfig/httpd
 # pidfile: /var/run/httpd.pid
# Source function library.
 . /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
         . /etc/sysconfig/httpd
 fi
# Start httpd in the C locale by default.
 HTTPD_LANG=${HTTPD_LANG-"C"}
# This will prevent initlog from swallowing up a pass-phrase prompt if
 # mod_ssl needs a pass-phrase from the user.
 INITLOG_ARGS=""
# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
 # with the thread-based "worker" MPM; BE WARNED that some modules may not
 # work correctly with a thread-based MPM; notably PHP will refuse to start.
# Path to the apachectl script, server binary, and short-form for messages.
 apachectl=/usr/local/apache/bin/apachectl
 httpd=${HTTPD-/usr/local/apache/bin/httpd}
 prog=httpd
 pidfile=${PIDFILE-/var/run/httpd.pid}
 lockfile=${LOCKFILE-/var/lock/subsys/httpd}
 RETVAL=0
start() {
         echo -n $"Starting $prog: "
         LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
         RETVAL=$?
         echo
         [ $RETVAL = 0 ] && touch ${lockfile}
         return $RETVAL
 }
stop() {
   echo -n $"Stopping $prog: "
   killproc -p ${pidfile} -d 10 $httpd
   RETVAL=$?
   echo
   [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
 }
 reload() {
     echo -n $"Reloading $prog: "
     if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
         RETVAL=$?
         echo $"not reloading due to configuration syntax error"
         failure $"not reloading $httpd due to configuration syntax error"
     else
         killproc -p ${pidfile} $httpd -HUP
         RETVAL=$?
     fi
     echo
 }
# See how we were called.
 case "$1" in
   start)
   start
   ;;
   stop)
   stop
   ;;
   status)
         status -p ${pidfile} $httpd
   RETVAL=$?
   ;;
   restart)
   stop
   start
   ;;
   condrestart)
   if [ -f ${pidfile} ] ; then
     stop
     start
   fi
   ;;
   reload)
         reload
   ;;
   graceful|help|configtest|fullstatus)
   $apachectl $@
   RETVAL=$?
   ;;
   *)
   echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
   exit 1
 esac
exit $RETVAL

[root@king01 ~]# chmod a+x /etc/init.d/httpd


[root@king01 ~]# chkconfig --add httpd
[root@king01 ~]# chkconfig --level 345 httpd on
[root@king01 ~]# service httpd start
Starting httpd:                                            [  OK  ]
[root@king01 ~]# netstat -tupln |grep http
tcp        0      0 :::80                       :::*                        LISTEN      1974/httpd


[root@king01 ~]# yum install -y libaio* ncurses-devel cmake


[root@king01 ~]# echo "192.168.1.201   king01" >>/etc/hosts
[root@king01 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.201   king01


[root@king01 ~]# useradd mysql
[root@king01 ~]# id mysql
uid=500(mysql) gid=500(mysql) groups=500(mysql)


[root@king01 ~]# cat >> /etc/security/limits.conf <<EOF
mysql            soft    nproc          2047
mysql            hard    nproc          16384
mysql            soft    nofile         1024
mysql            hard    nofile         65536
EOF


[root@king01 ~]# tar zxvf mysql-5.6.36.tar.gz 
[root@king01 ~]# cd mysql-5.6.36
[root@king01 mysql-5.6.36]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

[root@king01 mysql-5.6.36]# make && make install

[root@king01 mysql-5.6.36]# cd support-files/
[root@king01 support-files]# cp mysql.server /etc/init.d/mysqld
[root@king01 support-files]# chmod a+x /etc/init.d/mysqld


[root@king01 ~]# vim /etc/my.cnf 
[mysqld]
port = 3306
user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
socket = /tmp/mysql.sock
pid-file = /usr/local/mysql/data/mysql.pid
log_error = /usr/local/mysql/data/mysql.err
explicit_defaults_for_timestamp
sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
open-files-limit = 65535
max_connections = 500
max_connect_errors = 10000
key_buffer_size = 256M
max_allowed_packet = 16M
read_buffer_size = 1M
read_rnd_buffer_size = 1M
sort_buffer_size = 1M
join_buffer_size = 1M
tmp_table_size = 256M
max_heap_table_size = 256M
table_open_cache = 512
thread_cache_size = 64
slow_query_log = 1
long_query_time = 5
log-queries-not-using-indexes
slow-query-log-file = /usr/local/mysql/data/slow-query.log
log_bin = mysql-bin
binlog_format = row
sync_binlog = 1
binlog_cache_size = 16M
max_binlog_cache_size = 32M
max_binlog_size = 512M
expire_logs_days = 7
relay_log = relay-bin
relay_log_recovery = 1
master_info_repository = table
relay_log_info_repository = table
innodb_buffer_pool_size = 2G
innodb_buffer_pool_instances = 2
innodb_log_file_size = 128M
innodb_log_files_in_group = 3
innodb_log_buffer_size = 16M
innodb_undo_logs= 128
innodb_undo_tablespaces = 3
innodb_file_format = Barracuda
innodb_strict_mode = 1
innodb_data_file_path = ibdata1:1024M:autoextend
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
socket = /tmp/mysql.sock
[client]
socket = /tmp/mysql.sock


[root@king01 ~]# cd /usr/local/mysql
[root@king01 mysql]# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data



[root@king01 ~]# vim /etc/profile
PATH=$PATH:/usr/local/mysql/bin
[root@king01 ~]# source /etc/profile


[root@king01 ~]# chkconfig --add mysqld
[root@king01 ~]# chkconfig --level 345 mysqld on
[root@king01 ~]# chkconfig --list |grep mysqld
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@test01 ~]# service mysqld start
Starting MySQL.......                                      [  OK  ]

[root@test01 ~]# service mysqld status
MySQL running (15612)                                      [  OK  ] 

[root@king01 ~]# netstat -tupln |grep mysqld
tcp        0      0 :::3306                     :::*                        LISTEN      10101/mysqld

[root@king01 ~]# echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf
[root@king01 ~]# ldconfig

[root@king01 ~]# mysql_secure_installation
[root@king01 ~]# mysql -uroot -pabcd.1234 
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
 
mysql> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host      | password                                  |
+------+-----------+-------------------------------------------+
| root | localhost | *8E329B15E3C0FF9DDF7597B748CCE9473593BF60 |
| root | 127.0.0.1 | *8E329B15E3C0FF9DDF7597B748CCE9473593BF60 |
| root | ::1       | *8E329B15E3C0FF9DDF7597B748CCE9473593BF60 |
+------+-----------+-------------------------------------------+
3 rows in set (0.00 sec)




   



LAMP源码编译安装实录

标签:apache http   mysql   php   

原文地址:http://blog.51cto.com/13598811/2104461

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!