On Deploy a PHP development environment
First of all, install Ubuntu 20.04 LTS.
For convenience, we will install
fish
in replace of the preinstalled default shell (In classical Ubuntu, it should bebash
).
As a person without prior development experience, I find bash
very hard to use since I cannot autocomplete, inter alia, file name and command, I installed fish for better dev experience.
Installation on Fish
sudo apt install fish
Then run chsh -s /usr/bin/fish
which will change the default shell to fish
shell we just installed.
Then we commence the actual process of environment buildup, i.e. installation of LAMP.
Installation on Apache
Like always, update the repository list usingsudo apt update
After prompted to enter user passwd, I can be exempted from entering passwd within this session.
Then, start to install Apachesudo apt install apache2
After installation, I chose to disable ufw
firewall for convenience.
Run sudo ufw disable
. After that, the terminal should appear a line prompt you that the firewall has been disabled.
Then, we can start to test on whether our server has been started. First of all, start Apache by commandingstart apache2
in Windows Powershell or sudo service apache2 start
.
After Apache being successfully started, open http://localhost/index.html
to test if it works.
A page should be displayed with the title of
Apache2 Debian Default Page
If you can see that, congratulation! Your Apache server has been successfully deployed.
Since we finished the first step, let’s proceed to our next step, installing mySQL.
Installation of MySQL
MySQL is a database software provide front-end service and PHP information to process.
Type sudo apt install mysql-server
in the terminal, after completion, type sudo mysql_secure_installation
to eliminate unsecure factors.
After installation, use sudo mysql
to test if it has been install correctly.
Oops, in this time, the terminal throwed me an error with
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)
After checking with StackOverflow, I opened the config file usingsudo nano /etc/mysql/my.cnf
I found out that I have installed MariaDB before, so I have to uninstall the MariaDB.
Using Aptitude to locate the package name of MariaDB, command by sudo aptitude
.
And, uninstall MariaDB by sudo apt remove mariadb-common
.
Let’s try again.
The issue consists.
Let’s reinstall.
The issue consists. (Sigh)
After two hours of Googling and trying, I decided to give up and install mariadb.
Installation of PHP
Finally, we come to the point where the installation of PHP takes place.
Proceed sudo apt install php libapache2-mod-php
to install PHP.
After that, proceed sudo vim /etc/apache2/mods-enabled/dir.conf
to open the configuration file of Apache server.
Modify the priority of index.php second to DirectoryIndex, save and restart the Apache Server by
sudo systemctl restart apache2
and access
http://localhost
.
If you see the page of PHP status, congrats again! You’ve finished all necessary steps to avail a dev environment.