Thursday, July 23, 2015

Install LEMP on Centos 7.1

1. Install Nginx, then test it at http://ip_address
    yum install nginx -y
    systemctl start nginx 
    systemctl enable nginx

2. Modify /etc/nginx/nginx.conf to add following:
    location ~ \.php$ {
            root           /usr/share/nginx/html;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME \ $document_root$fastcgi_script_name;
            include        fastcgi_params;

3. Restart Nginx server:
    systemctl restart nginx

4. Install MySQL
    yum install mariadb-server mariadb
    systemctl start mariadb
    systemctl enable mariadb.service 

5. Install PHP
    yum install php php-common php-fpm php-mysql -y
    systemctl start php-fpm
    systemctl enable php-fpm

6. Modify /etc/php.ini to make "cgi.fix_pathinfo=0"

7. Modify /etc/php-fpm.d/www.conf to change both user and group equal to nginx instead of apache.

8. Restart Nginx:
    systemctl restart php-fpm

9. Create /usr/share/nginx/html/info.php with following code to test php. The php information page should be displayed at http://ip/info.php
    <?php phpinfo(); ?>

10. After the information on page http://ip/info.php confirmed. delete the file /usr/share/nginx/html/info.php.

If needed do the following to change the default PHP-FPM port to Unix socket:

1. Modify /etc/php-fpm.d/www.conf as show below:
    listen =
    listen = /var/run/php-fpm/php5-fpm.sock

2. Modify /etc/nginx/nginx.conf
    fastcgi_pass unix:/var/run/php-fpm/php5-fpm.sock;

Finally, restart Nginx and PHP-FPM:
    systemctl restart nginx
    systemctl restart php-fpm

Monday, July 13, 2015

Install FTP server vsftpd on CentOS 7.1

1. yum install vsftpd ftp -y
2. vi /etc/vsftpd/vsftpd.conf with following changes:
## Set to "NO" ##

## Uncomment ##

## Uncomment - Enter your Welcome message - This is optional ##
ftpd_banner=Welcome to UNIXMEN FTP service.

## Add at the end of this  file ##

3. systemctl restart vsftpd
4. systemctl enable vsftpd