Commands to launch and to set up my preferred environment in ubuntu.
$> sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y
$> sudo apt install -y php8.1-fpm php8.1 libapache2-mod-php8.1 php8.1-common php8.1-xml php8.1-xmlrpc php8.1-curl php8.1-gd php8.1-imagick php8.1-cli php8.1-imap php8.1-mbstring php8.1-opcache php8.1-soap php8.1-zip php8.1-intl php8.1-bcmath unzip php8.1-dom apache2 composer libapache2-mod-fcgid
$> sudo apt install -y certbot python3-certbot-apache #optional for SSL
$> sudo apt autoremove -y
Optionally to setup ZSH and the Z plugin
$> sudo apt install -y zsh #optional for ZSH
$> zsh
#pick option #2, to setup.
# install Z plugin
$> curl https://raw.githubusercontent.com/agkozak/zsh-z/master/zsh-z.plugin.zsh > zsh-z.plugin.zsh
$> echo source ~/zsh-z.plugin.zsh >> .zshrc
$> source ~/zsh-z.plugin.zsh
#set current user to use zsh as default
$> sudo chsh -s $(which zsh) $(whoami)
Setup apache.
### SETUP YOUR FQD - fully qualified domain
$> DOMAIN_NAME=example.com
Paste below carefully…
sudo mkdir -p /var/www/$DOMAIN_NAME/public
cd /var/www/$DOMAIN_NAME
sudo chown -R $(whoami):www-data .
sudo tee /etc/apache2/sites-available/$DOMAIN_NAME.conf << END
<VirtualHost *:80>
ServerName $DOMAIN_NAME
ServerAdmin webmaster@localhost
DocumentRoot /var/www/$DOMAIN_NAME/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Protocols h2 http/1.1
<Directory /var/www/$DOMAIN_NAME/public>
AllowOverride All
Order Allow,Deny
Allow from All
DirectoryIndex index.php
</Directory>
</VirtualHost>
END
sudo su a2dissite 000-default
sudo su a2ensite $DOMAIN_NAME.conf
sudo su a2dismod mpm_prefork
sudo su a2dismod php8.1
sudo su a2enmod mpm_event
sudo su a2enmod http2
sudo su a2enmod proxy
sudo su a2enmod proxy_fcgi
sudo su a2enconf php8.1-fpm
sudo su a2enmod rewrite
sudo su systemctl restart apache2
Probably want to ensure that your DNS settings are working. Run certbot, or put in your SSL certs manually.
other tidbits of script
###
### WARNING, this command can be dangerous.
### REVIEW initial crontab -l first, and only if you know for suer
### run the command below, and will populate.
### Handy cron stuff... INITIAL install only... REVIEW
###
echo '@daily apt update
@daily apt autoremove -y' | sudo crontab
###
### MySQL support for php
###
apt install php8.1-mysql
###
### Postgresl SQL support for php
###
apt install php8.1-pgsql
sudo -i -u postgres
createuser --interactive
### Postgresql itself
apt install postgresql postgresql-contrib
sudo systemctl start postgresql.service
####