sudo apt update -y && \ # Update dependencies
sudo apt upgrade -y && \
sudo apt install -y php7.4 php7.4-curl php7.4-gd php7.4-json php7.4-mbstring php7.4-xml libapache2-mod-php7.4 php7.4-mysql apache2 apache2-bin apache2-data apache2-utils mysql-server phpmyadmin && \ # Install dependencies
sudo mysql_secure_installation
The password for phpmyadmin can be phpmyadmin
, but chose one for yourself.
You will be asked for a MySQL Root Password, choose your own, I chose: kjdndnakdnejuef
. Leave the anonymus users on the DataBase (DB), only allow root access from localhost, remove the test DB,
To restart Apache and MySQL services, type:
sudo systemctl restart apache2
sudo systemctl restart mysql
To start Apache and MySQL services, type:
sudo systemctl start apache2
sudo systemctl start mysql
To stop Apache and MySQL services, type:
sudo systemctl stop apache2
sudo systemctl stop mysql
sudo rm /var/www/html/* && \ # Clear public folder
sudo nano /var/www/html/index.php
and paste
<?php
foreach (scandir('.') as $file)
echo "<a href=\"" . $file . "\">" . $file . "</a><br/>";
phpinfo();
?>
Then go to http://localhost/info.php to see the php info page.
- Download Wordpress
- Unpack the
.zip
- Move the contained
wordpress
folder with the contents to the location you want and rename it to<your_folder_name>
- I chose
homepage
, which will be used from now on. - In
sudo nano /etc/apache2/sites-available/<your_folder_name>.conf
paste:<Directory absolute/path/2/<your_folder_name>> Options FollowSymLinks AllowOverride Limit Options FileInfo All DirectoryIndex index.php Order allow,deny Allow from all Require all granted </Directory> <Directory absolute/path/2/<your_folder_name>/wp-content> Options FollowSymLinks AllowOverride All Order allow,deny Allow from all Require all granted </Directory>
- Run:
sudo a2ensite <your_folder_name> && \ sudo systemctl reload apache2 && \ sudo systemctl restart apache2 && \ sudo mysql -u root -p<your_previously_set_pwd> -e "CREATE DATABASE <databaseName>;"
- Create another wordpress user than root and grant him all priviliges:
CREATE USER <userName>@localhost IDENTIFIED BY '<user_password>'; GRANT ALL ON <databaseName>.* TO <userName>@localhost; FLUSH PRIVILEGES;
- Place in
your/path2/homepage/wp-config.php
this content:<?php /** The base configurations of the WordPress. */ $files = array( //any constant which is defined in this files, wont be overwritten by the default wp-config.php '/wp-config_staging.php', '/wp-config_local.php' ); foreach($files as $file) { if (file_exists(__DIR__ . $file)) { include_once __DIR__ . $file; } } $baseURL = $_SERVER['REMOTE_ADDR']=='127.0.0.1' || $_SERVER['REMOTE_ADDR']=='::1' ? 'http://localhost/<your_project_name>' : $_SERVER['REMOTE_ADDR']; $configs = array( // Production config // DB 'DB_HOST' => $_SERVER['REMOTE_ADDR'] == '127.0.0.1' || $_SERVER['REMOTE_ADDR'] == '::1' ? '127.0.0.1:3307' : 'localhost', 'DB_NAME' => '<your_db_name>', 'DB_USER' => '<your_wp_user_name>', 'DB_PASSWORD' => '<your_wp_password>', 'DB_CHARSET' => 'utf8', 'DB_COLLATE' => '', // WP 'FS_METHOD' =>'direct', 'WP_SITEURL' => $baseURL, 'WP_HOME' => $baseURL, 'WP_DEBUG' => false, 'WP_DEBUG_LOG', false, 'WP_DEBUG_DISPLAY', false, 'SCRIPT_DEBUG', false, 'ABSPATH' => dirname(__FILE__) . '/', 'AUTH_KEY' => '<apply_from_old_wp-config.php>', 'SECURE_AUTH_KEY' => '<apply_from_old_wp-config.php>', 'LOGGED_IN_KEY' => '<apply_from_old_wp-config.php>', 'NONCE_KEY' => '<apply_from_old_wp-config.php>', 'AUTH_SALT' => '<apply_from_old_wp-config.php>', 'SECURE_AUTH_SALT' => '<apply_from_old_wp-config.php>', 'LOGGED_IN_SALT' => '<apply_from_old_wp-config.php>', 'NONCE_SALT' => '<apply_from_old_wp-config.php>', ); foreach($configs as $key => $value) { if (!defined($key)) { define($key, $value); } } $table_prefix = 'wp_'; require_once(ABSPATH . 'wp-settings.php');
- (Re)Start best both services, apache2 + mysql with:
sudo systemctl start apache2 mysql
- Create in the
/var/www/html
directory a symlink to yourhomepage
wordpress project directory with:sudo ln -s /home/your/project/dir/homepage /var/www/html/homepage # 1. is source dir, 2. is target dir
- Go to http://localhost/homepage and complete the wordpress setup
- Now develop!
- Watch the apache2 error logs with
tail -F /var/log/apache2/error.log
- In the
/etc/apache2/apache2.conf
, inform yourself about security risks beforehand, but make changes to:<Directory /var/www/html/<your_wp_folder_name>> Options FollowSymLinks AllowOverride All DirectoryIndex index.php Order allow,deny Allow from all Require all granted </Directory> <Directory /var/www/html/<your_wp_folder_name>/wp-content> Options FollowSymLinks AllowOverride All Order allow,deny Allow from all Require all granted </Directory>
- Run:
sudo a2enmod rewrite &&\ sudo service apache2 restart
- You may need to execute:
sudo find wp-content/ -type d -exec chmod g+rx {} + sudo find wp-content/ -type f -exec chmod g+r {} +
To enable apache2 service on boot up run
sudo systemctl enable apache2
To disable apache2 service on boot up run
sudo systemctl disable apache2
To check whether the service is currently configured to start on the next boot up
systemctl is-enabled apache2
To see the service status
systemctl status service-name
To start the service
sudo systemctl start service-name
To restart the service
systemctl restart apache2
To stop the service
sudo systemctl stop service-name