By Sheldon L | Published at 2020-06-12 | Updated at 2020-06-12 |
sudo apt-get install apache2
# ServerName
sudo apache2ctl configtest # See ... using 127.0.1.1. Set the 'ServerName' ...
sudo nano /etc/apache2/apache2.conf
"""
. . .
ServerName <server_domain_or_IP>
"""
sudo ufw app list
sudo ufw allow 'Apache'
sudo ufw status
sudo systemctl start apache2
sudo apt-get install mysql-server
sudo mysqladmin -u root password
sudo mysql_secure_installation
# N for not VALIDATE PASSWORD
# Y for the rest
sudo apt install php7.4
php -v
# check the model installed
php -m
# Most commonly used packages for php7.4
sudo apt install php-pear php7.4-curl php7.4-dev php7.4-gd php7.4-mbstring php7.4-zip php7.4-mysql php7.4-xml
# Install More PHP Modules
apt-cache search php- | less
apt-cache show <package_name>
sudo apt-get install <package_name>
# If more than 1 version are installed, set the version
update-alternatives --set php /usr/bin/php<version>
sudo nano /etc/apache2/mods-enabled/dir.conf
# move `index.php` to be the first one of DirectoryIndex
sudo systemctl restart apache2
sudo systemctl status apache2
# Test PHP Processing on your Web Server
sudo nano /var/www/html/info.php
"""
<?php
phpinfo();
?>
"""
# check http://your_server_address/info.php
sudo rm /var/www/html/info.php # you can remove the php test
sudo apt install phpmyadmin
# set password for phpmyadmin during the installation
# OR reconfigure after installation:
sudo dpkg-reconfigure phpmyadmin
# If using apache2, check if /var/www/html/phpmyadmin exists, if not, then:
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
# open http://domain_address/phpmyadmin
cd ~/Downloads
curl -sS https://getcomposer.org/installer -o composer-setup.php
# install globally
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
# install in local project
php composer-setup.php # using `composer.phar` instead of `composer`
# test installation
composer
# You may need to change mirror source in China
composer config -g repo.packagist composer https://packagist.phpcomposer.com # -g: global, Chinese source
composer config -g --unset repos.packagist # back to default: https://packagist.org
# OR:
# 3rd party: crm (composer registry manager)
composer global require slince/composer-registry-manager
composer repo:ls
composer repo:use aliyun
# similar settings
composer config -g github-protocols https ssh
composer config -g --unset github-protocols
cd ~/Downloads
mkdir slugify
cd slugify
# search a package in https://packagist.org/, such as cocur/slugify (<vender>/<package>)
composer require cocur/slugify
# it will generate the composer.json and composer.lock
# and pull a folder `vender` with `autoload.php` in it
ls -l
cat composer.json
# Since PHP itself doesn’t automatically load classes
# you need to including the Autoload Script (`/vendor/autoload.php` in this case)
nano test.php
"""
<?php
require __DIR__ . '/vendor/autoload.php';
use Cocur\Slugify\Slugify;
$slugify = new Slugify();
echo $slugify->slugify('Hello World, this is a long sentence and I need to make a slug from it!');
"""php test.php
# Updating Project Dependencies
composer update
composer update <vendor>/<package> <vendor2>/<package2>
XAMPP
, such as WordPress
.cd /opt/lampp
# open xampp panel
sudo ./xampp panel
# open all servers
sudo ./xampp start
# open web server
sudo ./xampp startapache
# same as stop and reload ...
# Install Composer