Other languages English (source) ; Français |
Please remove this {{Draft}}template, when you're sure the page is complete and correct.
|
Introduction
This page aims at helping users getting started easily with Web development and publishing using Mageia.
The typical cases to be covered here are, by order of technical complexity:
- You use an external web site provider, and you want to modify simply content and pages
- You use an external web site provider, and you want to test and prepare the settings and contents on your LAN before publishing
- You want to use your computer as the server for publishing, allowing access from outside
Setting up a Web Server
To install all typical packages, use the meta-package (collection of packages): task-lamp
This will install the following key applications:
- Apache: the web server
- PHP: language to generate dynamic pages
- MariaDB: a database server
- PERL: a programming language
To start the server once installed, go to the MCC / System / Manage system services by enabling or disabling them and start httpd. Note: notice that by default, the server will always start when starting your computer. A simple way to test the web server is to type "localhost" in the address bar of your browser. If the web server is working correctly it should display the "It works!" text/page.
For local development (no need for external access)
If your published website is hosted on a different sever and you want to use your computer as a development computer to create and test your website before making the changes live, you may want to create one or several local sites. These are named hosts.
Create several local domains for development and test in your home directory
This is not the only process that can be used, there are various ways of achieving the same result. By default, the files are located in /var/www/html/ which requires root access. To simplify the edition of your new local websites, the files will be located in your home folder (it is also easier for you that way to back them up). Note that if your site uses a database you will need to also include that in your backups.
- Let's create a directory for that, for instance /home/your_user_name/www
- Within, create one folder per website. For instance, mysite_test and mysite_dev
- Set up the permissions to all (low level of security, assuming you are the only user of your computer): chmod -R 777 www
Now edit apache web server configuration:
- Save the existing configuration:
cd /etc/httpd/conf cp httpd.conf httpd.conf.bak
- Change the default document root of your web server:
vi httpd.conf
Change the lines:
DocumentRoot "/home/your_user_name/www" # # Relax access to content within /var/www. # <Directory "/home/your_user_name/www"> AllowOverride None # Allow open access: Require all granted </Directory> # Further relax access to the default document root: <Directory "/home/your_user_name/www">
To create new hosts:
1- set up host names to allow you to type them in your browser.
- Go to the MCC / Network & Internet / Hosts definition : This will edit the /etc/hosts file.
- Add as many hosts as you need, all with the address 127.0.0.1, and the name you will use to access your local site
- For instance: localhost (let's keep it), mysite_dev, mysite_test
2- set up redirection allowing you to be redirected from the host names to the directory holding the website.
- Start a console and change user to be root
- cd /etc/httpd/conf/vhosts.d
- vi myvhost.conf
- for each host name:
- Provide the directory path and grant the access:
<Directory "/home/your_user_name/www/mysite_dev"> Allow from all </Directory> <Directory "/home/your_user_name/www/mysite_test"> Allow from all </Directory>
- Create the redirection from the host name
# <VirtualHost 127.0.0.1> DocumentRoot /home/your_user_name/www/mysite_dev ServerName mysite_dev </VirtualHost> # <VirtualHost 127.0.0.1> DocumentRoot /home/your_user_name/www/mysite_test ServerName mysite_test </VirtualHost>
- Restart the server: go to the MCC / System / Manage system services by enabling or disabling them and stop and start the service httpd.
- to test this is working, type mysite_dev in your browser
For access on LAN
To allow other machines on the LAN to access the web server we need to open the firewall to allow access.
- Go to the MCC / Security / Setup Your Personal Firewall / Enable Web Server then click "OK"
Then, using a difference device on the same network, enter into the browser: ip.of.web.server/website_root_folder
eg 192.168.0.99/test_sitea
Where test_sitea is the root folder for that website. This is configured through /etc/httpd/conf/httpd.conf
Note ip.of.web.server/virtual_host_name will not work, as the host name requires redirection from other machines.
For external access
to be documented
Web page Development tools
Out of the pocket websites
- Tiki Free/Libre/Open Source Web Application with the most built-in features. Installation: download the archive from this website and extract it in your www folder.
Developping manually the pages (HTML, PHP, etc.)
to be documented
For reference, other applications using the web server
owncloud
to be documented
Troubleshooting
to be documented