编译安装lamp

只在同一台主机上实现

脚本如下

#!/bin/bash
lampdir=`mktemp -d /tmp/lamp.XXXX`
wget -q http://10.1.1.41/lamp/php-5.6.4.tar.xz -P $lampdir
wget -q http://10.1.1.41/lamp/mariadb-5.5.46-linux-x86_64.tar.gz -P $lampdir
wget -q http://10.1.1.41/lamp/httpd-2.4.23.tar.bz2 -P $lampdir
wget -q http://10.1.1.41/lamp/phpMyAdmin-4.0.5-all-languages.zip -P $lampdir
installmariadb(){
echo "install mariadb...."
tar -xvf $lampdir/mariadb-5.5.46-linux-x86_64.tar.gz -C /usr/local
id mysql || useradd -u 306 -r mysql
cd /usr/local && ln -sv mariadb-5.5.46-linux-x86_64/ mysql
cd /usr/local/mysql && chown root:mysql ./* -R
mkdir /mydata/data -pv
chown mysql:mysql /mydata/data/ -R
/usr/bin/cp -p /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf
sed -in "/mysqld]/adatadir=/mydata/data\ninnodb_file_per_table=ON\nskip_name_resolve=ON" /etc/my.cnf
/usr/bin/cp -p /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
cd /usr/local/mysql && scripts/mysql_install_db --user=mysql --datadir=/mydata/data
echo export PATH=/usr/local/mysql/bin:$PATH >> /etc/profile.d/mysql.sh && . /etc/profile.d/mysql.sh
service mysqld start
mysql -e "UPDATE mysql.user SET Password=PASSWORD('root') WHERE User='root';"
mysql -e "DELETE FROM mysql.user WHERE User='';"
mysql -e "FLUSH PRIVILEGES;"
echo "mariadb is ok..."
}
cd $lampdir && tar -xvf $lampdir/httpd-2.4.23.tar.bz2
make -j 8 && make install
sed  -in "/User daemon/aUser apache"  /etc/httpd24/httpd.conf
sed  -in "/User daemon/d"  /etc/httpd24/httpd.conf
sed  -in "/Group daemon/aGroup apache"  /etc/httpd24/httpd.conf
sed  -in "/Group daemon/d"  /etc/httpd24/httpd.conf
sed  -in "/AddType application\/x-compress/aAddType application\/x-httpd-php .php"  /etc/httpd24/httpd.conf
sed  -in "/DirectoryIndex /aDirectoryIndex index.php index.html"  /etc/httpd24/httpd.conf
sed  -in "/DirectoryIndex index.html/d"  /etc/httpd24/httpd.conf
echo export PATH=/usr/local/apache24/bin:$PATH >> /etc/profile.d/httpd.sh && . /etc/profile.d/httpd.sh
cat > /etc/systemd/system/httpd.service <<eof
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)
[Service]
ExecStart=/usr/local/apache24/bin/httpd $OPTIONS -DFOREGROUND
ExecReload=/usr/local/apache24/bin/httpd $OPTIONS -k graceful
ExecStop=/bin/kill -WINCH ${MAINPID}
[Install]
WantedBy=multi-user.target
eof
systemctl daemon-reload
}
installphp(){
yum install -y gd-devel freetype-devel libmcrypt-devel libxml2-devel bzip2-devel
cd $lampdir && tar -xvf $lampdir/php-5.6.4.tar.xz
cd $lampdir/php-5.6.4/  && ./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-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 --enable-xml --with-gd
make -j 8 && make install
/usr/bin/cp $lampdir/php-5.6.4/php.ini-production /etc/php.ini
}
installphpadmin(){
cd $lampdir && unzip phpMyAdmin-4.0.5-all-languages.zip
mkdir -pv /usr/local/apache24/htdocs/phpMyAdmin
mv $lampdir/phpMyAdmin-4.0.5-all-languages/* /usr/local/apache24/htdocs/phpMyAdmin
setfacl -R -m u:apache:rwx /usr/local/apache24/htdocs/*
}
installmariadb
installhttpd
installphp
installphpadmin
service mysqld restart
systemctl restart httpd.service
iptables -F
setenforce 0
rm -rf $lampdir
echo "you can use 'http://localhost/phpMyAdmin' to access your mysql databases,mysql'user is root and password is root "

访问如下:

详细代码:

 

编译安装php-xcache

php-fpm的性能比php的性能好

2,安装编译环境

yum install httpd php-fpm gcc gcc-c++ php-devel -y

3,解压编译安装

tar -xvf xcache-3.2.0.tar.bz2
cd xcache-3.2.0/ 
phpize            #为了生成一下configure文件
./configure --enable-xcache --with-php-config=/usr/bin/php-config
make && make install

4,复制配置文件

cp xcache.ini /etc/php.d/

5,编写index.php

echo -e "<?php\n\tphpinfo();\n?>" >> /var/www/html/index.php

6,修改httpd的主配置文件,使之支持fcgi模式

vim /etc/httpd/conf/httpd.conf

在最下面加入下面三行用来转发

DirectoryIndex index.php
proxyrequests off
proxypassmatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/html/$1

7,保存并重启httpd服务,开启php-fpm服务

systemctl start php-fpm
systemctl restart httpd

8,关闭防火墙,然后用浏览器输入ip访问

iptables -F

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值