How to input info into the form to install wordpress automatically?

Posted October 27, 2014 3.3k views

I have write an onekey installation script in bash,it is tested .

echo mysql-server mysql-server/rootpassword password $mysqlword | debconf-set-selections
echo mysql-server mysql-server/root
password_again password $mysqlword | debconf-set-selections
apt-get -q -y install apache2 mysql-server php5 php-pear php5-mysql php5-gd

mysql -u root -p$mysqlword -e"CREATE DATABASE wpdatabase;“
mysql -u root -p$mysqlword -e"use wpdatabase;”

mysql -u root -p$mysqlword -e"CREATE USER wpuser@localhost;“

mysql -u root -p$mysqlword -e"SET PASSWORD FOR wpuser@localhost= PASSWORD(‘dbpassword’);”
mysql -u root -p$mysqlword -e"GRANT ALL PRIVILEGES ON wpdatabase.* TO wpuser@localhost IDENTIFIED BY 'dbpassword’;“
mysql -u root -p$mysqlword -e"FLUSH PRIVILEGES;”

tar -xzvf latest.tar.gz
cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php

d1=“define('DBNAME’, 'databasenamehere’);”
USER’, 'usernamehere’);”
PASSWORD’, 'passwordhere’);”
NAME’, 'wpdatabase’);”
s2=“define('DBUSER’, 'wpuser’);”
PASSWORD’, 'dbpassword’);”
sed -i “s/$d1/$s1/g” $file
sed -i “s/$d2/$s2/g” $file
sed -i “s/$d3/$s3/g” $file

mv /root/wordpress/* /var/www/

Now when i input my serverip, there is the wordpress installatioin web.
alt text
The last step remain,you can input info by hand,how can i do that automatically with bash? or with python?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
3 answers

You seem to be trying to re-invent the wheel.
With digital ocean, you can deploy a droplet with WordPress pre-installed.
When creating your new droplet, just select application tab in the image section and choose the wordpress option.

Hope this helps.

The pre-installed wordpress is 14.04, it means that pre-installed wordpress can only
build on ubunt os ,how about debian?
I find that you can select just one method in image when to create droplet ,if you select bebian os ,no pre-installed wordpress in it ; if you select pre-installed wordpress ,no debian.
it is necessary for me to create the wheel to meet my need : debian + wordpress automatically one-click bash script.
I DO NOT like ubuntu ,debian is more stable than ubuntu.

  • Unfortunately we do not provide a 1-click installation image of Wordpress on Debian. However, you can spin up a Debian droplet, install Wordpress (How To Install WordPress on Debian 7 | DigitalOcean) on it, and take a snapshot of it. Then, whenever you want to spin up a new Wordpress on Debian droplet, you can create it off of the image and have Wordpress pre-installed. Keep in mind that you will have to change MySQL’s passwords so that it’s not the same for all droplets (which is bad security-wise).

    by Adam LaGreca
    WordPress is a free and open source blogging tool used by more than 18.9% of the top 10 million websites [as of August 2013]. This makes WordPress the most popular blogging system in use on the Web at more than 60 million websites. Setting up WordPress on a DigitalOcean Droplet with Debian is one of the fastest and simplest ways to host your own website.

You could try and detect changes made by the installation process and use those to automate.

There might be changes in the file system that you can catch if you create a repository and commit the fresh WordPress before you install it. After installation you can check the difference.

It will definitely make changes in the database that you can catch almost the same way. Dump the database before installation and commit it into a repository. Dump it after installation and check the difference.