To install PHP 7.4 on Ubuntu 22.04, you can follow these steps:
Update your package list:
sudo apt updateInstall the software-properties-common package:
sudo apt install software-properties-commonAdd the repository for PHP 7.4:
sudo add-apt-repository ppa:ondrej/phpUpdate your package list again:
sudo apt updateInstall PHP 7.4:
sudo apt install php7.4Verify the installation:
php -v
This will install PHP 7.4 on your Ubuntu 22.04 system. If you need specific PHP 7.4 extensions, you can install them using:
sudo apt install php7.4-[extension]sudo apt-get install php7.4-mbstringsudo apt-get install php7.4-curlsudo apt-get install php7.4-xmlsudo apt-get install php7.4-intlsudo apt-get install php7.4-mysqlisudo apt-get install php7.4-curl -y
Replace [extension] with the specific extension you need, such as php7.4-mysql, php7.4-xml, etc.
Other if you might like
Set Timezone
sudo timedatectl set-timezone Asia/Kolkata
To install Marriadb Server
sudo apt install mariadb-server -y
sudo apt install mariadb-client-core -y
Then start + enable service:
sudo systemctl enable mariadb
sudo systemctl start mariadb
After login – secure installation (recommended)
sudo mysql_secure_installation
Next for execute apache and upload files
Model: GPT-5
Best practice → make ubuntu the owner and group www-data so Apache can also read/write/execute.
Step 1 — set owner & group
sudo chown -R ubuntu:www-data /var/www/html
Step 2 — give permissions
Allow:
-
owner (ubuntu) = read/write/execute
-
group (www-data) = read/execute (and write if needed)
sudo chmod -R 775 /var/www/html
STEP 3 — make sure apache runs as www-data
By default apache2 on ubuntu = www-data
Check:
grep -i '^user\|^group' /etc/apache2/envvars
Should show:
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
Final correct setup (recommended)
sudo chown -R ubuntu:www-data /var/www/html
sudo chmod -R 775 /var/www/html
This gives ubuntu = full access
and apache (www-data) = read/write/execute inside project dirs.
If you add new files via git / sftp
To automatically inherit permissions:
sudo find /var/www/html -type d -exec chmod g+s {} \;
To Remove index.php follow this link
https://site4developer.blogspot.com/2019/05/remove-indexphp-in-ubuntu-aws-ec2.html
0 comments:
Post a Comment