Skip to content

Instantly share code, notes, and snippets.

@vaibhavpandeyvpz
Last active April 27, 2023 16:23
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save vaibhavpandeyvpz/2418b9456df64724ede3510faa82ba7e to your computer and use it in GitHub Desktop.
Save vaibhavpandeyvpz/2418b9456df64724ede3510faa82ba7e to your computer and use it in GitHub Desktop.
Install and setup LAMP stack + Composer on a clean Ubuntu 16.04 VPS
#!/usr/bin/env bash
APACHE_USER=wwwhost
VHOSTS_DOMAINS=(example.com second.example.com)
sudo ufw allow in "OpenSSH"
# Install Apache
sudo apt-get update
sudo apt-get install apache2
sudo nano /etc/apache2/apache2.conf # Add ServerName ... directive at bottom
sudo apache2ctl configtest
sudo systemctl restart apache2
sudo ufw allow in "Apache Full"
# Install MySQL
sudo apt-get install mysql-server
sudo mysql_secure_installation
# Install PHP
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
sudo nano /etc/apache2/mods-enabled/dir.conf # Move index.php to start
sudo systemctl restart apache2
# Install Composer
sudo apt-get install curl php-cli git
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
# Secure Apache
sudo adduser $APACHE_USER
sudo nano /etc/apache2/envvars # Update APACHE_RUN_USER & APACHE_RUN_GROUP to '$APACHE_USER'
# Create VirtualHosts
for $DOMAIN in "${VHOSTS_DOMAINS[@]}"
do
sudo mkdir -p /var/www/$DOMAIN/public_html
sudo chown -R $APACHE_USER:$APACHE_USER /var/www/$DOMAIN
then
sudo chmod -R 755 /var/www
for $DOMAIN in "${VHOSTS_DOMAINS[@]}"
do
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/$DOMAIN.conf
# Edit & enable vhost after copying
# sudo nano /etc/apache2/sites-available/$DOMAIN.conf
# sudo a2ensite $DOMAIN.conf
then
sudo a2enmod rewrite
sudo systemctl restart apache2
@Jumbo125
Copy link

hello
i tried this on my armbian.
The problem:
how can i load the vendor/autoload file for the composer??

require_once(DIR . '/vendor/autoload.php');

not work
file not found...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment