De LAMP-stack installeren
De LAMP-stack (Linux, Apache, MySQL en PHP) is een groep opensourcesoftware waarmee je websites met databases draaiend krijgt. Het Linux-deel valt buiten dit document.
Log met SSH en rootrechten in op je Linux-server en volg de onderstaande instructies.
- Installeer de LAMP-stack — yum groupinstall “Web Server” “PHP Support” “MySQL Database server” “MySQL Database client”
- Voeg PHP-MySQL-ondersteuning toe — yum install php-mysql
- Start Apache — service httpd start systemctl start httpd
- Laat Apache automatisch starten bij het opstarten — chkconfig httpd on systemctl enable httpd
- Start MySQL — service mysqld start systemctl start mysqld
- Laat MySQL automatisch starten bij het opstarten — chkconfig mysqld on systemctl enable mysqld
- Een wachtwoord instellen voor de MySQL-rootgebruiker. — mysqladmin -u root password ‘new-password’
- Of draai de wizard om een MySQL-rootwachtwoord in te stellen. Die leidt je door de stappen. Antwoord overal met Ja. — /usr/bin/mysql_secure_installation
Een database voor WordPress aanmaken
- Open de MySQL-shell — mysql -uroot -pYourPassword of mysql –user=root –password=YourPassword
- Maak een database aan — create database wordpressdb;
- Stel rechten in — grant all privileges on wordpressdb.* to ‘wordpressdb’@’localhost’ identified by ‘YOURNEWPASS’;
- Activeer de rechten — flush privileges;
- Verlaat de MySQL-shell — exit;
WordPress installeren
- Ga naar de map /root — cd /root
- Download WordPress — wget http://wordpress.org/latest.tar.gz is wget niet beschikbaar, installeer het dan met yum install wget
- Pak WordPress uit — tar -xvzf /root/latest.tar.gz -C /target/directory
- Synchroniseer de uitgepakte bestanden naar je DocumentRoot — rsync -avz wordpress/ /var/www/ is rsync niet beschikbaar, installeer het dan met yum install rsync
- Verwijder de WordPress-bronbestanden — rm latest.tar.gz
rm -rf wordpress/ - Maak het WordPress-configuratiebestand door het voorbeeldbestand te kopiëren — cp /var/www/wp-config-sample.php /var/www/wp-config.php
- Zet de databasegegevens in /var/www/wp-config.php — sed -i ‘s/database_name_here/your-db/’ /var/www/wp-config.php sed -i ‘s/username_here/your-username/’ /var/www/wp-config.php sed -i ‘s/password_here/your-password/’ /var/www/wp-config.php sed -i ‘s/localhost/your-dbserver/’ /var/www/wp-config.php
Beveilig je site met de juiste rechten
- Maak de Apache-gebruiker eigenaar van je DocumentRoot — chown -R apache:apache /var/www/html/yoursite
- Pas de rechten aan — chmod -R 400 /var/www/html/yoursite chmod -R a+X /var/www/html/yoursite
WordPress heeft schrijfrechten op de map /wp-content nodig om plugins, thema’s of updates te kunnen installeren.
- Geef WordPress schrijfrechten — chmod -R 775 /var/www/html/yoursite/wp-content