Because the company requires a RedHat configuration, let me practice what to do in Linux.
It's not that difficult. But record it.
First, it is the redhat6.2 x86 system built with Vmware on the server. In RedHat, the source base in yum is charged. Centos, a derivative version of RedHat, aims to break the RedHat charges, so there is no difference between the two. The yum package of centos6 is used for configuration.
First, enter:
cd /etc/yum.repos.d/
This is where the yum source is stored. By default there will be a rhel-source.repo suffix file, we delete it or rename it to. Bak
The next step is to add the centos source. Create a new centos. Base. Repo file. Enter:
# CentOS-Base.repo## The mirror system uses the connecting IP address of the client and the# update status of each mirror to pick mirrors that are updated to and# geographically close to the client. You should use this for CentOS updates# unless you are manually picking other mirrors.## If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead.# [base]name=CentOS-6 - Base - mirrors.aliyun.combaseurl=http://mirrors.aliyun.com/centos/6/os/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=osgpgcheck=0gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 #released updates [updates]name=CentOS-6 - Updates - mirrors.aliyun.combaseurl=http://mirrors.aliyun.com/centos/6/updates/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updatesgpgcheck=0gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful[extras]name=CentOS-6 - Extras - mirrors.aliyun.combaseurl=http://mirrors.aliyun.com/centos/6/extras/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extrasgpgcheck=0gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages[centosplus]name=CentOS-6 - Plus - mirrors.aliyun.combaseurl=http://mirrors.aliyun.com/centos/6/centosplus/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplusgpgcheck=0enabled=0gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users[contrib]name=CentOS-6 - Contrib - mirrors.aliyun.combaseurl=http://mirrors.aliyun.com/centos/6/contrib/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contribgpgcheck=0enabled=0gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
After saving, we have a centos source. Run the following command: Yum-y update!
Below isInstall nginx. We need to execute:
yum -y --enablerepo=remi,remi-test install nginx
Some may encounter:No nginx package!This is easy to solve.
Create an nginx. Repo file in the yum. Repos. D folder that you just created. Enter the following content:
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/6/$basearch/ gpgcheck=0 enabled=1
OK. This is a separate nginx source. Run the above command to install nginx again!
Continue,Install PHP and PHP-FPM:
yum -y --enablerepo=remi,remi-test install php php-fpm php-common
Install php5.4.4 module extension,Some will promptNo package, These are useless, don't worry about it!
yum -y --enablerepo=remi,remi-test install php-pecl-apc php-cli php-pear php-pdo php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml
In this case, OK.Run the following commandIf an error occurs, it indicates that the above step has an error.
Start nginx: Service nginx start PHP-FPM: Service PHP-FPM start
The following describes how to configure nginx to use PHP-FPM:
/etc/nginx/conf.d/
Open the default. conf file. Find:
Location/{root/usr/share/nginx/html; # This line is the root directory of the website, where your website files are stored! Index index.html index.htm; # This line adds the default homepage of the website. Of course, you can also add an index. php! }
Find the following content and remove the # above them:
#location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; # include fastcgi_params; #}
Open the RedHat firewall file and add port 80 to the whitelist:
cd /etc/sysconfig/
Open the iptables file and enter the following content:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
Restart Firewall:
service iptables restart
So far, PHP and nginx have been set up. Let's give it a try. Restart nginx and PHP-FPM first:
service nginx restart service php-fpm restart
Enter http: // localhost/on your RedHat page. Then, welcome to nginx is displayed! Nginx is successfully installed.
Enter the root directory of your website:/usr/share/nginx/html
Create a phpinfo. php file:
<?phpphpinfo();?>
Then access http: // localhost/phpinfo. php
Check whether the PHP configuration page is displayed. If it appears, PHP is successfully installed.
Start installing MySQL !!!!!Enter:
yum -y --enablerepo=remi,remi-test install mysql mysql-server
Start MySQL and set auto-start:
service mysqld start chkconfig --levels 235 mysqld on
Then, go to the/usr/bin/folder and run the mysql_secure_installation file:
cd /usr/bin/./mysql_secure_installation
This is the security mode for configuring MySQL. It is best to configure MySQL for the first installation. Increased security!
After the above files are executed, some configuration problems may occur.
1. Enter current password for root (enter for none): (enter the current root password) The current password is empty, so press enter directly.
2. Set root password? [Y/n] (whether to set the password) Enter y and press Enter.
3. New Password: (new password)
4. re-enter new password: (re-enter)
5. Remove anonymous users? [Y/n] (delete anonymous account)
6. disallow root login remotely? [Y/n] (root user remote login prohibited)
7. Remove test database and access to it? [Y/n] (delete the default test database)
8. Reload privilege tables now? [Y/n] (reload permission table)
Security mode configuration is complete!
Open the RedHat firewall file and add Port 3306 to the whitelist:
cd /etc/sysconfig/
Open the iptables file and enter the following content:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
Restart Firewall:
service iptables restart
OK! Lnmp configuration is complete!