只在同一台主机上实现
脚本如下
#!/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