Quickly build a LAMP environment in CentOS and build a lamp in centos
LAMP -- Linux Apache MySQL PHP
In the CentOS installation sequence, I usuallyApache->MySQL->PHP
Step 1. install and configure Apache
1. Install using yum
yum install httpd
2. Modify the firewall configuration and open port 80. You can also open port 3306 of MySQL.
vi /etc/sysconfig/iptables
Add two records
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
Add location, as shown in figure
3. Disable SELINUX.
vi /etc/selinux/config
Modify SELINUX = disabled
4. Apache configuration file
vi /etc/httpd/conf/httpd.conf
Find ServerName and set it to your own domain name. If there is no domain name, you can set it to localhost: 80.
5. Start Apache automatically upon startup
chkconfig httpd on
6. Restart Apache
service httpd restart
7. Open the browser and enter the address to test
Step 2. install and configure MySQL
1. Install using yum
yum install mysql mysql-server
2. Start MySQL automatically at startup
chkconfig mysqld on
3. Set the root password for MySQL
mysql_secure_installation
Enter y to set the password. After setting the password, press enter until Thanks for using MySQL appears!
4. Restart MySQL
service mysqld restart
Step 3: install and configure PHP
1. Install using yum
yum install php
2. install PHP Components
yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt
3. Restart Apache and MySQL
4. You can upload PHP files to the default code directory for testing. The default directory is/var/www/html. You can modify the path in the httpd. conf file.
* Then, you can configure Apache MySQL PHP based on your specific needs. The default configuration file path is as follows:
Apache configuration file path:/etc/httpd/conf/httpd. conf
MySQL configuration file path:/etc/my. cnf
PHP configuration file path:/etc/php. ini