编译安装lamp2(php-fpm)

同一台主机:

不仔细写了,自己写了一个脚本

#!/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
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..."
}

installhttpd(){
yum install -y  gcc gcc-c++ apr apr-util-devel apr-devel openssl-devel pcre-devel
#groupadd -g 808 -r apache
id apache || useradd -r -u 808 apache
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
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
eof
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
make -j 8 && make install
/usr/bin/cp $lampdir/php-5.6.4/php.ini-production /etc/php.ini
cp $lampdir/php-5.6.4/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
chmod a+x /etc/rc.d/init.d/php-fpm
chkconfig --add php-fpm
#cp /etc/php.ini /usr/local/php/etc/
cd /usr/local/php/etc/ && cp php-fpm.conf.default php-fpm.conf
}
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
service php-fpm start
systemctl restart httpd.service
iptables -F
setenforce 0
rm -rf $lampdir
echo "is ok"
echo "you can use 'http://localhost/phpMyAdmin' to access your mysql databases,mysql'user is root and password is root "

blob.png

blob.pngblob.png

blob.png

blob.png

blob.png

blob.png

blob.png

类似文章