Update: ChromeOS Beta Linux is in essence a Debian linux distribution, as is Ubuntu. I just followed the same instructions below and successfully installed wordpress onto my Ubuntu desktop machine. The only difference is that the IP Address 100.* is not necessary, just use localhost!
Ok, so most folks are happy enough to pay for windows or a Mac, I guess I am just tight, but I like free. If I could buy a decent linux laptop at a reasonable price, maybe I'd go that way, but they are so hard to find - So I use ChromeOS, and you know what? It just works... Most of the time... Anyways, I'm doing a bit of Wordpress development and thought I'd spend a morning to see if I can get Wordpress running locally on a ChromeOS device.
Of course, you cannot install stuff on "Chrome", so you'll need to start by enabling the linux beta on chrome.
Thanks to these lads for getting me off to a flying start with the wordpress install. Basically open up a terminal window and:
sudo apt update
sudo apt install apache2 php
sudo /etc/init.d/apache2 start
ip a
ip a
and in the midst of the blur of text, I can see there is an IP address in there "inet 100.115.92.198/28 brd 100.115.92.207 scope global eth0"sudo apt install mariadb-server
sudo /etc/init.d/mysql start
sudo service mysqld status
(seems to have started up correctly)sudo mysql_secure_installation
sudo systemctl start mariadb.service apache2.service
)sudo mysql --version
sudo mysql -u root
(Connects to the MariaDB Shell, following commands entered at the MariaDB [(none)]> prompt!)create database wordpress
;use wordpress
(Prompt changes to MariaDB [(wordpress)]>)GRANT ALL PRIVILEGES ON wordpress.* TO wordpress@localhost IDENTIFIED BY 'mypassword';
(Creates a user called wordpress)flush privileges;
quit
NOTE: I made a mess of the DB and needed to start over, so to remove the database I did the following, then started from the top again
sudo apt list --installed | grep maria
(to see what is installed for mariadb - loads!)sudo apt purge mariadb-server
(delete the installation so I can start again)sudo rm -rf /var/lib/mysql
(forcibly get rid of any of those files I might have messed up)sudo apt autoremove
(to cleanup additional packages that where added to support mariadb)sudo apt list --installed | grep maria
(just to make sure it is gone)sudo apt install php libapache2-mod-php php-mysql
sudo /etc/init.d/apache2 restart
So far so good, now all I need to do is install wordpress in the simplest possible fashion. Thanks to wordpress for these instructions. I'm not quite keen enough to take the latest nightly build, so I download the latest stable version (5.4.1) from here. When downloaded I click on "Show in Folder", and then move the file from Downloads folder to "Linux Files". I type ls -ltr
and I can see the wordpress zip file there in my home directory, good oh!
cd /var/www/html/
sudo unzip ~/wordpress-5.4.1.zip
Great, so now I point my browser to "http://100.115.92.198/wordpress/" click "Let's Go", enter database name 'wordpress', username 'wordpress', password 'mypassword', database host 'localhost' and table prefix 'wp_' and I get an error, unable to create wp-config.php... I presume this is because the sensible default for the user running apache is not allowed to write files that will be published on your website... But this is a development system, on a chromebook, that will never be connected to the internet, so I do something you would never, never EVER do on a production server...
sudo chmod -R 777 /var/www/html
(Please note if you are executing this on a production internet facing server, please now quit your job)Alright Sparky! So again I point the browser to http://100.115.92.198/wordpress/ and fill in the connection details, now I can proceed with the installation, fill in a few more blanks and you are done!
Well one last thing, you probably want to open the file /var/www/html/wordpress/wp-config.php
and in there add the code
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*/
define('WP_DEBUG', true);
Ok, so have to admit, that has taken me most of the morning to get working, but hopefully with the notes above you can get yours to work a lot more quickly than I did.
The wordpress user interface allows installing themes and plugins, but to do so requires your server to have an FTP service running. To setup an FTP server you can:-
sudo apt-get install vsftpd
(basic installation of FTP)sudo apt-get install gedit
(to install a text editor if you do not already have one)sudo cp /etc/vsftpd.conf /etc/vsftpd.conf_orig
(Make a backup copy of the original configuration file)sudo gedit /etc/vsftpd.conf
(or use your favorite text editor)local_enable=YES
the end of the file and savesudo /etc/init.d/vsftpd restart
(to restart FTP)sudo chown -R www-data /var/www/html
(probably not as bad as the chown 777 above, but definitely not something for the live server. We are now making the server the user is running as own all of the files and able to do anything with them, ideally that user should have readonly access to files in a production environment, but of course this is DEV only)Hey presto - I can now install themes & plugins!
Whilst I got going fine, I started getting various 404 errors, API didn;t work, and some other funcky stuff. Well thanks to this post, I was able to figure out I needed to update my apache.conf file, (/etc/apache2/apache2.conf) to change the word "none" to "FileInfo", otherwise the .htaccess entries that wordpress needs are ignored by apache. I also learned in the process that in fact wordpress can dynamically change /var/www/html/.htaccess file, so the user running apache needs access to the file to allow updating the permalink settings.
Before Change
Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride none
Require all granted
</Directory>
After Change
Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride FileInfo
Require all granted
</Directory>