8.7 KiB
| slug | title | authors | tags | |||
|---|---|---|---|---|---|---|
| CentOS 6 Web Server Setup LAMP Stack Installation Guide | CentOS 6 Web Server Setup LAMP Stack Installation Guide |
|
|
import CodeBlock from '@site/src/components/CodeBloack';
- Linux: It's like the foundation of your website. CentOS is already there, serving as the base.
- Apache: Think of Apache as a traffic cop for your website. It directs visitors to the right places.
- MySQL: MySQL is a storage place for your website's information. It keeps everything organized.
- PHP: PHP is a language that helps your website do things – like showing dynamic content.
<CodeBlock code={sudo yum install httpd} />
<CodeBlock code={sudo service httpd start} />
<CodeBlock code={ifconfig eth0 | grep inet | awk '{ print $2 }'} />
To get MySQL, go to the terminal and type in these special commands:
<CodeBlock code={sudo yum install mysql-server sudo service mysqld start} />
<CodeBlock code={sudo /usr/bin/mysql_secure_installation} />
<CodeBlock code={Enter current password for root (enter for none): OK, successfully used password, moving on...} />
CentOS makes it easy by asking you simple 'Yes' or 'No' questions.
Just say 'Yes' to everything it asks. When you're done, MySQL will finish up and put all the new stuff in place
<CodeBlock code={By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL!} />
<CodeBlock code={sudo yum install php php-mysql} />
<CodeBlock code={Exploring PHP Tools: Libraries and Modules} />
<CodeBlock code={yum search php-} />
<CodeBlock code={php-bcmath.x86_64 : A module for PHP applications for using the bcmath library php-cli.x86_64 : Command-line interface for PHP php-common.x86_64 : Common files for PHP php-dba.x86_64 : A database abstraction layer module for PHP applications php-devel.x86_64 : Files needed for building PHP extensions php-embedded.x86_64 : PHP library for embedding in applications php-enchant.x86_64 : Human Language and Character Encoding Support php-gd.x86_64 : A module for PHP applications for using the gd graphics library php-imap.x86_64 : A module for PHP applications that use IMAP} />
<CodeBlock code={yum info name of the module} />
<CodeBlock code={sudo yum install name of the module} />
Great job! Your online space now has the complete LAMP stack!
To make things even easier, let's set it up so that everything starts running automatically when your server starts (PHP will start as soon as Apache does):
<CodeBlock code={sudo chkconfig httpd on sudo chkconfig mysqld on} />
<CodeBlock code={sudo nano /var/www/html/info.php} />
<CodeBlock code={<?php phpinfo(); ?>} />
Now, let's make sure all the changes apply to your online space. Restart Apache on your server:
<CodeBlock code={sudo service httpd restart} />