Last active
December 31, 2018 13:51
-
-
Save a-yasui/f2a64317acb346c22f03c59651bf5c70 to your computer and use it in GitHub Desktop.
install PHPEnv + PHP7.2 + MySQL8 in CentOS7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# see: https://qiita.com/a_yasui/items/40ec1c30afc9f90acd0e | |
PHP_VERSION=7.2.13 | |
INSTALL_DIR=/opt/phpenv | |
MYSQL_YUM_REPOSITORY_RPM=https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm | |
MY_CNF=https://gist.githubusercontent.com/a-yasui/9b3a185f2920e5f1bfd0dbba10aa2261/raw/6a5ec116dc6295aeeda1ca3599fe11da687e1bb3/my.cnf | |
# 必要なものをインストール | |
yum install -y bzip2 \ | |
bzip2-devel \ | |
bison \ | |
re2c \ | |
libxml2-devel \ | |
openssl-devel \ | |
libcurl-devel \ | |
libjpeg-devel \ | |
libpng-devel \ | |
libicu-devel \ | |
readline-devel \ | |
libtidy-devel \ | |
libxslt-devel \ | |
libmcrypt-devel \ | |
git | |
yum groups install development -y | |
# create working directory | |
mkdir -p /srv/phpenv-work; | |
cd /srv/phpenv-work; | |
# save the profile. | |
PROFILE_PATH="/etc/profile.d/phpenv.sh" | |
touch $PROFILE_PATH; | |
echo 'export PHPENV_ROOT="/opt/phpenv"' >> $PROFILE_PATH | |
echo 'export PATH="$PATH:$PHPENV_ROOT/bin"' >> $PROFILE_PATH | |
source /etc/profile.d/phpenv.sh | |
# install the PHPENV | |
curl -L https://raw.github.com/CHH/phpenv/master/bin/phpenv-install.sh | bash; | |
mkdir ${INSTALL_DIR}/plugins; | |
git clone https://github.com/php-build/php-build.git ${INSTALL_DIR}/plugins/php-build; | |
echo 'eval "$(phpenv init -)"' >> /etc/profile.d/phpenv.sh | |
eval "$(phpenv init -)" | |
phpenv install $PHP_VERSION; | |
phpenv global $PHP_VERSION; | |
# Install the php-fpm start up script in systemctl file | |
php_fpm_service="${INSTALL_DIR}/versions/${PHP_VERSION}/etc/systemd/system/php-fpm.service" | |
if [ -e ${php_fpm_service} ]; then | |
cp ${php_fpm_service} /etc/systemd/system/; | |
systemctl enable php-fpm.service | |
fi | |
# Install MySQL | |
# see: https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/ | |
rpm -ivh ${MYSQL_YUM_REPOSITORY_RPM}; | |
yum install -y mysql-community-server; | |
systemctl enable mysqld.service; | |
systemctl start mysqld; | |
echo -n 'mysql root password : ' | |
grep 'temporary password' /var/log/mysqld.log | awk '{print $13}' | |
curl ${MY_CNF} > /etc/my.cnf; | |
# Install Nginx | |
yum install -y nginx; | |
# open the http/https | |
firewall-cmd --add-service=https --zone=public; | |
firewall-cmd --add-service=http --zone=public; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i forget -y option in
yum install mysql-community-server