PHP-FPM use standard user instead of www-data

This commit is contained in:
Michael RICOIS 2016-12-02 13:45:59 +01:00
parent 67489ba9be
commit 96c7ee74bd
2 changed files with 12 additions and 6 deletions

View File

@ -38,7 +38,7 @@ Vagrant.configure(2) do |config|
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
config.vm.synced_folder "../../", "/home/vhosts", owner: "www-data", group: "www-data"
config.vm.synced_folder "../../", "/home/vhosts"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.

View File

@ -6,6 +6,7 @@ DIRDATA=$DIR/data
MYSQL_PASS=scores
MARIADB_VERSION="10.1"
PHPMYADMIN_VERSION="4.6.3"
USER=$(whoami)
# --- Add a file action.upgrade to perfom a system upgrade
if [ -f $DIR/action.upgrade ]; then
@ -36,6 +37,9 @@ if [ $VARGANTDEV -eq 1 ]; then
sudo sed -i -e 's/bind-address[ \t]*= 127.0.0.1/bind-address = 0.0.0.0/g' /etc/mysql/my.cnf
sudo sed -i -e 's/max_connections[ \t]*= 100/max_connections = 20/g' /etc/mysql/my.cnf
sudo service mysql restart
# Création utilisateur universel
mysql -uroot -p$MYSQL_PASS -e "CREATE USER 'roor'@'%' IDENTIFIED BY '$MYSQL_PASS'"
mysql -uroot -p$MYSQL_PASS -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION"
sudo touch /etc/mysql/vagrant
fi
else
@ -80,8 +84,10 @@ if [ ! -f /usr/bin/php ]; then
sudo sed -i -e 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /etc/php/7.0/fpm/php.ini
sudo sed -i -e 's/session.gc_maxlifetime = 1440/session.gc_maxlifetime = 86400/g' /etc/php/7.0/fpm/php.ini
sudo sed -i -e 's/;opcache.enable=0/opcache.enable=1/g' /etc/php/7.0/fpm/php.ini
sudo cp -f $DIRDATA/PHP/xdebug.ini /etc/php/7.0/mods-available/xdebug.ini
sudo cp -f $DIRDATA/PHP/xdebug.ini /etc/php/7.0/mods-available/xdebug.ini
# Pool user
sudo sed -i -e "s/user = www-data/user = $USER/g" /etc/php/7.0/fpm/pool.d/www.conf
sudo sed -i -e 's/group = www-data/group = "$(whoami)"/g' /etc/php/7.0/fpm/pool.d/www.conf
# --- Browscap
sudo cp -f $DIRDATA/PHP/php_browscap.ini /etc/php/7.0/fpm/
sudo sed -i -e 's/;browscap = extra\/browscap.ini/browscap = \/etc\/php\/7.0\/fpm\/php_browscap.ini/g' /etc/php/7.0/fpm/php.ini
@ -97,7 +103,7 @@ if [ ! -f /usr/bin/php ]; then
#sudo cp $DIRDATA/ChartDirector/chartdir.ini /etc/php5/mods-available/
#sudo php5enmod chartdir
#fi
sudo usermod -a -G www-data "$(whoami)"
sudo service php7.0-fpm restart
fi
# --- Composer
@ -112,8 +118,8 @@ if [ ! -d "/home/vhosts/$PHPMYADMIN_DIR" ]; then
wget -q "$PHPMYADMIN_URL/$PHPMYADMIN_VERSION/$PHPMYADMIN_DIR.tar.xz" -O "/home/vagrant/$PHPMYADMIN_DIR.tar.xz"
if [ -f "/home/vagrant/$PHPMYADMIN_DIR.tar.xz" ]; then
tar xJvf "/home/vagrant/$PHPMYADMIN_DIR.tar.xz" --directory /home/vhosts/
mysql -hlocalhost -uroot -p$MYSQL_PASS < /home/vhosts/$PHPMYADMIN_DIR/sql/create_tables.sql
mysql -hlocalhost -uroot -p$MYSQL_PASS < $DIRDATA/Apps/phpmyadmin.sql
mysql -uroot -p$MYSQL_PASS < /home/vhosts/$PHPMYADMIN_DIR/sql/create_tables.sql
mysql -uroot -p$MYSQL_PASS < $DIRDATA/Apps/phpmyadmin.sql
sudo service mysql restart
cp $DIRDATA/Apps/config.inc.php /home/vhosts/$PHPMYADMIN_DIR/
chmod 0644 /home/vhosts/$PHPMYADMIN_DIR/config.inc.php