This guide explains how to set up this project on linux (specifically ubuntu) with apache (and mariadb) locally. For MacOS setup, see mamp-macos.md For Windows setup, see xampp-windows.md For setting up hosting with your custom domain, see hosting-linux.md
sudo apt update
sudo apt upgrade -y
sudo apt install apache2 -y
# Check if it is running
sudo systemctl status apache2Test if you see the apache default page in your browser on http://localhost/
sudo apt install php libapache2-mod-php php-mysql php-cli php-curl php-xml php-mbstring -y
# Test PHP
php -v# Create a test PHP file:
sudo nano /var/www/html/info.phpAdd <?php phpinfo(); ?>to the php file
Visit http://localhost/info.php
sudo apt install mariadb-server mariadb-client -y
# Secure the installation:
sudo mysql_secure_installationFollow prompts:
- Set root password
- Remove anonymous users
- Disallow remote root login
- Remove test database
Test
sudo mysql -u root -pLog into the database
sudo mysql -u root -pRun the following code and replace 'yourpassword'
CREATE USER 'studyshare'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON study_share.* TO 'studyshare'@'localhost';
FLUSH PRIVILEGES;Clone the repo into the /var/www/html/ directory
cd /var/www/html/
# Via HTTPS
git clone https://github.com/DarioLoll/study-share.git
# Via SSH
git clone git@github.com:DarioLoll/study-share.gitGive Apache read, write and execute rights:
sudo chown -R $USER:www-data /var/www/html/study-share
sudo chmod -R 775 /var/www/html/study-share
sudo chmod g+s /var/www/html/study-shareSet Apache's document root to src/public
# Open the config file
sudo nano /etc/apache2/sites-available/000-default.confChange the DocumentRootline and add the <Directory> tag below
DocumentRoot "/var/www/html/study-share/src/public"
# Apache denies access by default to directories outside /var/www/html
<Directory "/var/www/html/study-share/src/public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>Save the file
To make sure apache always redirects to index.php and let the php handle the routing:
sudo a2enmod rewriteReload the config
sudo systemctl reload apache2Test in the browser: http://localhost/
Navigate to src/config/
Create a copy of the file config.example.php and name it config.php
cp config.example.php config.phpOpen config.php and change the variables as needed:
<?php
return [
'host' => 'localhost',
'port' => 3306,
'db' => 'study_share',
'user' => 'studyshare', // the username you set at step 4
'pass' => 'yourpassword', // the password you set at step 4
'charset' => 'utf8mb4',
];TODO
See this guide for setting up html/css/php intellisense and hot reload with vscode