LAMP动态网站部署架构是由一套 Linux+Apache+MySQL+PHP 组成的动态网站系统解决方案.LNMP动态网站部署架构是由一套 Linux+Nginx+MySQL+PHP 组成的动态网站系统解决方案.编译安装费时费力有时还会出错误,下面我们将通过Yum仓库,快速构建LANMP网站环境.
LAMP
1.配置yum源,安装依赖
yum install -y wget
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
|
2.安装LAMP5环境
yum install -y httpd httpd-devel mariadb mariadb-server mysql-devel php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml
|
3.安装LAMP7环境
yum -y install epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install -y httpd httpd-devel mariadb mariadb-server mysql-devel php70w php70w-intl php70w-mysql php70w-common php70w-gd php70w-mbstring php70w-mcrypt php70w-devel php70w-xml
|
LNMP
1.配置yum源,安装依赖
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum -y install epel-release yum install -y pcre pcre-devel zlib zlib-devel openssl openssl-devel libjpeg* libmcrypt libmcrypt-devel
|
2.安装Nginx
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm yum install -y nginx
systemctl start nginx systemctl enable nginx
|
3.安装与配置MySQL
yum install -y mariadb mariadb-server
systemctl start mariadb systemctl enable mariadb
mysql_secure_installation
|
4.安装PHP
yum install -y php php-devel php-fpm \ php-mysql php-common php-gd php-imap \ php-ldap php-odbc php-pear php-xml \ php-xmlrpc php-mbstring php-mcrypt \ php-bcmath php-mhash
systemctl start php-fpm systemctl enable php-fpm
|
5.编辑PHP主配置文件
编辑配置文件,在PHP文件末尾追加写入以下标★语句
vim /etc/php.ini
★cgi.fix_pathinfo=1 ★max_execution_time = 0 ★max_input_time = 300 ★memory_limit = 256M ★post_max_size = 100M ★upload_max_filesize = 10M
|
6.修改php-fpm的配置
编辑配置文件,在PHP-fpm文件中,修改以下标★语句
vim /etc/php-fpm.d/www.conf
★listen.owner = nobody ★listen.group = nobody
★user = nginx ★group = nginx
|
7.修改nginx的主配置
编辑配置文件,在server语句内,写入以下标★语句
vim /etc/nginx/nginx.conf
38 server { 39 listen 80 default_server; 40 listen [::]:80 default_server; 41 server_name _; 42 root /usr/share/nginx/html; 43 44 45 include /etc/nginx/default.d/*.conf; 46 ★ location / { ★ ★ root /usr/share/nginx/html; ★ index index.php index.html index.htm; ★ 52 } 53 ★ location ~ \.php$ { ★ root /usr/share/nginx/html; ★ try_files $uri =404; ★ fastcgi_pass 127.0.0.1:9000; ★ fastcgi_index index.php; ★ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; ★ include fastcgi_params; ★ } 62 63 error_page 404 /404.html; 64 location = /40x.html { 65 }
|
8.设置网页目录权限
chown -R nginx:nginx /usr/share/nginx/html
|
9.新建index.php测试页
vim /usr/share/nginx/html/index.php
<?php phpinfo(); ?>
|
10.重启服务,并查看9000端口是否启动成功
systemctl restart nginx systemctl restart php-fpm systemctl restart mariadb
netstat -npa | grep 9000
|