Install LNMP and phpMyAdmin under CentOS7

wangking wrote
The work needs to use CentOS7, which requires the installation of LNMP mode. MYSQL under CentOS7 has been replaced by Mariadb. This does not matter, it is completely compatible, and there is no need to worry about it. So let's get started!

 

1. Before installing LNMP, install EPEL in order to install software other than the source, such as Nginx, phpMyAdmin, etc.

yum install epel-release

Tip: EPEL, the Extra Packages for Enterprise Linux, the enterprise version of linux additional package. This software repository has a lot of very commonly used software, and it is specially designed for RHEL. It is a good supplement to the RHEL standard yum source. It is completely free to use and maintained by the Fedora project, so if you are using RHEL, or CentOS , Scientific and other RHEL systems, you can use EPEL's yum source with confidence. 

 

2. Install Nginx

a) yum install nginx
b) systemctl start nginx #start nginx
c) systemctl enable nginx #set startup

 3. Install MYSQL (MariaDB)

a) yum install mariadb-server mariadb
b) systemctl start mariadb #start mariadb
c) systemctl enable mariadb #set startup

 4. Set MariaDB password

mysql_secure_installation # will ask to enter the original password, just click Enter, the rest is to enter the new password and confirm the password

5. Install PHP

yum install -y php php-devel php-fpm php-mysql php-common php-devel 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

 

6. Open php-fpm

a) systemctl start php-fpm #Open php-fpm
b) systemctl enable php-fpm #Automatic start at boot

7. Install phpMyAdmin

 

a) wget https://files.phpmyadmin.net/phpMyAdmin/4.4.12/phpMyAdmin-4.4.12-all-languages.zip
b) cd /usr/share/nginx/html/
c) unzip phpMyAdmin-4.4.12 -all-languages.zip
d) mv phpMyAdmin-4.4.12-all-languages ​​phpmyadmin
e) chown -R nginx.nginx /var/lib/php/session
#Visit http://youipaddress/phpmyadmin, if you can access it, Then it worked!

 

8. Modify the corresponding configuration

      A) Modify the configuration of php.ini

vim /etc/php.ini
cgi.fix_pathinfo=1 #将注释去掉,开启PHP的pathinfo伪静态功能。
max_execution_time = 0  #脚本运行的最长时间,默认30秒
max_input_time = 300#脚本可以消耗的时间,默认60秒
memory_limit = 256M#脚本运行最大消耗的内存,根据你的需求更改数值,默认128M
post_max_size = 100M  #单提交的最大数据,此项不是限制上传单个文件的大小,而是针对整个表单的提交数据进行限制的。限制范围包括表单提交的所有内容.例如:发表贴子时,贴子标题,内容,附件等…默认8M
upload_max_filesize = 10M#上载文件的最大许可大小 ,默认2M

      B) 修改php-fpm的配置

vim /etc/php-fpm.d/www.conf

找到以下两行,解除注释
listen.owner = nobody
listen.group = nobody

找下以下两行,将各自的apache改为nginx
user = apache -> user = nginx
group = apache -> group = nginx

 

     C) 修改nginx的配置

vim /etc/nginx/conf.d/default.conf
server {
    listen       80;
    server_name  server_domain_name_or_IP;

    location / {
        root   /usr/share/nginx/html;
        index  index.php index.html index.htm;
    }

    error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    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;
    }
	
}
 
参考文章:
1.https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-7
2.http://imcn.me/html/y2014/21227.html
3.http://my.oschina.net/u/2404183/blog/483968?fromerr=sAqMqzuD

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326685405&siteId=291194637