# RFC: Wordpress install script



## balanga (Jan 27, 2018)

I've attempted to put together a fully automated script for installing Wordpress along with FAMP

Be warned that there is no attempt at  securing mysql and no handling of errors.


```
pkg install -y apache24 mysql56-server mod_php71  php71-mysqli
sysrc apache24_enable=YES
sysrc mysql_enable=YES

cat <<EOF >/usr/local/etc/apache24/Includes/php.conf
<IfModule dir_module>
    DirectoryIndex index.php index.html

    <FilesMatch "\.php$">
        SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
    </FilesMatch>
</IfModule>
EOF
echo '<?php phpinfo(); ?>' > /usr/local/www/apache24/data/info.php

service apache24 start
service mysql-server start

#mysql_secure_installation
#mysql -u root -ppassword <<EOF
mysql -u root <<EOF
CREATE DATABASE wordpress;
CREATE USER wp_user@localhost IDENTIFIED BY 'wp_pass';
GRANT ALL PRIVILEGES ON wordpress.* TO wp_user@localhost;
FLUSH PRIVILEGES;
exit
EOF
fetch https://wordpress.org/latest.tar.gz
tar zxf latest.tar.gz -C /usr/local/www/apache24/data
pkg install -y php71-xml php71-hash php71-gd php71-curl php71-tokenizer php71-zlib php71-zip
cd /usr/local/www/apache24/data/wordpress
sed -e 's/database_name_here/wordpress/' -e 's/username_here/wp_user/' -e 's/password_here/wp_pass/'
chown -R www:www /usr/local/www/apache24/data/wordpress/*
service apache24 restart
#
# If it runs successfully point your browser at the following - after adjusting the IP address.
#
#http://192.168.1.15/
#http://192.168.1.15/info.php
#http://192.168.1.15/wordpress
```

I did try with mysql57-server but did not succeed.
The apache restart might not be necessary, but got an initial HTTP 500 on first attempt at running the install script

Any comments would be appreciated.


----------



## Dmitry D (Dec 25, 2018)

Thank you.
Пreat job. I take it as a basis.


----------



## SirDice (Dec 28, 2018)

What's wrong with simply using www/wordpress?


----------

