LAMP stands for Linux Apache Mysql and PHP stack which is the base to run web server and websites based on PHP. I am going to explain how you can set up LAMP on any ubuntu server or ubuntu machine step by step. Like and Share to spread this to people who needs it.
Hello Intelligent people out there, greet from Dheeraj.
If you are a Web developer, or system administrator, you must be having idea what LAMP is, and just like LAMP there are WAMP stands for Windows Apache Mysql and PHP and XAMPP where X stands for Cross platform.
If you are on linux machine and working with command lines only, let’s get to know how you can setup LAMP within 10 minute at max, depending on your internet speed for sure.
First thing first
Make sure all your packages are updated on server.
To make sure this, execute this command
|
This should install updates if available for your system. Once done, let’s get started.
-
Install LAMP Packages
First of all let’s execute command to install all of the required component to install PHP stack along with Apache and mysql
Execute following command into the putty or your terminal window.
|
This will ask for some hard drive space to be used and installation should begin.
During installation of mysql in between, you will be asked to provide default mysql username and password for your server.
Provide those details, this will be used to login to phpmyadmin and connecting database as well.
Once installation is finished, restart apache2 to save and update the settings. For the same reason, execute following command.
|
Update: If your MySQL installation didn’t ask for the password at the time of installation, please go through following additional steps to set a password
sudo mysqld_safe --skip-grant-tables&
sudo mysql --user=root mysql
mysql> update user set authentication_string=PASSWORD('new-password') where user='root';
flush privileges;
quit
sudo service mysql restart
sudo mysql -u root -p
exit
Followed by following command and instruction for the same.
sudo mysql_secure_installation
2. Check and verify mysql installation
This is simple, you can check mysql installation by following command
|
Followed by password, if you are able to login, type exit command to exit and this makes sure your mysql is been installed as well.
3. Installing phpMyAdmin
Now we’ll install phpmyadmin, to make sure you knows this, your Apache default directory is
/var/www/html
You can check apache installation by visiting IP of your server or any DNS that is associated with it. This will show apache default page located at /var/www/html/
Now to install phpmyadmin, execute following command.
|
This will install phpmyadmin and once done, you have to make short link or say shortcut of this to your root directory/phpmyadmin folder so that you can access via web/http
To do so, execute following command.
|
This will create a shortcut and you can access your phpmyadmin using /phpmyadmin.
You can also rename phpmyadmin folder to anything you want.
To check this, open your root directory/phpmyadmin or folder name you have specified, this will open phpmyadmin and you can login by entering username and password of mysql as stated earlier.
4. Finalizing setup and enabling htaccess
You may be asked to install mbstring or missing mbstring when running phpmyadmin, to fix that thing, simply execute following command to install it.
|
This will enable mbstring, and to make this setting effective, restart apache services as we have done earlier by executing command
|
Now we’ll enable htaccess by changing configuration setting of apache.
First execute following command to enable rewrite
|
Now edit file using your favorite editor. For my case i’ll use vim to edit configuration file by passing following command.
|
Now look for section where you’ll find
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Edit this section and change AllowOverride None to AllowOverride all
Save and quit editor.
Now again restart apache2.
One more thing, in case you are on AWS and installing LAMP on AWS after creating your own vpc, your default user will be ubuntu and owner of /var/www/html is root and you might not have write permission on this directory.
In that case, you can execute following command to change the owner of html folder to current user i.e. ubuntu.
By executing following command.
|
5. Setting up filezilla connection to your ubuntu server using keyfile.
This is easy too.
-
Open filezilla
-
Navigate to File > Sitemanager
-
Click on New site button.
-
Provide details as follows:
-
Hostname : your server’s IP address
-
Port (leave blank)
-
Connection type : sftp
-
Username : ubuntu
-
Keyfile : browse and select .pem file for AWS ec2 server which you have created during server launch.
-
Click on connect.
Upon connection, you will be able to connect to your server anytime. Navigate to /var/www/html to upload your php project and directory structure will be started root from this directory only.
Hope these points helped you to setting up server and connecting your server specially on AWS.
If you have any doubt, any bug, or question, please leave comment below.
Share with your friends, group and on social media for sure.
Have great time.
http://Inteligentcomp.com