Note: When managing the server, it is strongly recommended to use a normal user!
The LNMP (ie nginx-mysql-php) server has always been considered a server with high performance and low memory usage. Let's introduce how to install it through a simple YUM command
1. Preparation
1. Configure the firewall, open port 80 and port 3306
vim /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 through the firewall
The correct one should be to add to the default 22 port rule and save it, and restart iptables
/etc/init.d/iptables restart
2. Close SELINUX (best to close)
#SELINUX=enforcing #Comment
out
#SELINUXTYPE=targeted #Comment out
SELINUX=disabled #Add
:wq #Save and exit
shutdown -r now #Restart the system
#SELINUXTYPE=targeted #Comment out
SELINUX=disabled #Add
:wq #Save and exit
shutdown -r now #Restart the system
Or temporarily shut down:
$ sudo setenforce 0
$ status
3. Install the C compiler:
yum -y install gcc gcc-c++ autoconf automake
4.Install the third-party yum source
sohu source address (64-bit source): http://mirrors.sohu.com/fedora-epel/6/x86_64 /
centos 6.X 64bit:
rpm -Uvh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
rpm -ivh http ://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
2. Install mysql
yum -y install gcc gcc-c++ autoconf automake
4.Install the third-party yum source
sohu source address (64-bit source): http://mirrors.sohu.com/fedora-epel/6/x86_64 /
centos 6.X 64bit:
rpm -Uvh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
rpm -ivh http ://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
1. Uninstall the apache that comes with the system first, and then update the software library
yum update
2, yum install mysql
It is recommended to use one of the following
<1>
or
<2>
methods for installation:
<1>[mysql directory]
[★]centos6.5 uses yum to install mysql5.6
<2>[mysql directory]
[★]
Install MariaDB 10 on CentOS 6.5
<3> 直接安装
yum -y install mysql-server
3、加入启动项并启动mysql
/etc/init.d/mysqld start
4、设置mysql密码及相关设置
/usr/bin/mysqladmin -u root password '123456' // 第一次,为root账号设置密码
也可参考:mysql_secure_installation
因为第一次启动这命令,所以直接回车下一步,然后输入你的mysql密码,按照提示操作。
1、yum安装nginx
yum -y install nginx
2、添加到启动项并启动nginx
chkconfig --levels 235 nginx on
/etc/init.d/nginx start
yum -y install nginx
2、添加到启动项并启动nginx
chkconfig --levels 235 nginx on
/etc/init.d/nginx start
文章来源:
http://webtatic.com/packages/php55/
这里使用 Webtatic EL6的YUM源来安装php5.5
建议安装前,先卸载以前的php再进行安装,使用:
CentOS/RHEL 7.x:
CentOS/RHEL 6.x:
CentOS/RHEL 5.x:
安装php5.5
yum -y install php55w php55w-common php55w-mysql php55w-fpm php55w-gd php55w-imap php55w-mbstring php55w-mcrypt php55w-pdo php55w-soap php55w-tidy php55w-xml php55w-xmlrpc php55w-devel php55w-pgsql
安装项可以参考“
[LNMP目录中]
PHP 5.4 on CentOS/RHEL 6.2”
1、PHP配置
<1> 编辑文件php.in
修改:
short_open_tag = On
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE
date.timezone = PRC
short_open_tag = On
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE
date.timezone = PRC
request_order = "CGP"
保存
保存
<2> 启动php-fpm
service php-fpm start
<3> php-fpm加入启动项
chkconfig --levels 235 php-fpm on
修改nginx配置文件,添加fastcgi支持
修改nginx.conf文件 :vi /etc/nginx/nginx.conf
配置多站点虚拟域名:配置/etc/nginx/nginx.conf,确认能够引入/etc/nginx/conf.d中配置已.conf为后缀的配置文件(后缀自定义)
<1> 配置文件部分代码:
server{
listen 80;
root /home/www/test;
index index.php index.html index.htm;
server_name www.test.com;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
try_files $uri $uri/ /index.php?$args;
#try_files $uri $uri/ /index.php?s=$uri;
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
<2> 重启nginx php-fpm
/etc/init.d/nginx restart
/etc/init.d/php-fpm restart
<3> 建立info.php文件
<1> 配置文件部分代码:
server{
listen 80;
root /home/www/test;
index index.php index.html index.htm;
server_name www.test.com;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
try_files $uri $uri/ /index.php?$args;
#try_files $uri $uri/ /index.php?s=$uri;
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
<2> 重启nginx php-fpm
/etc/init.d/nginx restart
/etc/init.d/php-fpm restart
<3> 建立info.php文件
添加如下代码:
<?php
phpinfo();
?>
在浏览器打开测试是否正常,如
http://www.test.com/info.php(记得hosts文件进行配置)。
六、其它注意项
1、【mysql目录】centos 6.5 修改mysq数据库目录问题
2、【mysql目录】当mysql开启bin-log,请查看“This function has none of DETERMINISTIC, NO SQL解决办法”
3、【nginx目录】nginx提示:413 Request Entity Too Large (设置nginx上传大小限制)
4、【PHP目录】[★] php上传下载文件大小限制