Centos 6.4 actual working environment setup (LNMP)

Source: Internet
Author: User

Basic Configuration

Server IP settings. Edit the NIC configuration file. command:

1 vi /etc/sysconfig/network-scripts/ifcfg-eth0

Note: ifcfg-eth0 Parameters
TYPE = Ethernet # Nic TYPE
DEVICE = eth0 # Nic Interface Name
ONBOOT = yes # whether the system is automatically loaded at startup
BOOTPROTO = static # enable address protocol -- static: static protocol -- bootp protocol -- dhcp protocol
The following content is not about DHCP protocol settings. delete or comment out the DHCP protocol #
IPADDR = 192.168.1.11 # Nic IP Address
NETMASK = 255.255.255.0 # network address of the Network Adapter
GATEWAY = 192.168.1.1 # Nic GATEWAY address
DNS1 = 10.203.104.41 # Nic DNS address
HWADDR = 00: 0C: 29: 13: 5D: 74 # Nic device MAC address

BROADCAST = 192.168.1.255 # Nic BROADCAST address

Restart the network connection. command:

1 service network restart

Configure the firewall and enable port 80 and port 3306.

1 vi /etc/sysconfig/iptables

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:

########################################################## 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#########################################################
1/etc/init. d/iptables restart # restart the firewall to make the configuration take effect.

Disable SELINUX

1 vi /etc/selinux/config

# SELINUX = enforcing # comment out

# SELINUXTYPE = targeted # comment out

SELINUX = disabled # Add

: Wq save, close

1 shutdown-r now # restart the system

Configure a third-party yum source for CentOS 6.2 (no nginx software package exists in the default standard source for CentOS)

1 wget http://www.atomicorp.com/installers/atomic # download atomic yum source 2 sh./atomic # Install 3 yum check-update # update yum package
Install LNMPNginx

Before installing Nginx, you must install and install epel. For how to install epel in centos, see install epel in centos.

1 yum install-y nginx # install nginx2 service nginx start # start Nginx3 chkconfig -- add nginx # Set to startup 4 chkconfig nginx on # Set to startup 5/etc/init. d/nginx restart # restart
Mysql
1 yum install-y mysql-server # install Mysql and related components 2 chkconfig mysqld on # Set it to boot 3/etc/init. d/mysqld start # start MySQL4 cp/usr/share/mysql/my-medium.cnf/etc/my. cnf # copy the configuration file (Note: if the/etc directory contains a my. (cnf) 5 service mysqld restart # restart the service.

 

You can choose to reset the default password for Mysql. The default password is null. Reset the PASSWORD command:

1 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!

Remember to restart the Mysql service after the password is reset.

1 service mysqld restart
PHP
1 yum install-y php # install PHP2 yum install-y 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 libm crypt-devel php-fpm # Install PHP component 3 service mysqld restart # restart MySql4 service nginx restart # restart nginx5/etc/rc. d/init. d/php-fpm start # start php-fpm6 chkconfig php-fpm on # Set boot start

 

Nginx supports php In LNMP configuration Configuration
1 cp/etc/nginx. conf/etc/nginx. confbak # back up the original configuration file 2 vi/etc/nginx. conf # Edit

User nginx; # change the nginx running account to: nginx user in the nginx Group

 

1 cp/etc/nginx/conf. d/default. conf/etc/nginx/conf. d/default. confbak # back up the original configuration file 2 vi/etc/nginx/conf. d/default. conf # Edit

 

 

Index. php index.html index.htm; # add index. php
 1 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 2 # 3   location ~ \.php$ { 4     root           html; 5     fastcgi_pass   127.0.0.1:9000; 6     fastcgi_index  index.php; 7     fastcgi_param  SCRIPT_FILENAME   /usr/share/nginx/html$fastcgi_script_name; 8     include        fastcgi_params; 9   }10     # deny access to .htaccess files, if Apache's document root11     # concurs with nginx's one12     #13     location ~ /\.ht {14      deny  all;15      }16 }

# 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.

 

Configure php
1 vi/etc/php. ini # Edit

If not, use nano for replacement.

1 nano /etc/php.ini

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

Disable_functions = passthru, exec, system, chroot, scandir, chgrp, chown, shell_exec, proc_open, proc_get_status, ini_alter, ini_alter, disconnect, dl, openlog, syslog, readlink, symlink, release, delimiter, delimiter, dll, popen, disk_free_space, checkdnsrr, checkdnsrr, getservbyname, getservbyport, delimiter, posix_getgrnam, posix_getgroups, posix_getlogin, delimiter, delimiter, posix_getpid, delimiter, delimiter, posix_getpwuid, delimiter, posix_getsid, posix_getuid, delimiter, posix_kill, posix_mkfifo, delimiter, 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/

Configure php-fpm
1 p/etc/php-fpm.d/www. conf/etc/php-fpm.d/www. confbak # back up the original configuration file 2 vi/etc/php-fpm.d/www. conf # Edit

User = nginx # change the user to nginx

Group = nginx # change the group to nginx to restart all services
1 service nginx restart # restart Nginx2 service mysqld restart # restart Mysql3 service php-fpm restart # restart PHP

Finally, open the browser and you will see the following results:

 

 

Installation complete!

 

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.