Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gigabyteservice/5c892c5e3309c17d78f4a9d481680b08 to your computer and use it in GitHub Desktop.
Save gigabyteservice/5c892c5e3309c17d78f4a9d481680b08 to your computer and use it in GitHub Desktop.
Install MongoDB on Ubuntu with Nginx and PHP
sudo apt update
sudo apt install nginx
sudo systemctl stop nginx.service
sudo systemctl start nginx.service
sudo systemctl enable nginx.service
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php7.4-cli php7.4-fpm php7.4-mysql php7.4-common php7.4-mongodb php-pear php7.4-dev php7.4-curl php7.4-json php7.4-mbstring php7.4-xml php7.4-bcmath -y
# install mongodb https://gist.github.com/gigabyteservice/3ed2e0b46face796c1ff109d3ce7965d
sudo pecl install mongodb
sudo bash
sudo echo "extension=mongodb.so" >> /etc/php/7.4/fpm/php.ini
sudo echo "extension=mongodb.so" >> /etc/php/7.4/cli/php.ini
sudo nano /etc/nginx/sites-available/example
ln -s /etc/nginx/sites-available/example /etc/nginx/sites-enabled/
nginx config https://gist.github.com/gigabyteservice/b10343f3ec2fbf0d6ee7aa99551dbc7f
sudo systemctl restart nginx.service
sudo systemctl restart php7.2-fpm.service
# create toot directory and give permission for www-data and fpt user
# setfacl -R -m u:ubuntu:rwx example.com
export WEBSITEUSER=youruser
adduser $WEBSITEUSER # (go through add-user wizard, or use the 'useradd' command to do this noninteractively)
mkdir -p /home/$WEBSITEUSER/logs
chown $WEBSITEUSER:www-data /home/$WEBSITEUSER/logs/
chown $WEBSITEUSER:www-data /home/$WEBSITEUSER
chmod 775 /home/$WEBSITEUSER
cd /home/example.com/public_html
chown -R youruser:www-data .
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment