限量版的青春 2017-05-13
1) wget http://mirrors.hust.edu.cn/apache//apr/apr-1.5.2.tar.gz
2) tar xf apr-1.5.2.tar.gz
3) cd apr-1.5.2
4) ./configure
5) make&makeinstall
1) wget http://mirrors.hust.edu.cn/apache//apr/apr-util-1.5.4.tar.gz
2) cd apr-util-1.5.4
3) tar xf apr-util-1.5.4.tar.gz
4) ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
5) make&makeinstall
1) yum install pcre pcre-devel -y
2) yum install openssl-devel -y
3) wget http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.25.tar.bz2
4) cd httpd-2.4.25
5) ./configure \
--prefix=/usr/local/httpd \
--sysconfdir=/etc/httpd \
--enable-so \
--enable-rewrite \
--enable-ssl --enable-cgi \
--enable-cgid --enable-modules=most \
--enable-mpms-shared=all \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util \
--with-ssl=/usr/local/openssl \
--enable-proxy \
--enable-proxy-fcgi
6) make && make install
1) getenforce
2) setenforce 0
3) vim /etc/selinux/config
4) getenforce
5) iptables -F
1) vim /etc/httpd/httpd.conf
2) 添加 PidFile "/var/run/httpd.pid": 修改pid进程文件位置
1) /usr/local/httpd/apachectl start
2) netstat -tnlp
1) vim /etc/init.d/httpd
. /etc/rc.d/init.d/functions #chkconfig: 2345 10 90 # # pull in sysconfig settings [ -f /etc/sysconfig/httpd ] && . /etc/sysconfig/httpd HTTPD_LANG=${HTTPD_LANG-"C"} INITLOG_ARGS="" #apachectl=/usr/local/apache/bin/apachctl #httpd=${HTTPD-/usr/local/apache/bin/httpd} httpd=${HTTPD-/usr/local/httpd/bin/apachectl} 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 -eq 0 ] && touch $lockfile return $RETVAL } stop() { echo -n $"Stopping $prog: " killproc -p ${pidfile} -d 10 $httpd RETVAL=$? # if we are in halt or reboot runlevel kill all running sessions # so the TCP connections are closed cleanly echo [ $RETVAL -eq 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 } restart() { stop start } case "$1" in start) start ;; stop) stop ;; status) status -p ${pidfile} $httpd RETVAL=$? ;; restart) restart ;; 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 $RETVALhttpd
2) 添加执行权限
a) chmod +x /etc/init.d/httpd
3) 加入到启动服务列表中
a) chkconfig --add httpd
b) chkconfig --list httpd
c) chkconfig --level 35 httpd on
4) 处理报错信息
a) vim /etc/httpd/httpd.conf
ServerName localhost:80
a) vim /etc/profile.d/httpd.sh
a) export PATH=$PATH:/usr/local/httpd/bin/
b) 注意httpd -t生效需要退出重新登录
1) wget https://downloads.mysql.com/archives/get/file/mysql-5.5.28-linux2.6-i686.tar.gz
ii. 解压到指定目录
1) tar xf mysql-5.5.28-linux2.6-i686.tar.gz -C /usr/local/
iii. 切换到该目录下
1) cd /usr/local/
iv. 做链接
1) ln -sv mysql-5.5.28-linux2.6-i686/ mysql
v. 添加用户, 修改属主, 属组
1) groupadd -r -g 306 mysql
2) useradd -g 306 -r -u 306 mysql
3) chown -R root.mysql /usr/local/mysql/*
vi. 制作逻辑卷
1) fdisk /dev/sdb
2) pvcreate /dev/sdb5
3) vgcreate myvg /dev/sdb5
4) lvcreate -n mydata -L 5G myvg
5) lvs
6) mke2fs -j /dev/myvg/mydata
vii. 数据库数据存放至逻辑卷
1) mkdir /mydata/
2) mount /dev/myvg/mydata /mydata/
viii. 修改/etc/fstab文件
1) /dev/myvg/mydata /mydata ext3 defaults 0 0
2) mount -a
ix. 修改数据存储文件夹权限
1) chown -R mysql.mysql data/
2) chmod o-x /mydata/data/
1) yum install -y libaio: 初始化时报错的解决办法
2) cd /user/local/mysql
3) scripts/mysql_install_db --user=mysql --datadir=/mydata/data/
4) chown -R root /usr/local/mysql/*
xi. 修改启动文件
1) cp support-files/mysql.server /etc/init.d/mysqld
xii. 添加入开机启动
1) chkconfig --add mysqld
2) chkconfig --list mysqld
1) cp /usr/local/mysql-5.5.28-linux2.6-i686/support-files/my-huge.cnf /etc/my.cnf
2) vim /etc/my.cnf
a) datadir = /mydata/data/mysql
b) thread_concurrency = 8
c) mysql中一个cpu提供2个线程
i) 查看当前系统有几个cpu:cat /proc/cpuinfo
ii) 所以这里最多有2个线程,修改为2
1) vim /etc/profile.d/mysqld.sh
a) export PATH=$PATH:/usr/local/mysql/bin
2) 退出重新登录
1) service mysqld start
mysql -u root mysql
mysql>use mysql;
mysql>desc user;
mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "william"; //为root添加远程连接的能力。
mysql>update user set Password = password('xxxxxx') where User='root';
mysql>select Host,User,Password from user where User='root';
mysql>flush privileges;
mysql>exit
重新登录:mysql -u root -p
1) wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.6.tar.gz
2) tar xf libmcrypt-2.5.6.tar.gz
3) cd libmcrypt-2.5.6
a) ./configure --prefix=/usr/local/libmcrypt
ii. wget http://museum.php.net/php5/php-5.4.13.tar.bz2
iii. yum install gcc openssl-devel libxml2-devel bzip2-devel -y
cd php-5.4.13
iv. 编译安装
./configure \
--prefix=/usr/local/php \
--enable-fpm \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d \
--with-libxml-dir=/usr \
--with-openssl \
--with-zlib \
--with-bz2 \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--enable-mbstring \
--with-mcrypt \
--enable-sockets \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-maintainer-zts \
--with-mcrypt=/usr/local/libmcrypt
1) make && make install
1) cp php.ini-production /etc/php.ini
2) 为php-fpm提供Sysv init脚本, 并将其添加至服务列表
a) cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
b) chmod +x /etc/init.d/php-fpm
c) chkconfig --add php-fpm
d) chkconfig --list php-fpm
vi. 修改httpd.conf
1) AddType application/x-httpd-php .php
2) AddType application/x-httpd-source .phps
vii. 配置php-fpm
1) 为php-fpm提供Sysv init脚本, 并将其添加至服务器列表
a) cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
b) chmod +x /etc/rc.d/init.d/php-fpm
c) chkconfig --add php-fpm
d) chkconfig php-fpm on
a) cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
3) 编辑php-fpm的配置文件
a) vim /usr/local/php/etc/php-fpm.conf
b) 配置fpm的相关选项为你所需要的值, 并启用pid文件
i) pm.max_children = 50
ii) pm.start_servers = 5
iii) pm.min_spare_servers=2
iv) pm.max_spare_servers=8
v) pid=/usr/local/php/var/run/php-fpm.pid
1) service php-fpm start
2) netstat -tnlp
PHP连接HTTP
i. 修改php服务器配置php-fpm的文件vim /usr/local/php/etc/php-fpm 定位到listen =192.168.205.117:9000
ii. 在该主机上新建虚拟主机目录用于存放网页文件
mkdir -pv /www/{glinux,gliuxstar}
iii. 配置http服务器Apache虚拟主机使用php
1) 在httpd主机上, 192.168.205.116, 建立一个目录作为虚拟主机的家目录
a) mkdir -pv /www/{glinux,glinuxstar}
a) vim /etc/httpd/httpd.conf
One. 注释 #DocumentRoot "/usr/local/apache/htdocs"
Two. 并打开启用 Include /etc/httpd/extra/httpd-vhosts.conf
Three. 同时定位 AddType;添加下面两行
First. AddType application/x-httpd-php .php
Second. AddType application/x-httpd-php-source .phps
Four. 并且定位至DirectoryIndex
First. <IfModule dir_module>
1. DirectoryIndex index.php index.html #添加index.php(最好添加在最前面)
Second. </IfModule>
Five. 启动模块
First. 还要启用proxy_module proxy-fcgi_module等
Second. LoadModule proxy_module modules/mod_proxy.so #开启
Third. LoadModule proxy_connect_module modules/mod_proxy_connect.so
Fourth. LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
Fifth. LoadModule proxy_http_module modules/mod_proxy_http.so
Sixth. LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so #开启
<VirtualHost *:80>
DocumentRoot "/www/glinux"
ServerName www.glinux.com
ServerAlias glinux.com
ErrorLog "/usr/local/httpd/logs/glinux.error_log"
CustomLog "/usr/local/httpd/logs/glinux.access_log" combined
ProxyRequests off
ProxyPassMatch ^/(.*.php)$ fcgi://192.168.205.117:9000/www/glinux/$1
<Directory "/www/glinux">
Options none
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
vim /www/glinux/index.php
<?php
phpinfo();
?>
浏览器里输入: http://192.168.205.116
1) wget http://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz
2) 安装xcache
a) tar xf xcache-3.2.0.tar.gz
b) cd xcache-3.2.0
c) 安装依赖关系
i) yum -y install m4 autoconf
d) /usr/local/php/bin/phpize
e) ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
f) make && make install
3) 安装完毕后会出现这么一行 Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
4) 编辑php.ini,整合php和xcache:
a) 首先将xcache提供的样例配置导入php.ini
i) # mkdir /etc/php.d
ii) # cp xcache.ini /etc/php.d
iii) 说明:xcache.ini文件在xcache的源码目录中。
5) 接下来编辑/etc/php.d/xcache.ini,找到extension开头的行,修改为如下行:
a) extension = /usr/local/php/lib/php/extensions/no-debug-zts-20131226/xcache.so
b) 注意:如果php.ini文件中有多条zend_extension指令行,要确保此新增的行排在第一位。
6) 然后重启服务即在phpinfo的页面中就可看见xcache的选项了。
7) 关闭xcache方法
a) vim /etc/php.d/xcache.ini
i) xcache.size = 0 :设置为0是关闭xcache
use mysql;
grant all privileges on *.* to 'root'@'192.9.205.105' identified by 'william';
select Host,User,Password from user where User='root';
flush privileges;
<?php
$link=mysql_connect('192.168.205.115','root','william');
if($link){
echo "success..william!";
}else{
echo "failed..frank!".mysql_error();
}
mysql_close($link);
phpinfo();
?>
浏览器里输入: http://192.168.205.116
wget https://files.phpmyadmin.net/phpMyAdmin/4.7.0/phpMyAdmin-4.7.0-all-languages.tar.gz
1) 在php 主机和http主机上分别在/www目录建立一个文件夹glinux, 并同样执行下面操作
2) tar xf phpMyAdmin-4.7.0-all-languages.zip
3) cd /www/glinux
4) mv /root/phpMyAdmin-4.7.0/* ./
5) 接下来在php主机上进行对phpmyadmin的配置。
6) cp config.sample.inc.php config.inc.php
7) vim config.inc.php
a) 主要找到
b) $cfg['Servers'][$i]['host']=‘192.168.205.115’ 数据库服务器的IP地址
c) $cfg['blowfish_secret'] = 'william';这里的字符随意,这个主要是为了区分cookie。
8) 然后重启三台主机上的服务即可测试。
下面关于LAMP相关的内容你可能也喜欢: