Lamp is the abbreviation of linux,apache,mysql,php. This tutorial is mainly about installing an Apache Web server with PHP and MySQL support in CentOS.
Add external sources to keep MySQL and php up to date
Because the system basic source of MySQL and PHP program is older, so we add a newer external source.
- # RPM--import Http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
- # Vi/etc/yum.repos.d/centos-base.repo
Add the following information at the bottom
- [Utterramblings]
- Name=jason ' s utter ramblings Repo
- baseurl=http://www.jasonlitka.com/media/el$releasever/$basearch/
- Enabled=1
- Gpgcheck=1
- Gpgkey=http://www.jasonlitka.com/media/rpm-gpg-key-jlitka
Install MySQL
Run the Yum program to install MySQL
- Yum install MySQL Mysql-server
Add the MySQL entry boot entry (so that MySQL starts automatically when the system starts) and start the MySQL server immediately:
- Chkconfig--levels 235 mysqld on
- /etc/init.d/mysqld start
To set the MySQL root account password:
- Mysql_secure_installation
- Note:running all PARTS of this SCRIPT are RECOMMENDED for all MySQL
- SERVERS in PRODUCTION use! Please READ each STEP carefully!
- In order to log into MySQL to secure it, we'll need the current
- Password for the root user. If you ' ve just installed MySQL, and
- You haven ' t set the root password yet, the password would be blank,
- So, should just press ENTER here.
- Enter current password to root (enter for none):
- OK, successfully used password, moving on ...
- Setting The root password ensures that nobody can log into the MySQL
- Root user without the proper authorisation.
- Set root Password? [y/n] <--ENTER
- New Password: <--your MySQL root password
- Re-enter new password: <--your MySQL root password
- Password Updated successfully!
- Reloading privilege tables.
- ... success!
- By default, a MySQL installation have an anonymous user, allowing anyone
- To log into MySQL without has to has a user account created for
- them. This was intended only for testing, and the installation
- Go a bit smoother. You should remove them before moving into a
- Production environment.
- Remove anonymous users? [y/n] <--ENTER
- ... success!
- Normally, Root should only is allowed to connect from ' localhost '. This
- Ensures that someone cannot guess at the root of password from the network.
- Disallow Root login remotely? [y/n] <--ENTER
- ... success!
- By default, MySQL comes with a database named ' test ' that anyone can
- Access. This was also intended only for testing, and should be removed
- Before moving into a production environment.
- Remove test database and access to it? [y/n] <--ENTER
- -Dropping test database ...
- ... success!
- -Removing privileges on test database ...
- ... success!
- Reloading the privilege tables would ensure that all changes made so far
- would take effect immediately.
- Reload privilege tables now? [y/n] <--ENTER
- ... success!
- Cleaning up ...
- All done! If you've completed all of the above steps, your MySQL
- Installation should now is secure.
- Thanks for using mysql!
Installing Apache
Apache is available in the CentOS package, so we can use Yum to install:
- Yum Install httpd
Set the system to boot from Apache when booting
- Chkconfig--levels 235 httpd on
and start Apache
- /ETC/INIT.D/HTTPD start
Now that you type http://192.168.0.100 directly in your browser, you should see the Apache test page.
Install PHP
We can install PHP and Apache PHP modules according to the following command:
- Yum Install PHP
Then restart the Apache server:
- /ETC/INIT.D/HTTPD restart
Install related modules using PHP support MySQL
In order for PHP to support MySQL, we can install the Php-mysql package. You can also install other PHP modules. You can use the following command to search for available PHP modules:
- Yum Search PHP
Select some of the modules you need to install:
- Yum install php-mysql Php-common php-mbstring php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
Add Apache support PHP:
Edit/etc/httpd/conf/httpd.conf, add:
- AddType application/x-httpd-php. php
Now restart Apache:
- /ETC/INIT.D/HTTPD restart
Installing phpMyAdmin
phpMyAdmin is a visual management software for your MySQL database.
The installation is simple and the download is extracted to the root directory.
: http://www.phpmyadmin.net/home_page/downloads.php
Then we configure phpMyAdmin, in order to use phpMyAdmin not only to allow the localhost connection, we modify the Apache configuration.
- Vi/etc/httpd/conf.d/phpmyadmin.conf
Fill in the following content:
- #
- # WEB application to manage MySQL
- #
- #<directory "/usr/share/phpmyadmin" >
- # Order Deny,allow
- # Deny from all
- # Allow from 127.0.0.1
- #</directory>
- Alias/phpmyadmin/usr/share/phpmyadmin
To restart Apache:
/ETC/INIT.D/HTTPD restart
Then you can get into phpMyAdmin by HTTP://IP address/phpmyadmin/.
This article out to: https://www.centos.bz/2011/04/centos-yum-install-lamp-apache-mysql-php for reference
Yum Install lamp