This is the first part in my series of step by step guides to turn Fedora into the ultimate web development platform. I am going to assume that you have Fedora installed already, or are comfortable installing it yourself. Once you are up and running, just run the terminal application and follow along to set up your perfect development environment. In this guide we will discover:I hope you have found this guide helpful. If you would like to employ me for any upcoming projects, please do not hesitate to get in contact. Please leave your feedback on this guide below and I will be sure to take it into account for future updates.
- How to set the host name, and why it's important.
- Which repositories to install and how to do it.
- How to setup subpixel rendering to improve font appearance.
- How to setup and configure your LAMP environment for localhost development.
Set the host nameIt’s a good idea to give your computer a name so it can identify itself to other computers on the network. This will also to make it easy for you to identify your own computer if you are logged in remotely to multiple systems. When you are using the terminal it will show:
[username@hostname ~]$before every command you type. If you have multiple windows open all showing you logged in from @localhost (the default) it will soon become very confusing! So use this command:
hostnamectl set-hostname yourhostname
Enable extra repositoriesFedora only installs 100% free and open source software from its own official built in repository. It is very strict, sometimes too strict in it’s FOSS definition. We need more software than comes out of the box, and more than is available from the official repo. The best way to get the software we want is add some extra 3rd party repositories. That way we get the following advantages over just downloading the software from the official website:
- Time saved looking for updates, going to the site, and downloading them.
- Automatic updates whenever we update our system.
- Enhanced security, checksums are used when downloading.
sudo su -c 'dnf -y install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm' sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc sudo sh -c 'echo -e "\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
Update everythingBefore we go further, let’s update the entire system to the latest versions of all packages. This is best practice.
sudo dnf -y --refresh upgrade
Allow virtual machines that use fusefs to intall properly with SELinuxThis is just a weird little one I threw in, as it could save you hours of wasted time if you use virtual machines. If you don’t enter this command, then you will enter a over zealous security paranoia hell hole trying to run a virtual machine. Just enter this and thank me later.
sudo setsebool -P virt_use_fusefs 1
Install subpixel rendering and change desktop settingsThis has a long story to go with it, a tale of patents and Microsoft tom foolery. You can go and read that all elsewhere if you like. The short version is if your monitor is 1080p or less you will probably benefit from enabling subpixel rendering. I have debated with people who swear they can’t see the difference, I think they must be half blind. Without subpixel rendering <=1080p text has a slight uneven spidery appearance. With, it looks amazing. If you are lucky enough to have a really high resolution display then you totally don’t want this, it will probably make things look worse for you. Ubutu has it by default, so do some other Linux distros. Fedora is 100% pure FOSS, they won’t even touch a potential patent infringement with a bargepole.
sudo dnf -y install freetype-freeworld gsettings set org.gnome.settings-daemon.plugins.xsettings hinting slight gsettings set org.gnome.settings-daemon.plugins.xsettings antialiasing rgba echo "Xft.lcdfilter: lcddefault" >>"$HOME/.Xresources"
Increase the amount of inotify watchers so live-server works with > 8192 files in a directoryIn part 2 of this guide I will suggest you use the awesome live-server software so you can edit HTML/CSS/JS in real time, if you don't intend to follow my advice then you can safely ignore this tweak. I don’t know if this is a hardware thing, but on my system I run into problems using live-server if I don’t make this little change:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf sudo sysctl -p
Setting up the LAMP for localhost DevelopmentThis is my way of doing things. I am going to do a bit of a ‘hack’ and run Apache as the user, this saves a lot of bother setting permissions. I think it is fine for a development machine that is not facing out to the internet, but the hyper security concious are probably going to get triggered. First we will make a folder in our home directory to store all our development sites:
mkdir ~/sitesMake a symbolic link from the Apache web directory to your sites folder:
sudo ln -s ~/sites /var/www/htmlTell SELinux that these files/directories are allowed to be modified by Apache:
chcon -R unconfined_u:object_r:httpd_sys_rw_content_t:s0 ~/sitesChange the "User apache" string in the config file to "User (the username of the current user)". For a development machine, it's more convenient to run Apache as the current user to simplify permissions problems:
sudo sed -i "s/User apache/User $USERNAME/g" /etc/httpd/conf/httpd.confYou can turn Apache and MySQL server on and off at the same time with this little script I created:
if pgrep -x "httpd" > /dev/null then read -rp "Apache is running, would you like to stop Apache and MariaDB? (y/n) " -n 1 run echo if [ "$run" == n ];then exit fi echo "Stopping Apache and MariaDB..." sudo systemctl stop httpd.service sudo systemctl stop mariadb.service else echo "Starting Apache and MariaDB..." sudo systemctl start httpd.service sudo systemctl start mariadb.service fiIf Apache is running it asks if you would like to stop Apache and MySQL running, if it’s not it runs both. This works out great if you only ever run them both at once, like myself. You can finish off by going through the MySQL security setup:
sudo systemctl start mariadb.service sudo mysql_secure_installationNow you have everything setup and ready to go, let's install all the software we will need in part two, Linux Web Development Tools.