[root@rs1 ~]# vim compile_nginx.sh # 查看编译安装Nginx的脚本
#!/bin/bash
#
# FTP Server
ftp_ip=192.168.10.99
# See if there is a parameter given#
! [ "$1" == "start" ] && echo "Please give parameter: start" && exit 1
echo "Let's Go!"
# download the nginx source
if ! [ -f ./nginx-${version}.tar.gz ]; then
if lftp ${ftp_ip} -e "mget upload/sources/nginx-${version}.tar.gz; exit"; then
echo "Download the Nginx package successfully."
else
echo "Failed to download the Nginx source package."
exit 2
fi
#!/bin/bash
#
# FTP Server
ftp_ip=192.168.10.99
# See if there is a parameter given#
! [ "$1" == "start" ] && echo "Please give parameter: start" && exit 1
echo "Let's Go!"
# download the nginx source
if ! [ -f ./nginx-${version}.tar.gz ]; then
if lftp ${ftp_ip} -e "mget upload/sources/nginx-${version}.tar.gz; exit"; then
echo "Download the Nginx package successfully."
else
echo "Failed to download the Nginx source package."
exit 2
fi
#!/bin/bash
#
# FTP Server
ftp_ip=192.168.10.99
# See if there is a parameter given#
! [ "$1" == "start" ] && echo "Please give parameter: start" && exit 1
echo "Let's Go!"
# download the nginx source
if ! [ -f ./nginx-${version}.tar.gz ]; then
if lftp ${ftp_ip} -e "mget upload/sources/nginx-${version}.tar.gz; exit"; then
echo "Download the Nginx package successfully."
else
echo "Failed to download the Nginx source package."
exit 2
fi
fi
# install the dependency package
if yum -y install pcre-devel openssl-devel zlib-devel gcc &> /dev/null; then
echo "Install the Nginx dependency package successfully."
else
echo "Failed to install the Nginx dependency package."
exit 3
fi
# compile the nginx
if tar xf nginx-${version}.tar.gz; then
cd nginx-${version}
./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/nginx.pid --lock-path=/var/lock/nginx.lock --with-http_ssl_module --with-http_gzip_static_module --with-debug --with-http_stub_status_module
make -j 4 && make install && echo -e "\n Compile and Install Nginx completely!"
fi
# export the program path
echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
echo -e "\nPlease execute the following command:\n ==> source /etc/profile.d/nginx.sh\n\n "
[root@rs1 ~]# ./compile_nginx.sh start # 执行脚本
...(以上输出信息省略)...
Please execute the following command:
source /etc/profile.d/nginx.sh
# Install PHP-FPM
yum -y install gcc bzip2 libmcrypt-devel libxml2-devel bzip2-devel openssl-devel &> /dev/null
if ! [ -f php-${php_version}.tar.bz2 ]; then
lftp ${ftp_ip} -e "mget upload/sources/php-${php_version}.tar.bz2; exit"
fi
if [ -d php-${php_version} ]; then
cd php-${php_version}
make clean
cd -
rm -rf php-${php_version}
fi
tar xf php-${php_version}.tar.bz2
cd php-${php_version}/
make -j ${vcpus} && make install
# Install configuration for PHP-FPM
if [ -f /etc/php.ini ]; then
mv -f /etc/php.ini{,.bak}
fi
cp php.ini-production /etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
sed -i "/^listen/s/127.0.0.1:9000/${fpm_listen_ip}:${fpm_listen_port}/" /usr/local/php/etc/php-fpm.conf
sed -i "/listen.allowed_clients/{s/127.0.0.1/${web_server_ip}/;s/;//}" /usr/local/php/etc/php-fpm.conf
if ! id ${SystemUser} &> /dev/null; then
useradd -r ${SystemUser}
fi
sed -i "/^user/s/nobody/${SystemUser}/" /usr/local/php/etc/php-fpm.conf
sed -i "/^group/s/nobody/${SystemUser}/" /usr/local/php/etc/php-fpm.conf
# Start the PHP-FPM Service
if [ -f /etc/init.d/php-fpm ]; then
rm -rf /etc/init.d/php-fpm{,.bak}
fi
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chkconfig --add php-fpm
chmod +x /etc/init.d/php-fpm
if service php-fpm start &> /dev/null; then
if ss -tnl | grep :9000 &> /dev/null; then
echo -e "\nThe PHP-FPM Service is start!" && echo -e "\n Compile and install php-fpm successfully!\n"
fi
fi
# Prepare datadir
if [ -d /mydata/data ]; then
mv -f /mydata/data{.bak}
else
mkdir -p /mydata/data
fi
# Install MySQL
if ! id mysql &> /dev/null; then
useradd -r mysql
fi
if ! [ -f mariadb-${mysql_version}-linux-x86_64.tar.gz ]; then
lftp ${ftp_ip} -e "mget upload/sources/mariadb-${mysql_version}-linux-x86_64.tar.gz; exit"
fi
if [ -d mariadb-${mysql_version}-linux-x86_64 ]; then
rm -rf mariadb-${mysql_version}-linux-x86_64
fi
tar xf mariadb-${mysql_version}-linux-x86_64.tar.gz -C /usr/local
cd /usr/local
if [ -d mysql ]; then
rm -rf mysql
fi
ln -sv mariadb-${mysql_version}-linux-x86_64 mysql
cd /usr/local/mysql
chown -R root:mysql ./*
scripts/mysql_install_db --user=mysql --datadir=/mydata/data
if [ -f /etc/init.d/mysqld ]; then
rm -f /etc/init.d/mysqld
fi
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
# Install configuration for MySQL
if [ -f /etc/my.cnf ]; then
mv -f /etc/my.cnf{.bak}
fi
cp support-files/my-large.cnf /etc/my.cnf
sed -i '42a \datadir = /mydata/data\ninnodb_file_per_table = ON\nskip_name_resolve = ON' /etc/my.cnf
# Start the MySQL Service
if service mysqld start | grep SUCCESS &> /dev/null; then
if ss -tnl | grep :3306 &> /dev/null; then
echo -e "\n Install MySQL completely!\n The MySQL Service is start!"
fi
fi
# Export the path
echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
echo -e "Please execute the following command:\n ==> source /etc/profile.d/mysql.sh\n\n " #执行脚本,安装mysql。
[root@mysql ~]# ./binary_mysql.sh start
[root@mysql ~]# source /etc/profile.d/mysql.sh
(2) 在mysql中创建数据库wpdb、授权数据库用户wpuser。
[root@mysql ~]#
[root@mysql ~]# mysql
MariaDB [(none)]> GRANT ALL ON wpdb.* TO wpuser@'192.168.10.%' IDENTIFIED BY 'wppass';
MariaDB [(none)]> CREATE DATABASE wpdb;
MariaDB [(none)]> exit