Centos 6 YUM install lmp and centoslmp

Source: Internet
Author: User

Centos 6 YUM install lmp and centoslmp

Preparation:

1. configure the firewall and enable port 80 and port 3306.
Vi/etc/sysconfig/iptables
-A input-m state -- state NEW-m tcp-p tcp -- dport 80-j ACCEPT (allow port 80 to pass through the firewall)
-A input-m state -- state NEW-m tcp-p tcp -- dport 3306-j ACCEPT (allow port 3306 to pass the firewall)
Note: many users add these two rules to the last line of the firewall configuration, which causes firewall startup failure. The correct rule should be added to the default port 22.
The firewall rules are as follows:
######################################## #################

123456789101112131415 # Firewall configuration written by system-config-firewall# Manual customization of this file is not recommended.*filter:INPUT ACCEPT [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [0:0]-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT-A INPUT -p icmp -j ACCEPT-A INPUT -i lo -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT-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-A INPUT -j REJECT --reject-with icmp-host-prohibited-A FORWARD -j REJECT --reject-with icmp-host-prohibitedCOMMIT


######################################## #################
/Etc/init. d/iptables restart # restart the firewall to make the configuration take effect.

2. Disable SELINUX
Vi/etc/selinux/config
# SELINUX = enforcing # comment out
# SELINUXTYPE = targeted # comment out
SELINUX = disabled # Add
: Wq save, close
Shutdown-r now # restart the system

3. Configure the third-party yum source of CentOS 6.2 (the nginx package is not included in the standard source of CentOS by default)
Yum install wget # install the download tool wget

1 wget http://www.atomicorp.com/installers/atomic

# Download atomic yum Source
Sh./atomic # Installation
Yum check-update # update yum Software Package
######################################## ########################
Installation:

1. Install nginx
Yum install nginx # install nginx. Enter Y as prompted to install nginx.
Service nginx start # start
Chkconfig nginx on # Set to boot
/Etc/init. d/nginx restart # restart
Rm-rf/usr/share/nginx/html/* # Delete the default ngin test page

Ii. Install MySQL
1. Install mysql

Yum install mysql-server # ask if you want to install it. Enter Y to install it automatically until the installation is complete.
/Etc/init. d/mysqld start # start MySQL
Chkconfig mysqld on # Set to boot
Cp/usr/share/mysql/my-medium.cnf/etc/my. cnf # copy the configuration file (Note: if there is a my. cnf under the/etc directory by default, directly overwrite it)
Shutdown-r now # restart the system

2. Set a password for the root account
Mysql_secure_installation
Press enter and enter Y as prompted.
Enter the password twice and press Enter.
Enter Y as prompted
Thanks for using MySQL!

After setting the MySql password, restart MySQL:
/Etc/init. d/mysqld stop # stop
/Etc/init. d/mysqld start # start
Service mysqld restart # restart

3. install PHP
1. install PHP
Yum install php # Enter Y as prompted until installation is complete
2. Install the PHP component to make PHP support MySQL and PHP support FastCGI Mode

1 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 libmcrypt-devel php-fpm

# Enter Y and press enter as prompted
/Etc/init. d/mysqld restart # restart MySql
/Etc/init. d/nginx restart # restart nginx
/Etc/rc. d/init. d/php-fpm start # start php-fpm
Chkconfig php-fpm on # Set startup
######################################## ########################
Configuration

1. Configure nginx to support php
Cp/etc/nginx. conf/etc/nginx. confbak # back up the original configuration file
Vi/etc/nginx. conf # Edit
User nginx; # change the nginx running account to: nginx user in the nginx Group
: Wq! # Save and exit

Cp/etc/nginx/conf. d/default. conf/etc/nginx/conf. d/default. confbak # back up the original configuration file
Vi/etc/nginx/conf. d/default. conf # Edit

Index. php index.html index.htm; # add index. php

123456789   # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000  #  location ~ \.php$ {    root           html;    fastcgi_pass   127.0.0.1:9000;    fastcgi_index  index.php;    fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;    include        fastcgi_params;  }


# Cancel the location comment of the FastCGI server and change the parameter of the fastcgi_param line to $ document_root $ fastcgi_script_name or use the absolute path.

2. Configure php

Vi/etc/php. ini # Edit

Date. timezone = PRC # Remove the semicolon in front of row 946 and change it to date. timezone = PRC.

1   disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname


# List the functions that PHP can disable in Row 3. If some programs need this function, delete it and disable it.
Expose_php = Off # disable display of php version information in line 432
Magic_quotes_gpc = On # enable magic_quotes_gpc On Line 1 to prevent SQL Injection
Open_basedir =. :/tmp/# in row 380, set to allow access to the current directory (that is, the directory where the PHP script file is located) And/tmp/directory, to prevent php trojans from being cross-site, if there is a problem with the installation program after the change, you can log out of this line, or directly write the program directory path/var/www/html/www.osyunwei.com/:/tmp/
: Wq! # Save and exit

3. Configure php-fpm

Cp/etc/php-fpm.d/www. conf/etc/php-fpm.d/www. confbak # back up the original configuration file
Vi/etc/php-fpm.d/www. conf # Edit
User = nginx # change the user to nginx
Group = nginx # change the group to nginx

/Etc/init. d/mysqld restart # restart MySql
/Etc/init. d/nginx restart # restart nginx
/Etc/rc. d/init. d/php-fpm restart # restart php-fpm
######################################## ########################
Test
Cd/usr/share/nginx/html/# enter the default nginx website root directory
Vi index. php # create an index. php file

123 <?php           phpinfo();       ?>


: Wq! # Save

Chown nginx. nginx/usr/share/nginx/html/-R # Set the directory owner

Chmod 700/usr/share/nginx/html/-R # Set Directory Permissions

Enter the Server IP address in the client browser to view the configuration information!
######################################## ########################

Remarks

The default nginx site directory is/usr/share/nginx/html/

Permission settings: chown nginx. nginx/usr/share/nginx/html/-R

The MySQL database directory is/var/lib/mysql.

Permission settings: chown mysql. mysql-R/var/lib/mysql

 

Reference: http://www.osyunwei.com/archives/2353.html

Https://zhidao.baidu.com/question/362471324498583292.html

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.