Build the CentOS development environment
-------------------------------------------------------------------------Ready to work-------------------------------------------- -------------------------------------
1. Configure the firewall to turn on 80 ports, 3306 ports
->vim/etc/sysconfig/iptables
#将以下两行配置, add to the bottom of Port 22.
-A input-m state--state new-m tcp-p TCP--dport 80-j accept# allow 80 ports through the firewall
-A input-m state--state new-m tcp-p TCP--dport 3306-j accept# allow 3306 ports through the firewall
->/etc/init.d/iptables restart# configuration complete, reboot firewall
2. Turn off SELinux (Linux kernel security mechanism)
->vim/etc/selinux/config
#注释以下两行配置
Selinux=enforcing
selinuxtype=targeted
#新增配置
Selinux=disabled
: wq! #保存, close
Shutdown-r now# Restart System
-------------------------------------------------------------------------installation---------------------------------------------- -----------------------------------
1. Installing the Apache server
->yum install httpd# According to the information, all the way to enter Y can be installed successfully
->/ETC/INIT.D/HTTPD start# Launch Apache
#不出意外, will error: Httpd:httpd:Could not ... Omit ... for ServerName
#OK是ServerName
#解决办法:
->vim/etc/httpd/conf/httpd.conf#vim Edit
#找到 #ServerName www.example.com:80
#修改为 #ServerName localhost:80# Here, or it can be your domain
->:wq! #保存, close
->chkconfig httpd on# set to boot
->/ETC/INIT.D/HTTPD restart# Restart Apache
2. Install MySQL
->yum install MySQL mysql-server# according to the information, all the way to enter Y can be installed successfully
->/etc/init.d/mysqld start# start MySQL
->chkconfig mysqld on# set to boot
->cp/usr/share/my-medium.cnf/etc/my.cnf# Copy configuration file, if prompt exists, directly overwrite
#为root账户设置密码, the default password is empty, according to the prompt to enter the password 2 times, all the way to enter Y
->mysql_secure_installation
#直到出现Thanks for using mysql!
#MySql密码设置完成, restart MySQL:
->/etc/init.d/mysqld Restart #重启
3. Installing PHP5
#根据提示输入Y直到安装完成
->yum Install PHP
#安装PHP组件 to enable PHP5 to support MySQL
#这里选择以下安装包进行安装, enter y all the way
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
/etc/init.d/mysqld Restart #重启MySql
/ETC/INIT.D/HTTPD Restart #重启Apche
-------------------------------------------------------------------------Configuration---------------------------------------------- -----------------------------------
1. Configure Apache
->vim/etc/httpd/conf/httpd.conf #编辑文件
Servertokens OS modified to: Servertokens Prod (the name of the server operating system is not displayed when the error page appears)
Serversignature on modified to: Serversignature OFF (the Apache version is not shown in the error page)
Options Indexes followsymlinks modified to: Options includes execcgi followsymlinks (Allow server to execute CGI and SSI, prohibit listing of directories)
#AddHandler cgi-script. CGI modified to: AddHandler cgi-script. cgi. PL (allows CGI scripts with extension. pl to run)
AllowOverride None modified to: allowoverride all (Allow. htaccess)
Adddefaultcharset UTF-8 modified to: Adddefaultcharset UTF-8 (add UTF-8 as default encoding)
Options Indexes multiviews followsymlinks modified to: Options MultiViews followsymlinks (does not display the tree structure on the browser)
DirectoryIndex index.html Index.html.var modified to: DirectoryIndex index.html index.htm default.html default.htm index.php default.php Index.html.var
KeepAlive Off modified to: KeepAlive on (allow program online)
Maxkeepaliverequests 100 modified to: Maxkeepaliverequests 1000 (Increased number of simultaneous connections)
: wq! #保存退出
->/ETC/INIT.D/HTTPD Restart #重启
->rm-f/etc/httpd/conf.d/welcome.conf/var/www/error/noindex.html Delete Default test page
2.php Configuration
->vim/etc/php.ini #编辑
Date.timezone = PRC Remove the preceding semicolon and change to Date.timezone = PRC
Disable_functions = Lists the functions that PHP can disable, and if some programs need to use this function, you can delete and cancel the disabled.
expose_php = Off Suppresses the display of PHP version information
MAGIC_QUOTES_GPC = on open MAGIC_QUOTES_GPC to prevent SQL injection
Short_open_tag = on support PHP short tag
Open_basedir =.:/ tmp/setting means to allow access to the current directory (that is, the php script file directory) and the/tmp/directory, you can prevent the PHP Trojan cross-site, if you change the installation program after the problem (such as: Dream Content Management System), you can log off this line, or directly write the program directory/data/ www.osyunwei.com/:/tmp/
: wq! #保存退出
->/etc/init.d/mysqld Restart #重启MySql
->/ETC/INIT.D/HTTPD Restart #重启Apche
CentOS Development Environment Lamp construction