所需要的源码包:
mariadb-5.5.46-linux-x86_64.tar.gz
httpd-2.4.9.tar.bz2
php-5.4.26.tar.bz2
nginx-1.8.1.tar.gz
编译mariadb:
[[email protected] ~]# yum -y remove mariadb*
[[email protected] ~]# tar xf mariadb-5.5.46-linux-x86_64.tar.gz -C /usr/local/
[[email protected] ~]# cd /usr/local/
[[email protected] local]# ln -sv mariadb-5.5.46-linux-x86_64 mysql ‘mysql’ -> ‘mariadb-5.5.46-linux-x86_64’
[[email protected] local]# id mysql
uid=27(mysql) gid=27(mysql) groups=27(mysql)
[[email protected] local]# cd mysql/
[[email protected] mysql]# chown -R root:mysql ./* ——链接文件赋权规则
[[email protected] mysql]# mkdir /mydata/data -p
[[email protected] mysql]# chown -R mysql.mysql /mydata/data/
[[email protected] mysql]# cp support-files/my-large.cnf /etc/my.cnf
[[email protected] mysql]# vim /etc/my.cnf
添加:
datadir = /mydata/data
skip_name_resolve = ON
innodb_file_per_table = ON
[[email protected] mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[[email protected] mysql]# chkconfig --add mysqld
[[email protected] mysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data
[[email protected] mysql]# ls /mydata/data/
aria_log.00000001 mysqlmysql-bin.000002 performance_schema
aria_log_control mysql-bin.000001 mysql-bin.index test
[[email protected] mysql]# service mysqld start
Starting MySQL.. SUCCESS!
[[email protected] mysql]# ss -tnl
StateRecv-Q Send-Q Local Address:PortPeer Address:Port
LISTEN05192.168.122.1:53*:*
LISTEN0128*:22*:*
LISTEN0128127.0.0.1:631*:*
LISTEN0100127.0.0.1:25*:*
LISTEN0128:::22:::*
LISTEN0128::1:631:::*
LISTEN0100::1:25:::*
[[email protected] mysql]# vim /etc/profile.d/mysql.sh ——命令调用
export PATH=/usr/local/mysql/bin:$PATH
[[email protected] mysql]# chmod +x /etc/profile.d/mysql.sh
[[email protected] mysql]# vim /etc/lb.so.conf.d/mysql.conf ——配置mysql的库
/usr/local/bin/lib
[[email protected] mysql]# lbconfig
编译apache:
[[email protected] ~]# yum groupinstall "Development Tools" "Server Platform Development" -y
[[email protected] ~]# yum -y install pcre-devel openssl-devel zlib-devel
[[email protected] ~]# tar xf httpd-2.4.9.tar.bz2
[[email protected] ~]# cd httpd-2.4.9/
[[email protected] httpd-2.4.9]# yum -y install apr-devel apr-util-devel
[[email protected] httpd-2.4.9]# ./configure --prefix=/usr/local/apache24 --sysconfdir=/etc/httpd24--enable-so --enable-ssl -- enable-rewrite --with-zlib --with-pcre --with-apr=/usr --with-apr-util=/usr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
[[email protected] httpd-2.4.9]# make -j 4 && make install
[[email protected] profile.d]# cat /etc/profile.d/http24.sh
export PATH=/usr/local/apache24/bin:$PATH
[[email protected] apache24]# . /etc/profile.d/httpd24.sh
编译php:
[[email protected] ~]# yum -y install libxml2-devel libmcrypt-devel bzip2-devel
[[email protected] ~]# tar xf php-5.4.26.tar.bz2
[[email protected] ~]# cd php-5.4.26/
[[email protected] php-5.4.26]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-png-dir --with-jpeg-dir --with-freetype-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache24/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2
[[email protected] php-5.4.26]# make && make install
配置apache与php映射:
[[email protected] php-5.4.26]# cp /root/php-5.4.26/php.ini-production /etc/php.ini
[[email protected] php-5.4.26]# cd /etc/httpd24/
[[email protected] httpd24]# cp httpd.conf{,.backup}
[[email protected] httpd24]# vim httpd.conf
添加:
AddType application/x-httpd-php .php
DirectoryIndex index.php index.html
Listen 808 ——修改协议端口(因为这是自己编译的apache)
[[email protected] httpd24]# apachectl stop
[[email protected] httpd24]# apachectl start
[[email protected] httpd24]# vim /usr/local/apache24/htdocs/index.php
[[email protected] httpd24]# rm /usr/local/apache24/htdocs/index.html
[[email protected] httpd24]# firefox http://localhost:808
编译nginx:
[[email protected] ~]# tar xf nginx-1.8.1.tar.gz
[[email protected] nginx-1.8.1]# ./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --user=nginx --group=nginx --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --with-http_ssl_module --with-http_gzip_static_module --with-debug --with-http_stub_status_module
[[email protected] nginx-1.8.1]# make && make install
[[email protected] nginx-1.8.1]# useradd nginx
[email protected] nginx]# vim /etc/profile.d/nginx.sh
export PATH=/usr/local/nginx/sbin:$PATH
[[email protected] nginx]# . /etc/profile.d/nginx.sh
[[email protected] nginx]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[[email protected] nginx]# nginx -h
nginx version: nginx/1.8.1
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
-?,-h: this help
-v: show version and exit
-V: show version and configure options then exit
-t: test configuration and exit
-q: suppress non-error messages during configuration testing
-s signal: send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /usr/local/nginx/)
-c filename : set configuration file (default: /etc/nginx/nginx.conf)
-g directives : set global directives out of configuration file
[[email protected] html]# nginx ——启动nginx
配置nginx:
[[email protected] html]# vim /etc/nginx/nginx.conf
添加:
upstream lamp { ——虚拟主机
server 127.0.0.1:808 weight=1 max_fails=2 fail_timeout=30s;
}
location / {
root /usr/local/apache24/htdocs ;
index index.html index.htm index.php;
}
location ~.*\.(php|jsp|cgi)?$ ——动态页面给lamp执行
{
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://lamp;
}
location ~.*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ ——静态页面自己执行
{
root /usr/local/apache24/htdocs;
expires 3d;
}