Fast setup of lamp environment under CentOS

Source: Internet
Author: User

First, prepare the article

1, configure the firewall, open 80 ports, 3306 ports
Vi/etc/sysconfig/iptables
-A input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT #允许80端口通过防火墙
-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT #允许3306端口通过防火墙

PS: The above 2 sentences should be placed under the default 22 port under this rule, if placed in another location, will cause the firewall failed to start!

Remember to restart the firewall after the configuration is successful /etc/init.d/iptables Restart #最后重启防火墙使配置生效

2. Turn off SELinux

Vi/etc/selinux/config
#SELINUX =enforcing #注释掉
#SELINUXTYPE =targeted #注释掉
Selinux=disabled #增加
: Wq #保存, close
Shutdown-r now #重启系统

3. Related commands

/ETC/INIT.D/HTTPD start #启动Apache

/etc/init.d/httpd Restart #重启Apache

/etc/init.d/httpd Stop#停Apache

/etc/init.d/mysqld Restart #重启MySql
/etc/init.d/httpd Restart #重启Apche

/etc/init.d/iptables Restart #重启防火墙使配置生效

/etc/init.d/mysqld start #启动MySQL
chkconfig mysqld on #设为开机启动

Second, installation article

1. Installing Apache

Yum install httpd #根据提示, enter Y to install successfully
/ETC/INIT.D/HTTPD start #启动Apache

# # # #设置主机域名, or launch Apache will error

vi/etc/httpd/conf/ Httpd.conf  #编辑
found #ServerName   www.example.com:80
modified to Servername  www.baidu.com : #这里设置为你自己的域名, if you don't have a domain name, you can set it to localhost

: wq! #保存退出
Chkconfig httpd on #设为开机启动
/etc/init.d/httpd Restart #重启Apache


2. Install MySQL

(1), install MySQL
Yum install MySQL Mysql-server #询问是否要安装, enter Y to install automatically until the installation is complete
/etc/init.d/mysqld start #启动MySQL
Chkconfig mysqld on #设为开机启动
Cp/usr/share/mysql/my-medium.cnf/etc/my.cnf #拷贝配置文件(Note: If the/etc directory has a default MY.CNF, you can overwrite it directly)

(2), set the password for the root account

mysql_secure_installation
Enter, according to the prompt for Y
Input 2 times the password, enter
According to the prompt input y
last appear: Thanks for using mysql!
MySQL Password setup complete, restart MySQL:
/etc/init.d/mysqld restart  #重启
/ Etc/init.d/mysqld stop  #停止
/etc/init.d/mysqld Start   #启动


3, Installation PHP5

(1), Installation PHP5
Yum Install PHP
Enter Y as prompted until the installation is complete

(2), install PHP components, so that PHP5 support MySQL

Yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-b Cmath Php-mhash Libmcrypt
Select the above installation package here for installation
Enter Y return as prompted
/etc/init.d/mysqld Restart #重启MySql
/etc/init.d/httpd Restart #重启Apche


Third, the test article

By default, the code source file is in the /var/www/html directory

Cd/var/www/html
VI index.php #输入下面内容
<?php

Phpinfo ();
?>
: wq! #保存退出
In the client browser enter the server IP address, you can see the configuration information as shown in the relevant!



Fast setup of lamp environment under CentOS

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.