This term is actually an acronym which represents the Linux operating system, with the Apache web server. Ubuntu will fulfill our first requirement: a Linux operating system. Prerequisites Before you begin with this guide, you should have a separate, non-root user account with sudo privileges set up on your server. You can learn how to do this by completing steps in the initial server setup for Ubuntu
|Published (Last):||18 December 2009|
|PDF File Size:||2.39 Mb|
|ePub File Size:||3.5 Mb|
|Price:||Free* [*Free Regsitration Required]|
This term is actually an acronym which represents the Linux operating system, with the Apache web server. Ubuntu will fulfill our first requirement: a Linux operating system. Prerequisites Before you begin with this guide, you should have a separate, non-root user account with sudo privileges set up on your server.
You can learn how to do this by completing steps in the initial server setup for Ubuntu Step 1: Install Apache and Allow in Firewall The Apache web server is among the most popular web servers in the world. A package manager allows us to install most software pain-free from a repository maintained by Ubuntu. You can learn more about how to use apt here. For our purposes, we can get started by typing these commands: sudo apt-get update sudo apt-get install apache2 Since we are using a sudo command, these operations get executed with root privileges.
Press Y and hit Enter to continue, and the installation will proceed. Next, check for syntax errors by typing: sudo apache2ctl configtest Since we added the global ServerName directive, all you should see is: Output Restart Apache to implement your changes: sudo systemctl restart apache2 You can now begin adjusting the firewall. It should look something like this: If you see this page, then your web server is now correctly installed and accessible through your firewall.
Usually, this is the address you use to connect to your server through SSH. From the command line, you can find this a few ways. They are all correct addresses, but your computer may only be able to use one of them, so feel free to try each one. An alternative method is to use the curl utility to contact an outside party to tell you how it sees your server. MySQL is a database management system. Basically, it will organize and provide access to databases where our site can store information.
Again, we can use apt to acquire and install our software. This is because we recently ran it in the commands above to install Apache.
The package index on our computer should already be up-to-date. Enter Y to continue. This is an administrative account in MySQL that has increased privileges. Think of it as being similar to the root account for the server itself the one you are configuring now is a MySQL-specific account, however. Make sure this is a strong, unique password, and do not leave it blank.
When the installation is complete, we want to run a simple security script that will remove some dangerous defaults and lock down access to our database system a little bit. Warning: Enabling this feature is something of a judgment call. This will cause issues if you use a weak password in conjunction with software which automatically configures MySQL user credentials, such as the Ubuntu packages for phpMyAdmin.
It is safe to leave validation disabled, but you should always use strong, unique passwords for database credentials. Answer y for yes, or anything else to continue without enabling. It checks the strength of password and allows the users to set only those passwords which are secure enough.
Keep in mind that if you enter 2, for the strongest level, you will receive errors when attempting to set any password which does not contain numbers, upper and lowercase letters, and special characters, or which is based on common dictionary words. Estimated strength of the password: Change the password for root? Press y Y for Yes, any other key for No : n For the rest of the questions, you should press Y and hit the Enter key at each prompt.
This will remove some anonymous users and the test database, disable remote root logins, and load these new rules so that MySQL immediately respects the changes we have made. At this point, your database system is now set up and we can move on. It can run scripts, connect to our MySQL databases to get information, and hand the processed content over to our web server to display. We can once again leverage the apt system to install our components. Currently, if a user requests a directory from the server, Apache will first look for a file called index.
To do this, type this command to open the dir. After this, we need to restart the Apache web server in order for our changes to be recognized. To see the available options for PHP modules and libraries, you can pipe the results of apt-cache search into less, a pager which lets you scroll through the output of other commands: apt-cache search php- less Use the arrow keys to scroll up and down, and q to quit.
The results are all optional components that you can install. If we decided that php-cli is something that we need, we could type: sudo apt-get install php-cli If you want to install more than one module, you can do that by listing each one, separated by a space, following the apt-get install command, like this: sudo apt-get install package1 package At this point, your LAMP stack is installed and configured.
We should still test out our PHP though. We will call this script info. In Ubuntu We want to put the following text, which is valid PHP code, inside the file: info. Now we can test whether our web server can correctly display content generated by a PHP script. To try this out, we just have to visit this page in our web browser.
It is useful for debugging and to ensure that your settings are being applied correctly. If this was successful, then your PHP is working as expected. You probably want to remove this file after this test because it could actually give information about your server to unauthorized users. As an immediate next step, you should ensure that connections to your web server are secured, by serving them via HTTPS.
Some other popular options are: Install Wordpress the most popular content management system on the internet. Learn how to use SFTP to transfer files to and from your server.
Note: We will be updating the links above to our
Tutorial Belajar PHP Dasar Untuk Pemula
More modes are coming soon. Error handling. And this is all you need for the basic error reporting. Catch an exception only if you have a handling scenario other than just reporting it. The only exception pun not intended is the creation of the PDO instance, which in case of error might reveal the connection credentials that would be the part of the stack trace. In order to hide them, we can wrap the connection code into a try.. A long rant on the matter: Despite a widespread delusion, you should never catch errors to report them.
PHP : Le tutoriel pour grands débutants pressés