Last active
April 30, 2020 01:16
-
-
Save erickpatrick/c014febe11708cee88cd3d8083307fda to your computer and use it in GitHub Desktop.
Install php7.3-magento-ngnix
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
PATH_TO_MAGENTO='/path/to/magento/installation/folder' | |
GITHUB_TOKEN='github-token-here' | |
MAGENTO_USER='your-key-here' | |
MAGENTO_PASS='your-pass-here' | |
MAGENTO_ADMIN_URL='http://your-server.com' | |
MAGENTO_ADMIN_USER='admin' | |
MAGENTO_ADMIN_PASS='admin123' | |
# ondrej best php apt-repository for php to be able to | |
# update and install PHP as needed | |
sudo add-apt-repository ppa:ondrej/php | |
sudo apt-get update | |
# need to install updated and missing extensions for php7.3 | |
sudo apt-get install php7.3 php7.3-fpm php7.3-dev php7.3-bcmath \ | |
php7.3-common php7.3-curl php7.3-gd php7.3-mbstring php7.3-mcrypt \ | |
php7.3-pdo php7.3-mysql php7.3-xml php7.3-xmlrpc php7.3-xsl \ | |
php7.3-zip php7.3-soap php7.3-phpdbg php7.3-opcache php7.3-json \ | |
php7.3-intl php7.3-json php7.3-iconv | |
# Use the best server, right? ;) | |
sudo apt-get install nginx | |
# please edit this file updating the following lines: | |
# - cgi.fix_pathinfo=0 | |
# - display_errors=On | |
# - memory_limit=1024M | |
# - max_execution_time = 600 | |
# - max_input_nesting_level = 512 | |
# - post_max_size = 128M | |
# - upload_max_filesize = 128M | |
sudo vim /etc/php/7.1/fpm/php.ini | |
# restarting the fpm process so we can use it with Nginx | |
sudo service php7.3-fpm restart | |
# install Magento so we can use it when updating Nginx 'vhost' | |
# configuration, allowing the server to restart properly | |
git clone git@github.com:magento/magento2.git $PATH_TO_MAGENTO | |
# create and fill out auth.json under home folder please fill out the keys | |
json="{ \"github-oauth\": { \"github.com\": \"$GITHUB_TOKEN\" }, \"http-basic\": { \"repo.magento.com\": { \"username\": \"$MAGENTO_USER\", \"password\": \"$MAGENTO_PASS\" } } }" | |
echo $json > ~/auth.json | |
# Nginx 'vhost' configuration as recommended by Magento on | |
# <path to magento>/nginx.conf.sample | |
vhost="upstream fastcgi_backend { | |
server unix:/var/run/php/php7.3-fpm.sock; | |
} | |
server { | |
listen 80; | |
server_name your-domain-or-ip.com; | |
set \$MAGE_ROOT $PATH_TO_MAGENTO; | |
set \$MAGE_MODE developer; # or production|default | |
fastcgi_param MAGE_MODE \$MAGE_MODE; | |
include $PATH_TO_MAGENTO/nginx.conf.sample; | |
}" | |
sudo echo $vhost > /etc/nginx/sites-available/default | |
# restart server in order to things work as expected | |
sudo service nginx restart | |
# remove default composer and reisntall to pass over permission problems | |
sudo rm -rf /usr/local/bin/composer | |
sudo rm -rf ~/.composer/cache/ | |
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer | |
# run composer to really install Magento | |
cd $PATH_TO_MAGENTO | |
composer install | |
# export this path in order to use Magento's cli command without | |
# having to call `bin/magento <command>`, but, instead use just | |
# `magento <command>`. Also, add this to your .zshrc, .profile, | |
# .bashr_profile, .bashrc, .fish, etc... | |
export PATH=$PATH:$PATH_TO_MAGENTO/bin | |
# edit /etc/php/7.1/fpm/conf.d/20-xdebug.ini with the following | |
# setting to properly enable xDebug for things other than cli | |
# xdebug.remote_enable=1 | |
# xdebug.remote_handler=dbgp | |
# xdebug.remote_mode=req | |
# xdebug.remote_host=localhost | |
# xdebug.remote_port=9000 | |
# xdebug.var_display_max_depth = -1 | |
# xdebug.var_display_max_children = -1 | |
# xdebug.var_display_max_data = -1 | |
# xdebug.idekey = "vdebug" | |
sudo vim /etc/php/7.1/fpm/conf.d/20-xdebug.ini | |
# disable xdebug to speed up things during installation and updates | |
sudo phpdismod xdebug | |
# creates database for the next command | |
mysqladmin -u root create your-database-name-here | |
# install magento - change to your own values here | |
magento setup:install --base-url=http://$MAGENTO_URL/ --db-host=localhost \ | |
--db-name=your-database-name-here --admin-firstname=Magento --admin-lastname=User \ | |
--admin-email=user@example.com --admin-user=$MAGENTO_ADMIN_USER --admin-password=$MAGENTO_ADMIN_PASS \ | |
--language=en_US --currency=EUR --timezone=Europe/Berlin --use-rewrites=1 | |
# remove cached files before set to developer mode otherwise bad things can happen there | |
rm -rf pub/static var/cache/ var/page_cache/ var/composer_home/ | |
# set magento mode to developer so it`s faster to develop with | |
magento deploy:mode:set developer | |
# disables asset versioning | |
magento config:set dev/static/sign 0 | |
# isntall sample data | |
cd ~/sites | |
git clone https://github.com/magento/magento2-sample-data.git | |
cd magento2-sample-data/dev/tools | |
# create symlink for this files on our magento-installation path | |
php -f build-sample-data.php -- --ce-source="$PATH_TO_MAGENTO" | |
# update magento instalation with newsest modules and data | |
cd <path_to_magento_instalation> | |
magento setup:upgrade | |
# publish static content... even though we shouldn't need due to developer | |
# mode, magento is not reliable on this end | |
magento setup:static-content:deploy -f | |
# flush cache to be sure things are created from scratch again | |
magento cache:flush | |
# set correct permissions | |
sudo find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \; | |
sudo find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \; | |
sudo chown -R :www-data . | |
chmod u+x bin/magento | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment