LAMP源码编译安装实录

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LAMP源码编译安装实录相关的知识,希望对你有一定的参考价值。

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


[[email protected] ~]# groupadd apache
[[email protected] ~]# useradd apache -g apache -s /bin/nologin


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


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


[[email protected] ~]# tar zxvf httpd-2.4.29.tar.gz 
[[email protected] ~]# cd httpd-2.4.29
[[email protected] 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

[[email protected] httpd-2.4.29]# make
[[email protected] httpd-2.4.29]# make install


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


[[email protected] ~]# vim /etc/man.config
MANPATH /usr/local/apache/man


[[email protected] ~]# 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 [email protected]
   RETVAL=$?
   ;;
   *)
   echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
   exit 1
 esac
exit $RETVAL

[[email protected] ~]# chmod a+x /etc/init.d/httpd


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


[[email protected] ~]# yum install -y libaio* ncurses-devel cmake


[[email protected] ~]# echo "192.168.1.201   king01" >>/etc/hosts
[[email protected] ~]# 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


[[email protected] ~]# useradd mysql
[[email protected] ~]# id mysql
uid=500(mysql) gid=500(mysql) groups=500(mysql)


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


[[email protected] ~]# tar zxvf mysql-5.6.36.tar.gz 
[[email protected] ~]# cd mysql-5.6.36
[[email protected] 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

[[email protected] mysql-5.6.36]# make && make install

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


[[email protected] ~]# 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


[[email protected] ~]# cd /usr/local/mysql
[[email protected] mysql]# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data



[[email protected] ~]# vim /etc/profile
PATH=$PATH:/usr/local/mysql/bin
[[email protected] ~]# source /etc/profile


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

[[email protected] ~]# service mysqld status
MySQL running (15612)                                      [  OK  ] 

[[email protected] ~]# netstat -tupln |grep mysqld
tcp        0      0 :::3306                     :::*                        LISTEN      10101/mysqld

[[email protected] ~]# echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf
[[email protected] ~]# ldconfig

[[email protected] ~]# mysql_secure_installation
[[email protected] ~]# 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源码编译安装实录的主要内容,如果未能解决你的问题,请参考以下文章

源码编译安装LAMP

编译安装LAMP

详解LAMP源码编译安装

源码编译安装LAMP

LAMP环境官方最新源码编译安装

想看不懂都难! 图文详细解读 LAMP源码编译安装